Jump to content

Inserting Multi-page PDF variable graphics


Admin1676454018

Recommended Posts

I've used this script many times without an imposition, but am having trouble using an imposition template with an infinite stack.

 

In the attached sample, I'm trying to get the "AK" version with 14 pages to print 3 times, the "GTC1" version with 23 pages to print 4 times, then the "SSG" version with 22 pages to print 5 times. However, it seems that since the "AK" version is first record, it composes the last 2 records with only 14 pages too and I get the error message:

The number of pages in this record does not match the imposition signature: 9 pages will be truncated.

 

From another thread, I tried adding these lines in OnJobStart, but it sounds like that is uneccessary:

//FusionPro.Composition.chunksBreakStacks = true;

 

//FusionPro.Composition.forcePreprocessing = true;

 

So what's the trick for getting variable page PDFs to work with infinite stacking imposition?

InsertGraphics Sample.zip

Link to comment
Share on other sites

I don't believe stacking works with projects where each record has a different number of pages output. When job begins to compose FP Imposer presumably calculates total number of records and multiplies that times number of pages in layout/first record to determine total pages which is used to determine where to break each stack (and thereby determine total number of sheets). This process does not take into account that each record might have different number of pages based on rules since they have not processed yet.

 

I have always had to output single pages in this scenario and use 3rd party imposition software for the stacking process.

 

I will be thrilled if I turn out to be wrong! ;)

Link to comment
Share on other sites

I don't believe stacking works with projects where each record has a different number of pages output.

I would make a more general statement: Imposition expects each record to output the same number of pages, whether you're doing stacking or not. There's a setting in FP Imposer where you enter the number of pages per record.

When job begins to compose FP Imposer presumably calculates total number of records and multiplies that times number of pages in layout/first record to determine total pages which is used to determine where to break each stack (and thereby determine total number of sheets).

Yes, there's a preprocessing step which determines the number of records, and where the stacks and chunks will break.

This process does not take into account that each record might have different number of pages based on rules since they have not processed yet.

Well, it's not so much that preprocessing doesn't expect records to have different numbers of pages; it's that the entire imposition system doesn't expect it.

I have always had to output single pages in this scenario and use 3rd party imposition software for the stacking process.

 

I will be thrilled if I turn out to be wrong! ;)

No, you're not wrong. Although it's not clear to me what the expectation is if you define a signature of, say, 2-up for a business card with a front and a back, and then you output three pages from a record.

Link to comment
Share on other sites

Although it's not clear to me what the expectation is if you define a signature of, say, 2-up for a business card with a front and a back, and then you output three pages from a record.

It would be nice to have the option of creating business cards (using your example) for 500 employees while generating different quantities for each employee based on title (i.e. executives get 300 each; administrative/sales gets 500 each; everyone else gets 100 each). These would all be stacked by employee in one print-ready file.

Link to comment
Share on other sites

It would be nice to have the option of creating business cards (using your example) for 500 employees while generating different quantities for each employee based on title (i.e. executives get 300 each; administrative/sales gets 500 each; everyone else gets 100 each). These would all be stacked by employee in one print-ready file.

You can do exactly that in FusionPro now. In OnRecordStart, you can set FusionPro.Composition.repeatRecordCount to the appropriate number for each person, and you can call FusionPro.Composition.StartNewStack() when the name changes.

 

But each record (and each iteration of a repeated record) still has to output the same number of pages.

Link to comment
Share on other sites

  • 1 month later...

I really like this script. The issue I'm having is with the orientation of the PDF's I'm trying to insert.

 

Some of the PDF's are set to lanscape and when they are placed in the merge they stay landscaped and get chopped off.

 

Is there a way for this script to force all the PDF's to a portrait orientation?

Link to comment
Share on other sites

I really like this script. The issue I'm having is with the orientation of the PDF's I'm trying to insert.

 

Some of the PDF's are set to lanscape and when they are placed in the merge they stay landscaped and get chopped off.

 

Is there a way for this script to force all the PDF's to a portrait orientation?

Well, you can figure out whether a graphic (such as a page in a PDF) is landscape or portrait, and determine whether to place it into a rotated graphic frame, with the code in this post:

http://forums.pti.com/showpost.php?p=1367&postcount=2

 

However, you can't rotate an inline graphic in a text frame, which is what is going on here with the multi-page PDF insertion rule.

 

But what you can do is use an FPRepeatableComponent to call out a Template Page, which can have separate graphic frames for landscape and portrait graphics, like I talk about here:

http://forums.pti.com/showpost.php?p=6173&postcount=12

Link to comment
Share on other sites

  • 1 month later...

I have a customer who wants this as well (multipage to handle bleeds or no bleeds), so I set it up as graphic copyholes instead of overflow pages. The catch is now they want a 16-page template.

 

So, I am trying to turn this, which works fine:

 

//Insert upload PDF into each page

for (pageLoop = 1; pageLoop <= pagesInPDF; pageLoop++)

{

PageFrame1.SetGraphic('<graphic file="' + PDFresourceRef.name + '" pagenumber = "1" scale="off" />');

PageFrame2.SetGraphic('<graphic file="' + PDFresourceRef.name + '" pagenumber = "2" scale="off" />');

PageFrame3.SetGraphic('<graphic file="' + PDFresourceRef.name + '" pagenumber = "3" scale="off" />');

return pathToPDF;

}

 

into something like this:

 

//Insert upload PDF into each page

for (pageLoop = 1; pageLoop <= pagesInPDF; pageLoop++)

{

'PageFrame' + pageLoop + '.SetGraphic(<graphic file="' + PDFresourceRef.name + '" pagenumber = "' + 'pageLoop" scale="off" />)';

return pathToPDF;

}

 

but this does not work in that it appears to return the desired value, but the graphics preview as blank. Has anyone tried this? Am I just missing something in the syntax?

Edited by invaricconsulting
Link to comment
Share on other sites

I have a customer who wants this as well (multipage to handle bleeds or no bleeds), so I set it up as graphic copyholes instead of overflow pages. The catch is now they want a 16-page template.

 

So, I am trying to turn this, which works fine:

 

//Insert upload PDF into each page

for (pageLoop = 1; pageLoop <= pagesInPDF; pageLoop++)

{

PageFrame1.SetGraphic('<graphic file="' + PDFresourceRef.name + '" pagenumber = "1" scale="off" />');

PageFrame2.SetGraphic('<graphic file="' + PDFresourceRef.name + '" pagenumber = "2" scale="off" />');

PageFrame3.SetGraphic('<graphic file="' + PDFresourceRef.name + '" pagenumber = "3" scale="off" />');

return pathToPDF;

}

 

into something like this:

 

//Insert upload PDF into each page

for (pageLoop = 1; pageLoop <= pagesInPDF; pageLoop++)

{

'PageFrame' + pageLoop + '.SetGraphic(<graphic file="' + PDFresourceRef.name + '" pagenumber = "' + 'pageLoop" scale="off" />)';

return pathToPDF;

}

 

but this does not work in that it appears to return the desired value, but the graphics preview as blank. Has anyone tried this? Am I just missing something in the syntax?

The problem is highlighted in Red above. If you have JavaScript variables such as PageFrame1, PageFrame2, etc., you have to call them out by name. You can't "build up" the name of a JavaScript variable as a string like that (although you can build up names of object properties, or specify array indices, which I'll get into in a bit).

 

Let's back up a bit. Where are the objects PageFrame1, PageFrame2, etc., being defined? Presumably you're calling the FindTextFrame function for each of those. Can you show that code as well?

 

Depending on how you're already setting up those objects, you can probably change those variables to be in an array instead. Presumably, you're doing something like this now:

var PageFrame1 = FindTextFrame("PageFrame1");
var PageFrame2 = FindTextFrame("PageFrame2");
var PageFrame3 = FindTextFrame("PageFrame3");

So, you can change that to use an array instead, like so:

var PageFrame = []; // new Array
PageFrame[1] = FindTextFrame("PageFrame1");
PageFrame[2] = FindTextFrame("PageFrame2");
PageFrame[3] = FindTextFrame("PageFrame3");

Obviously this can be done in a loop as well, like so:

var PageFrame = []; // new Array
for (var i = 1; i <= 16; i++)
 PageFrame[i] = FindTextFrame("PageFrame" + i);

Then, you can do this to assign to the frames:

//Insert upload PDF into each page
for (var pageLoop = 1; pageLoop <= pagesInPDF; pageLoop++)
{
    PageFrame[pageLoop].SetGraphic('<graphic  file="' + PDFresourceRef.name + '" pagenumber= "' + pageLoop + '"  scale="off" />');
}

Of course, if you're going to go to all that trouble to create a loop anyway, there's no point in assigning all those objects in a separate loop. You might as well do it all in one shot, like so:

//Insert upload PDF into each page
for (var pageLoop = 1; pageLoop <= pagesInPDF; pageLoop++)
{
    FindTextFrame("PageFrame" + i).SetGraphic('<graphic  file="' + PDFresourceRef.name + '" pagenumber= "' + pageLoop + '"  scale="off" />');
}

Now, having said all of that, there is an even easier way to do this, in FusionPro 8.2 and later. You don't even need to name the frames. Instead of setting up a loop in OnRecordStart to populate all the frames, you can simply create a regular Graphic rule and check the "Re-evaluate this rule for every graphic frame" box, with logic like so:

var r = Resource("YourResourceName")
r.pagenumber = FusionPro.Composition.currentPageNumber;
return r;

Then you can call out that rule in each of the frames, on each page.

Edited by Dan Korn
fixed last example
Link to comment
Share on other sites

  • 11 months later...

Need some help! I was able to get the sample file to work, but I'm having issues applying this with data and graphics (multipage pdf's) with names other then Doc1 or images named Doc.pdf.

 

I have data that has one field called "Graphic". And each record under that field has the names of the Multipage PDFs to be inserted, for example "apple.pdf", "grapes.pdf" ect...

 

These PDF graphics range from 1 to 4 pages.

 

Could someone help me tweak the sample rule to make this work?

Link to comment
Share on other sites

Need some help! I was able to get the sample file to work, but I'm having issues applying this with data and graphics (multipage pdf's) with names other then Doc1 or images named Doc.pdf.

 

I have data that has one field called "Graphic". And each record under that field has the names of the Multipage PDFs to be inserted, for example "apple.pdf", "grapes.pdf" ect...

 

These PDF graphics range from 1 to 4 pages.

 

Could someone help me tweak the sample rule to make this work?

Set the path to the graphics in the Search Path box on the Advanced tab of the Composition Settings dialog, and then your rule just needs to do this:

var result = [];
var r = CreateResource(Field("Graphic"), "graphic");
for (r.pagenumber = 1; r.pagenumber <= r.countPages; r.pagenumber++)
   result.push(r.content);

return result.join("<p>\n");

Link to comment
Share on other sites

  • 2 months later...

Dan, I'm revisiting this thread for some new insight. I used this solution about a year ago to tackle a project and it worked great. Now I'm trying something new.

 

I have a client who is doing their own VDP composition and sending me PDF files which are very great in number. Some have 300,000 pages in them!

 

We are working with them presently using a band-aid solution with our pre-press software, Preps. I use Acrobat Pro to break the 300,000 record file into 3600 record chucks, as we run this job 6-up, and want 600 sheets in a stack.

 

I'm toying around with automating this with FP (and ultimately letting FP Server do all the heavy lifting).

 

I don't care if I have to break the files into chunks still, that's super easy. But if I was able to feed the original file in, that would be even more awesome.

 

But the problem I'm running into, as others have mentioned, is the 6-up imposition doesn't work, because even though there are 3600 "records" in the pdf file, FP sees the file as "1 record". I've been re-reading this trying to understand if there's another approach... Is there a way for me help FP see that every two pages in the PDF constitutes a new "record" or "instance"? I'm not sure I'm asking for exactly the same thing as other users here, but I'm not sure I'm following all the responses.

Link to comment
Share on other sites

  • 1 year later...

Hey everyone!

 

This is an awesome thread and has really helped me with my project. Below is the tactic I ended up using:

 

-Create a 48pg document to receive in any pdf with up to 48pages

-Name each page as 'p1', 'p2, 'p3', etc...

-Make them all unused pages except for pg1

-Create a graphic frame on each page and name the frames 'p1', 'p2, 'p3', etc...

-The OnRecordStart will do the rest

 

Take a look at the zip attachment, all code and a working template are included inside it.

 

Here is the code for those who want a quick preview:

pagesInPDF = 0;

markupToReturn = '';

PDFresourceRef = new FusionProResource(Field("image"), "graphic", true);

 

//Find out how many pages it has

pagesInPDF = PDFresourceRef.countPages;

 

//Page usage loop to turn pages on based on pagesInPDF

for (i = 1; i <= pagesInPDF; i++){

FusionPro.Composition.SetBodyPageUsage('p' + i, true);

}

 

//Graphic frame loop to specify which pdf page goes into which graphic frame

for (pageLoop = 1; pageLoop <= pagesInPDF; pageLoop++){

var frame = FindGraphicFrame('p' + pageLoop);

frame.SetGraphic('<graphic file="' + PDFresourceRef.name + '" pagenumber = "' + pageLoop + '" scale="off" />');

}

 

return markupToReturn;

 

*****One catch with this template, you can't impose multiple records where the pdf page count varies. For example, record 1 has a 16p PDF and record 2 has a 32p PDF. The template will only use the record 1 (16p) info. I believe this due in part to the template using FPImposer.

 

Cheers,

Mark

FP_Forum.zip

Link to comment
Share on other sites

  • 6 years later...

I was looking for a way to get the original code to work in Marcom, but would come to a dead end after trying some of the suggested solutions. So I thought I would share the simple solution that finally worked in case someone else had the same issue.

 

I was able to get a version of the original code from this thread to work in Marcom by adding a height value to the graphic tag. Before adding a height, the template would find the PDF file and create the correct number of pages, but would not insert the file into the text frames. Also remember to set pathToAllPDFs = '';

 

//---Original---//
markupToReturn += '<graphic file="' + PDFresourceRef.name + '" pagenumber = "' + pageLoop + '" position="afterline"/>';

//---Updated---//
markupToReturn += '<graphic file="' + PDFresourceRef.name + '" pagenumber = "' + pageLoop + '" position="afterline" height=79200 />';

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...