Jump to content

Multiple Page PDF


Fellsway

Recommended Posts

Can someone help with this.... I have a 16 page document where I need to insert numerous Multipage PDFs. Most of PDFs are 16 pages but some are only 15 pages. If they are only 15 pages I need to insert an alternative single page PDF as the 16th page. I am using the rule below for each page but not sure how to have it add my alternate PDF if the Multipage PDF is only 15 pages.

 

var r = Rule("Insert Picture Rule");

r.pagenumber = 16; // or 1 here

return r;

 

Sorry if this explanation was clear as mud.

Link to comment
Share on other sites

I probably have everyone scratching their heads with my first post so how about this... If the PDF image I'm pulling in is 15 pages instead of 16, how can i have a alternate page 16 turn on in page usage?

 

 

pagesInPDF = 0;

markupToReturn = '';

PDFresourceRef = new FusionProResource(Field("PDF"), "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;

Link to comment
Share on other sites

Here's how I would do it:

 

pagesInPDF = 0;
markupToReturn = '';
PDFresourceRef = CreateResource(Field("PDF"), "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);	

if (pagesInPDF < 16)
FusionPro.Composition.SetBodyPageUsage('alternate', 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);
PDFresourceRef.pagenumber = pageLoop;
frame.SetGraphic(PDFresourceRef);
}

return markupToReturn;

 

I don't know what you are returning there though, seems blank, but I left it in for whatever reason.

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