Fellsway Posted December 3, 2018 Share Posted December 3, 2018 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. Quote Link to comment Share on other sites More sharing options...
Fellsway Posted December 5, 2018 Author Share Posted December 5, 2018 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; Quote Link to comment Share on other sites More sharing options...
ThomasLewis Posted December 8, 2018 Share Posted December 8, 2018 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. Quote Link to comment Share on other sites More sharing options...
Fellsway Posted December 10, 2018 Author Share Posted December 10, 2018 That worked great Thomas! Thanks so much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.