Jump to content

Multiple page output in one record based on different fields


Rick J.

Recommended Posts

I would like to produce multiple pages from an individual record each with different graphics based on 4 separate fields in that each record. Not all records will have all 4 fields filled with information (i.e. some may have only one field, and others may have from 2 – 4 fields and not always in order). The fields that are blank should not produce a blank page in the output file. I will only have one input file to work with. I would like all the pages to be in one pdf that I could print from it.

 

I tried the code in this thread

http://forums.pti.com/showthread.php?t=4566&highlight=compose+multiple+pages+record

it somewhat works when there is only one record (still output blank pages). The minute I added a second record everything went south.

 

Any help would be great.

 

Here’s my info:

FusionPro VDP Creator 0.3.36

Adobe Acrobat XI

Mac OS X Yosemite Version 10.10.5

Edited by Dan Korn
Link to comment
Share on other sites

I tried the code in this thread

http://forums.pti.com/showthread.php?t=4566&highlight=compose+multiple+pages+record

it somewhat works when there is only one record (still output blank pages). The minute I added a second record everything went south.

Please elaborate on "everything went south." What specifically happened?

 

Anyway, the code in that other thread outputs exactly (only) one page per record. It sounds like you want to output multiple pages per record. So it's not the right solution. But it's hard to know exactly what the right solution is without seeing the job files.

Link to comment
Share on other sites

What happened when more than one record was in my file is that it would bring in the wrong graphic on the wrong page and leave some graphics out where they were needed.

 

I do need multiple pages per record (from 1-4 pages per record).

 

What job files do you need me to attach to proceed.

 

Thanks,

Rick

Link to comment
Share on other sites

What happened when more than one record was in my file is that it would bring in the wrong graphic on the wrong page and leave some graphics out where they were needed.

 

I do need multiple pages per record (from 1-4 pages per record).

Okay, thanks.

What job files do you need me to attach to proceed.

The collected template. Though I don't need the fonts. From the menu in Acrobat, select FusionPro -> Collect, then uncheck Fonts and click Collect, and upload the Zip file here.

Link to comment
Share on other sites

I have collected the project and attached all the files.

 

I tried to simplify my project and now it is producing to many pages with nothing on them. What I need is any field with and "H" to bring in the "H Graphic" and the fields with a "M" to bring in the "M Graphic".

 

Thank you for taking a look.

TribTest.zip

Link to comment
Share on other sites

I tried to simplify my project and now it is producing to many pages with nothing on them.

That's because you need to assign your graphic rule to your graphic frame.

 

What I need is any field with and "H" to bring in the "H Graphic" and the fields with a "M" to bring in the "M Graphic".

 

After you assign the rule to your frame, you can delete the rule and populate it from the OnRecordStart callback:

var FP = FusionPro.Composition;
var graphics = [Field("TribType"), Field("TribType1"), Field("TribType2"), Field("TribType3")].filter(String);

if (!(FP.repeatRecordCount = graphics.length))
   ReportError('No graphics to compose for record #' + FP.inputRecordNumber);

var graphic = Resource('Graphic' + graphics[FP.repeatRecordNumber - 1]);
FP.AddGraphicVariable('BackgroundGraphic', graphic);

Link to comment
Share on other sites

Thanks Ste for the help. Everything worked flawless.

 

I realized that I have a new problem because I forgot that I have to add a text frame with data relevant to each graphic. I spent a few hours trying to get this to work with no avail. I can't seem to get the text to come back with each graphic. I tried to treat it like the graphic, but it doesn't seem work with text. What am I missing? I'm uploading a new collection with a modified Fusion Pro template and a modified data file.

 

Thanks in advance for any help,

Rick J.

 

 

FusionPro VDP Creator 0.3.36

Adobe Acrobat XI

Mac OS X Yosemite Version 10.10.5

FP_TribTest_1.zip

Link to comment
Share on other sites

Delete the "NameAdd" rule and change your "OnRecordStart" callback rule to:

var FP = FusionPro.Composition;
var graphics = [Field("TribType"), Field("TribType1"), Field("TribType2"), Field("TribType3")].filter(String);
[color="red"]var txt = [Field("TName"), Field("TName1"), Field("TName2"), Field("TName3")].filter(String);
[/color]

if (!(FP.repeatRecordCount = graphics.length))
   ReportError('No graphics to compose for record #' + FP.inputRecordNumber);

var graphic = Resource('Graphic' + graphics[FP.repeatRecordNumber - 1]);
FP.AddGraphicVariable('BackgroundGraphic', graphic);
[color="Red"]FP.AddVariable('NameAdd', (txt[FP.repeatRecordNumber - 1] || ''));[/color]

 

I noticed in your example that some records (record 11 – for example) don't have names associated with all of the graphics. If you only want to compose the graphics that have names associated with them, you'd need to rewrite the code to be something like this:

var FP = FusionPro.Composition;
var fields = [];

for (var i = 0; i < 4; i++) {
 var [graphic, txt] = ['TribType', 'TName'].map(function(s) { return Field(s + (i ? i : '')); }).filter(String);
 if (graphic && txt)
   fields.push({ graphic: Resource('Graphic' + graphic), txt: txt });
}

if (!(FP.repeatRecordCount = fields.length))
 ReportError('Nothing to compose for record #' + FP.inputRecordNumber);

var content = fields[FP.repeatRecordNumber - 1];
FP.AddGraphicVariable('BackgroundGraphic', content.graphic);
FP.AddVariable('NameAdd', content.txt);

Link to comment
Share on other sites

  • 2 weeks later...
Thanks Ste the code is working good. I have a bump in the road. I have modified my Name Add rule (that ends up getting deleted) to be tagged text that needs to be formatted with html tags. The format looks correct in the rule editor window. When I run the file the formatting is lost. Do I need to add code in the On Record Start to tell it that it is tagged text?
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...