PDA

View Full Version : How to place a 2 page PDF in 1 template page?


Fabian
November 16th, 2011, 10:28 PM
Hi, I need to display 2 pages of a credit card sized PDF file on an 8.5 x 11 sized template page for proofing purposes. Is there a rule that will bring in a PDF file and insert page 1 and page 2 into separate graphic frames on the same template sheet? I've attached a sample.

esmith
November 17th, 2011, 11:12 AM
Sure. You just need a separate rule for each graphic frame, each with it's own rule. For the first frame, your rule would look like:
var bg = CreateResource("fileName.pdf");
bg.countpages;
bg.pagenumber = 1;
return bg;
Rule 2 is a duplicate with pagenumber=2.

Fabian
November 17th, 2011, 03:26 PM
Thank you Eric!

jwhittaker
May 1st, 2012, 10:01 AM
I have a 2 page variable product on the storefront. There is a 2 page pdf uploaded and I want to put page1 of the uploaded pdf to a graphic frame on the products page 1 and put the page 2 of the uploaded pdf on the second page of the product. I can get page one to work but can't get page 2 to work. It just shows up blank. Page 1, I'm just returning the field so it automatically puts page 1 of the pdf in the graphic frame.

I have tried this rule
var bg = CreateResource(Field("pdf")

ThomasLewis
May 1st, 2012, 12:18 PM
The easiest way to do it is to create a rule like this for each page:

var pdffile = Resource(Field("pdf"));
pdffile.pagenumber = 1;
return pdffile;

Then assign the rule to the graphic frame.

jwhittaker
May 1st, 2012, 12:50 PM
Thomas
My post was cut off a little and didn't notice it. I did try that code and I also tried your code. It works on the desktop but when I load it to Marcom it doesn't show the back. Do you have any javascript globals or anything besides those graphic rules?

ThomasLewis
May 1st, 2012, 01:29 PM
I'm not using any globals or other rules. If this is for a Marcom upload field you will need to use the CreateResource function as Eric mentioned above. I don't think the code I posted would work unless the PDF is already associated. It does seem odd that it's displaying page 1 but not page 2. I would try a few different multiple page PDFs as well to rule out it's not a problem with the source file.

Another method you could try is putting the JavaScript in OnRecordStart instead. You will need to name the frames and remove the other graphic rules.

var r = CreateResource(Field("pdf"), "graphic");

r.pagenumber = 1;
FindGraphicFrame("frame1").SetGraphic(r);

r.pagenumber = 2;
FindGraphicFrame("frame2").SetGraphic(r);

jwhittaker
May 1st, 2012, 02:13 PM
Thomas
Thanks for the other option. I tried it and it's now putting page 1 of the uploaded pdf in both pages. I did a collect and have a pdf I'm using for testing in the zip file. If you can see anything let me know otherwise I'll have to wait for Dan the Man. I do really appreciate your time helping me.
Jon

ThomasLewis
May 1st, 2012, 03:19 PM
I modified the JavaScript in my post above. Tested it in Marcom and it is working for me.