Jump to content

Multiple page PDF


INGuser

Recommended Posts

Posted

Hi, I am trying to create one template to use for my mailing. The first 18 pages of my document are the same for every person in my mail list. The remaining pages are variable in length based on a file name in my CSV file. i have 143 different PDF's that could be listed in these three fields so I do not want to create a template with a page for each. I have tried using the follwoing code but can not get my graphis to show up in my output file.

 

//This rule will examine the input data to find a list of PDF files

//that are to be inserted in the template.

//Each PDF is of varying and unknown page count. Therefore, this script

//will determine that page count and reference each page in each PDF.

//The resulting tagged markup will include the variable <graphic> tag to reference

//the PDF pages and include as inline images in the template.

//This text rule in inserted into a large text frame on a Body page. That frame

//is set to Overflow to a frame on an overflow page.

 

//First, declare the variables and initiate them with values.

FieldName = '';

PDFfileName = '';

pagesInPDF = 0;

markupToReturn = '';

pathToAllPDFs = 'C:\Documents and Settings\taypdc\Desktop\West Mailing\PDF';

pathToPDF = '';

PDFresourceRef = '';

 

//There are 3 fields in this sample - Doc1, Doc2, and Doc3. We will loop through

//each field name with a simple for loop. The following variable sets the counter

//for that loop.

//For example, if you have 25 fields instead of 3 with the PDF file names in them,

//such as "Doc1" through "Doc25" you would set the following to 25.

FieldsToInspect = 3;

 

//This is the main loop that parses through all of the fields for a given record.

for (fieldCounter = 1; fieldCounter <= FieldsToInspect; fieldCounter++)

{

FieldName = 'PDF File Name_' + fieldCounter;

PDFfileName = Field(FieldName);

pathToPDF = pathToAllPDFs + PDFfileName;

//Create a new resource that references this

PDFresourceRef = CreateResource(pathToPDF ,'graphic' ,'no');

//Find out how many pages it has

pagesInPDF = PDFresourceRef.countPages;

 

//return PDFresourceRef.name;

//This is the secondary loop for this script.

//It will loop through and create markup for each page in the PDF.

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

{

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

markupToReturn += '<P>';

}

 

 

}

//remove the last <P>

markupToReturn = Left(markupToReturn, markupToReturn.length - 3);

 

return markupToReturn;

 

 

I have researched this code ont h forum and tried to do all the things that have been suggested to other users having issues. I am new to using Java Script so i am sure that the issue is me rather than the code. Can someone please help?

Test Mailing.zip

Posted

INGuser,

 

A long time ago, I had the same problems as you're having. I think I've found the fixes to your problem:

 

  1. You need to name the fields in your data "Doc1", "Doc2", "Doc3", etc. That's what the script is looking for.
  2. In the text box on your variable page (p. 19), you need to insert the rule, "«PDF Graphic Insertion Rule»" and set the size of the text box to slightly larger than page size: W: 8.7" H: 11.2"
  3. Finally, open up the Composition Settings command and select the last tab "Advanced". Under Search Path, you need to tell FP where your PDFs are located. I just copy/paste the pathway. Hit save.

I was able to get it to run using these fixes, so hopefully you can too. I'm attaching back your fixed files sans the PDF inserts.

 

Good luck!

Jeff

Fixed.zip

Posted

I've ran into two other issues with this mailing that I can not seem to get to work.

 

1.) Is there a way to add a 2D barcode to a job where each record has multiple pages? Based on the code that I have added below for 2D barcodes my first thought is no.

 

/* This script will create a Datamatrix barcode for a given page in the the output

file. The data to be encoded is as follows:

Position

1 Demand Feed - If this is the last page in the document, the value = "G" else the value = "0"

2 "0"

3-4 # of sheets of paper in the document

5-10 document in file e.g. this is the 15th statement in the file, 16th statement, etc.

11-12 sheet in document e.g. this is the 1st sheet, 2nd sheet, etc in an x sheet document

13-15 "000"

*/

2D Barcode for 5.8 Fusion Pro

barcodeData = "";

barcodeData = "0";

barcodeData += "0";

barcodeData += "02";

recNum = CurrentRecordNumber();

barcodeData += FormatNumber("000000", recNum);

barcodeData += "01";

barcodeData += "000";

var DMbarcode = new DataMatrixBarcode;

DMbarcode.pointSize = 3;

DMbarcode.preferredFormat = 7;

return DMbarcode.Make(barcodeData);

 

2. Is there a way to set the document up so if one of the PDF's being pulled in is an odd number of pages a blank page is added to that PDF?

 

Sorry to have so many questions but I went from doing simple setup in this tool to more complex setup and I do not understand all the fetures of fusion Pro. Thanks for your time.

Posted
Can't help with #1, but for #2 you can select the text frame that will contain the placed PDF, and in the Text Frame palette click on Overflow and change the setting for Add Pages to "So Last Added Page Is Even."
Posted

Sorry, but I probably can't help on those two either, but I do have 2 suggestions. Delete "2D Barcode for 5.8 Fusion Pro" from the active script, it's just a header I think. Second, make sure "Treat Return Strings as Text" is checked. Doing this produced a 2D barcode for me, but I'm not sure it's filled with the info you want in it.

 

I assume you're trying to have a 2D show up on all your inserted variable pages? That would be interesting to know how to create that. Would it be easier to just have a formatted (000001) sequence number in your data?

 

 

At least I learned a good tip from DCurry, thanks! :)

Posted

Lol. Not too good, Don. That's why I'm surfing this Forum and doing other's work! I was buried this time last year with you leaving and now, nothing.

 

Got something in the works though, so hopefully I won't be suffering too much longer.

 

Hope the grass is greener where you're at! :)

Posted

Going good here so far. Hope things work out for you.

 

E-mail me if you need help with something, I have some time today.

  • 2 months later...
Posted

Hi, I have a mailing for 12074 names that I am trying to do. I have four different PDF’s that have unique call tags within one column of my mail file. One file is three pages and the other three are ten pages. I have set my template up to be four pages with page four being my overflow page. Page one is my address page and page three should be the first page of my pulled PDF. I have renamed my tag column to Doc1 so that I can use the rule below. However, I cannot seem to get the rule to work as my composed output file is three pages per record. Records one and two should be six output pages per record and records three thru eight should be 12 output pages per record. The address is on page one but the rule is not pulling in my PDF’s per the input file on body page three. I normally use FusionPro to setup simple VDP jobs so this is a little beyond my normal comfort zone. I was able to get this to work for a previous mailing but cannot seem to get it to work for this mailing. Can someone please advise if this is the best way to setup this mailing?

//This rule will examine the input data to find a list of PDF files

//that are to be inserted in the template.

//Each PDF is of varying and unknown page count. Therefore, this script

//will determine that page count and reference each page in each PDF.

//The resulting tagged markup will include the variable <graphic> tag to reference

//the PDF pages and include as inline images in the template.

//This text rule in inserted into a large text frame on a Body page. That frame

//is set to Overflow to a frame on an overflow page.

 

//First, declare the variables and initiate them with values.

FieldName = '';

PDFfileName = '';

pagesInPDF = 0;

markupToReturn = '';

pathToAllPDFs = '';

pathToPDF = '';

PDFresourceRef = '';

 

//There are 3 fields in this sample - Doc1, Doc2, and Doc3. We will loop through

//each field name with a simple for loop. The following variable sets the counter

//for that loop.

//For example, if you have 25 fields instead of 3 with the PDF file names in them,

//such as "Doc1" through "Doc25" you would set the following to 25.

FieldsToInspect =;

 

//This is the main loop that parses through all of the fields for a given record.

for (fieldCounter = 1; fieldCounter <= FieldsToInspect; fieldCounter++)

{

FieldName = Doc' + fieldCounter;

PDFfileName = Field(FieldName);

pathToPDF = pathToAllPDFs + PDFfileName;

//Create a new resource that references this

PDFresourceRef = CreateResource(pathToPDF ,'graphic' ,'no');

//Find out how many pages it has

pagesInPDF = PDFresourceRef.countPages;

 

//return PDFresourceRef.name;

//This is the secondary loop for this script.

//It will loop through and create markup for each page in the PDF.

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

{

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

markupToReturn += '<P>';

}

 

 

}

//remove the last <P>

markupToReturn = Left(markupToReturn, markupToReturn.length - 3);

 

return markupToReturn;

 

 

I have attached sample files. I greatly appreciate all suggestions on the best way to produce this mailing or getting this rule to work.

Test Files.zip

Posted

First, change line 44 of your rule to this:

PDFresourceRef = CreateResource(pathToPDF ,'graphic');

This will throw an error when the resource is not found. The error I get for record one is, "Error: In CreateResource(), resource 'RLAA' does not exist." So the problem is that your data contains the name of the file, without the .pdf extension. You also need to tell the rule what folder to look in.

 

Based on this information, you can change line 41 of your rule to this:

pathToPDF = "PDF/" + PDFfileName + ".pdf";

Then you should see the resource PDF pages inserted into the output.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...