Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 1st, 2017, 09:46 AM
ricky10ss ricky10ss is offline
Junior Community Member
 
Join Date: Mar 2009
Posts: 35
Default Multiple PDF's with variable text boxes on different pages

I am trying to figure out the most simple way to import multiple pdf's that have the same variable text boxes in the same location but on different pages. Below are the document names and the page the variable text fields are on. Everyone gets the standard form but if they are in any of the states below they get that specific state form.

LNG-3001 (Standard form - Page 20)
LN-3001 CO (Colorado – Page 21)
LN-3001 LA (Louisiana – Page 24)
LN-3001 MO (Missouri – Page 20)
LN-3001 NC (North Carolina – Page 26)
LN-3001 NV (Nevada – Page 23)
LN-3001 SD (South Dakota – Page 22)

In the past I was able to use the code below to import specific pages till I got to the variable page 4 then import the rest of the pages since all documents had the variable on the same page.

Bringing in specific page:

var image = CreateResource(path + image,"graphic",true);
image.pagenumber = 1;
return image;

Then the last pages after page 4:

var result = [];
var r = CreateResource(path + image,"graphic",true);
for (r.pagenumber = 4; r.pagenumber <= r.countPages; r.pagenumber++)
result.push(r.content);

return result.join("<p>\n");
Reply With Quote
  #2  
Old March 1st, 2017, 08:08 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,671
Default Re: Multiple PDF's with variable text boxes on different pages

Sorry, it's not clear to me what you're trying to do. Perhaps seeing some of the PDFs in question, and the desired output, would be illuminating.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old March 2nd, 2017, 07:56 AM
ricky10ss ricky10ss is offline
Junior Community Member
 
Join Date: Mar 2009
Posts: 35
Default Re: Multiple PDF's with variable text boxes on different pages

Attached are two documents. LNG-3001.pdf is the standard form and has the variable boxes only all states except CO, LA, MO, NC, NV and SD. LN-3001 CO.pdf is the form only for CO. The variable text boxes are on page 21. Each state form has the variable boxes on different pages.
Attached Files
File Type: pdf LN-3001 CO.pdf (369.8 KB, 13 views)
File Type: pdf LNG-3001.pdf (510.2 KB, 7 views)
Reply With Quote
  #4  
Old March 2nd, 2017, 11:50 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: Multiple PDF's with variable text boxes on different pages

Ignoring the fact that the two forms in the PDFs you posted do not appear to have the variable frames in the same location, one option you have is to:
  1. Create an 8.5x11 template
  2. Put a graphic frame on it that will return your graphic rule
  3. Duplicate that page
  4. FusionPro > Manage Pages > Page Usage and name the first page "page" and the second page "form"
  5. Draw your variable frames on the "form" page
  6. Create an onRecordStart rule that toggles the appropriate body page based on the state
OnRecordStart
Code:
var [ver, state] = Field("version").split(' ');
var pdf = CreateResource('/path/to' + Field("version") + '.pdf', 'graphic', true);
var pages = pdf.countPages;
var form = 20;

switch(state) {
  case 'CO': form = 21; break;
  case 'LA': form = 24; break;
  case 'NC': form = 26; break;
  case 'NV': form = 23; break;
  case 'SD': form = 22; break;
}

FusionPro.Composition.repeatRecordCount = pages;
var isForm = FusionPro.Composition.repeatRecordNumber == form;
FusionPro.Composition.SetBodyPageUsage('page', !isForm);
FusionPro.Composition.SetBodyPageUsage('form', isForm);
If the variable frame locations move based on the state, you may have to create a body page for each form, set them all to unused, and name them "form," "form-CO," "form-NC," etc. Then you'd modify the OnRecordStart code:
Code:
FusionPro.Composition.SetBodyPageUsage(['form',state].filter(Boolean).join('-'), isForm);
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #5  
Old March 2nd, 2017, 01:09 PM
ricky10ss ricky10ss is offline
Junior Community Member
 
Join Date: Mar 2009
Posts: 35
Default Re: Multiple PDF's with variable text boxes on different pages

Thanks Ste. Yes I noticed that after as well that the text boxes are not in the same locations. So with this rule you are just pulling in the specific pages correct? What if I need to pull in the whole form all pages for the standard form and all pages for the state forms?

The only way I could think is make a page for all the common count pages till each variable pages then bring in the pages after. But the issue there is MO state form only has 22 total pages. Some of the state forms variable pages are past page 22.
Reply With Quote
  #6  
Old March 2nd, 2017, 02:58 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: Multiple PDF's with variable text boxes on different pages

Quote:
Originally Posted by ricky10ss View Post
So with this rule you are just pulling in the specific pages correct?
No. The rule that I posted is not pulling in any pages. It's counting the number of pages in the document and repeating the record by that number. For example, when the version is "LN-3001 CO," it counts the number of pages in "LN-3001 CO.pdf." Since there are 24 pages in that file, that record will be repeated 24 times. The rule will enable the "form-CO" body page the 21st time the record is repeated. Pulling in the pages would be done in the graphic rule and would look something like this:
Code:
var pdf = CreateResource('/path/to/' + Field("Version") + '.pdf');
pdf.pagenumber = FusionPro.Composition.repeatRecordNumber;
return pdf;
Quote:
Originally Posted by ricky10ss View Post
What if I need to pull in the whole form all pages for the standard form and all pages for the state forms?
So all pages in "LNG-3001.pdf" and all pages in "LN-3001 CO.pdf"? You'd do the same thing except you'd repeat the record by the number of pages in both files and you'd have to edit which pages the forms fall on for each state. For example: "LNG-3001.pdf" has 22 pages so you'd have to adjust the "form" page for "CO" by 22 pages:
Code:
case 'CO': form = 43; break; //21st page + 22 pages in LNG-3001.pdf
You'd also have to change your graphic rule a little bit:
Code:
var pdf = CreateResource('/path/to/LNG-3001.pdf');
var page = FusionPro.Composition.repeatRecordNumber;
var pages = pdf.countPages;
if (page > pages) {
  page -= pages;
  pdf = CreateResource('/path/to/' + Field("Version") + '.pdf');
}
pdf.pagenumber = page;
return pdf;
Quote:
Originally Posted by ricky10ss View Post
The only way I could think is make a page for all the common count pages till each variable pages then bring in the pages after. But the issue there is MO state form only has 22 total pages. Some of the state forms variable pages are past page 22.
I don't think I follow what you're suggesting here but I don't think it's something you should be concerned with if you use the method I've detailed here.
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #7  
Old March 2nd, 2017, 03:36 PM
ricky10ss ricky10ss is offline
Junior Community Member
 
Join Date: Mar 2009
Posts: 35
Default Re: Multiple PDF's with variable text boxes on different pages

Sorry I am not trying to combine "LNG-3001.pdf" and all pages in "LN-3001 CO.pdf". So it sounds like your first response is what I am trying to do. With the code you posted below I have another question. How would I call the forms only from a field called State? I don't have a field calling out the specific name of the form. All I have in data provided to me is the State. So if the state equals to CO then I need to pull the resource "LN-3001 CO.pdf" and so one for LA, NC, NV, SD. All other states get "LN-3001.pdf".

var [ver, state] = Field("version").split(' ');
var pdf = CreateResource('/path/to' + Field("version") + '.pdf', 'graphic', true);
var pages = pdf.countPages;
var form = 20;

switch(state) {
case 'CO': form = 21; break;
case 'LA': form = 24; break;
case 'NC': form = 26; break;
case 'NV': form = 23; break;
case 'SD': form = 22; break;
}

FusionPro.Composition.repeatRecordCount = pages;
var isForm = FusionPro.Composition.repeatRecordNumber == form;
FusionPro.Composition.SetBodyPageUsage('page', !isForm);
FusionPro.Composition.SetBodyPageUsage('form', isForm);
Reply With Quote
  #8  
Old March 2nd, 2017, 04:45 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: Multiple PDF's with variable text boxes on different pages

Quote:
Originally Posted by ricky10ss View Post
How would I call the forms only from a field called State? I don't have a field calling out the specific name of the form. All I have in data provided to me is the State.
There are several ways you can do that. One way is to write some if/if else/else statements like you mentioned.
Quote:
Originally Posted by ricky10ss View Post
So if the state equals to CO then I need to pull the resource "LN-3001 CO.pdf" and so one for LA, NC, NV, SD. All other states get "LN-3001.pdf".
Code:
if (Field("State") == "CO") {
  var pdf = "LN-3001 CO.pdf";
}
else if (Field("State") == "LA") {
  var pdf = "LN-3001 LA.pdf";
}
// ...
else {
  var pdf = "LN-3001.pdf";
}
But since we already have that switch statement for those states, we can just key off of that 'form' value instead:
Code:
var state = Field("State");
var pdf = '/path/to/LN-3001';
var form = 20;
switch(state) {
  case 'CO': form = 21; break;
  case 'LA': form = 24; break;
  case 'NC': form = 26; break;
  case 'NV': form = 23; break;
  case 'SD': form = 22; break;
}
if (form > 20)
  pdf += ' ' + state;
pdf = CreateResource(pdf + '.pdf', 'graphic', true);
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #9  
Old March 3rd, 2017, 09:01 AM
ricky10ss ricky10ss is offline
Junior Community Member
 
Join Date: Mar 2009
Posts: 35
Default Re: Multiple PDF's with variable text boxes on different pages

I created a OnRecordStart rule using the last bit of code you sent but nothing seems to be happening. I validate rule and Expression is OK. Do I need to do something with the graphic frame since no variable is assigned?

Could it be this is incorrect?
var pdf = 'G:\VP\Variable Elements\LifeShield\LN-3001.pdf';
Reply With Quote
  #10  
Old March 3rd, 2017, 09:41 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: Multiple PDF's with variable text boxes on different pages

Quote:
Originally Posted by ricky10ss View Post
Do I need to do something with the graphic frame since no variable is assigned?
No variable is assigned? I said you need to create a graphic rule to return the graphic:

Quote:
Originally Posted by step View Post
Pulling in the pages would be done in the graphic rule and would look something like this:
Code:
var pdf = CreateResource('/path/to/' + Field("Version") + '.pdf');
pdf.pagenumber = FusionPro.Composition.repeatRecordNumber;
return pdf;
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:29 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.