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 February 11th, 2016, 04:53 AM
mclisa81 mclisa81 is offline
Regular Contributor
 
Join Date: Oct 2008
Location: Manchester CT
Posts: 97
Default Composing 2 records only

Hi,

I have 44 data files that I'm pulling in one at a time into my template and composing only the first and last record of each for proof pdfs. I am going in and modifying the rule each time, changing the last record since they are all different record counts. I'm sure there's a way to automate this to make it less painful. Any help is appreciated.

Code:
var ranges = [ 1, 225 ];
function CheckRanges(val)
{
  for (var i in ranges)
    if (val == ranges[i] || ((ranges[i] instanceof Array) && val >= ranges[i][0] && val <= ranges[i][1]))
      return true;
  return false;
}
FusionPro.Composition.composeThisRecord = CheckRanges(CurrentRecordNumber());
return FusionPro.Composition.composeThisRecord;
Thanks in advance,
Lisa
Reply With Quote
  #2  
Old February 11th, 2016, 07:53 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 870
Default Re: Composing 2 records only

Is that in an OnJobStart rule? I think you can assign a variable for a global data file object which uses your input data file. Then you count the total records and use that as your secondary element in var ranges:

Code:
myData = new ExternalDataFileEx(GetFileName(FusionPro.Composition.inputFileName), ",") //assuming CSV data
totalRecords = myData.recordCount;
var ranges = [ 1, totalRecords ];
// your function, etc.
Admittedly, I have not tried this yet, but I think the logic is valid.
__________________
Eric Smith
Content Developer
Classic
FP 9.3.6, MAC OSX 10.9.4, Acrobat 11.0.09
Reply With Quote
  #3  
Old February 11th, 2016, 08:01 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Composing 2 records only

Actually, as long as pre-processing is occurring, FusionPro already knows how many records there are. That information is accessible through "FusionPro.Composition.totalRecordCount".

If your job is imposing, then pre-processing is already occurring. Otherwise, you'll need to specifically tell the job to pre-process by putting this in an OnJobStart rule:
Code:
FusionPro.Composition.forcePreprocessing = true;
Then it's just a matter of making the following edit to your OnRecordStart code:
Code:
var ranges = [ 1, FusionPro.Composition.totalRecordCount ];
function CheckRanges(val)
{
  for (var i in ranges)
    if (val == ranges[i] || ((ranges[i] instanceof Array) && val >= ranges[i][0] && val <= ranges[i][1]))
      return true;
  return false;
}
FusionPro.Composition.composeThisRecord = CheckRanges(CurrentRecordNumber());
Or more succinctly:
Code:
FusionPro.Composition.composeThisRecord = [1,FusionPro.Composition.totalRecordCount].indexOf(CurrentRecordNumber()) > -1
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #4  
Old February 11th, 2016, 08:04 AM
mclisa81 mclisa81 is offline
Regular Contributor
 
Join Date: Oct 2008
Location: Manchester CT
Posts: 97
Default Re: Composing 2 records only

Eric,

Worked perfectly. Thank you so much!

Lisa
Reply With Quote
  #5  
Old February 16th, 2016, 08:29 AM
mclisa81 mclisa81 is offline
Regular Contributor
 
Join Date: Oct 2008
Location: Manchester CT
Posts: 97
Default Re: Composing 2 records only

Hi Ste,

I've already finished this job, however, I'm now trying your suggestions since they're a few less steps. Both of them are composing the first record (1) only. Any ideas?

On Job Start
Code:
FusionPro.Composition.forcePreprocessing = true;
On Record Start
Code:
var ranges = [ 1, FusionPro.Composition.totalRecordCount ];
function CheckRanges(val)
{
  for (var i in ranges)
    if (val == ranges[i] || ((ranges[i] instanceof Array) && val >= ranges[i][0] && val <= ranges[i][1]))
      return true;
  return false;
}
FusionPro.Composition.composeThisRecord = CheckRanges(CurrentRecordNumber());

Thanks
Lisa
Reply With Quote
  #6  
Old February 16th, 2016, 10:28 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,408
Default Re: Composing 2 records only

Quote:
Originally Posted by mclisa81 View Post
I've already finished this job, however, I'm now trying your suggestions since they're a few less steps. Both of them are composing the first record (1) only. Any ideas?
I would add some calls to the Print function and look at the log file to trace what's going on. Try adding this to the end of your OnRecordStart rule:
Code:
Print("FusionPro.Composition.totalRecordCount=" + FusionPro.Composition.totalRecordCount);
Print("CurrentRecordNumber()=" + CurrentRecordNumber());
Print("FusionPro.Composition.composeThisRecord=" + 
FusionPro.Composition.composeThisRecord);
__________________
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
  #7  
Old February 16th, 2016, 10:55 AM
mclisa81 mclisa81 is offline
Regular Contributor
 
Join Date: Oct 2008
Location: Manchester CT
Posts: 97
Default Re: Composing 2 records only

Hi Dan,

Thanks for getting back to me.

I added the calls you suggested and I can see that the "totalRecordCount" is showing 0 in the msg file. I'm attaching the msg file for you to take a look at if you wouldn't mind.



Thanks
Lisa
Attached Files
File Type: zip 94305_.zip (9.6 KB, 4 views)
Reply With Quote
  #8  
Old February 16th, 2016, 01:42 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Composing 2 records only

Sorry, Lisa, I should have given that a try before I posted it as a solution. I think what's happening is that OnRecordStart is being called during pre-processing to determine the total number of records that will be generated. Since the range is set to "1" and "totalRecords" (which is unknown at the time of pre-processing), pre-processing will determine that only one record will be created thus making the total records 1. You'd have to add the following to tell pre-processing that all records should be composed when you're pre-processing the job so that the totalRecordCount is accurate:
Code:
var ranges = [ 1, FusionPro.Composition.totalRecordCount ];
function CheckRanges(val)
{
  for (var i in ranges)
    if (val == ranges[i] || ((ranges[i] instanceof Array) && val >= ranges[i][0] && val <= ranges[i][1]))
      return true;
  return false;
}

FusionPro.Composition.composeThisRecord = FusionPro.Composition.inPreprocessing || CheckRanges(CurrentRecordNumber());
Alternatively, you could determine the total number of records yourself by incrementing a variable each time a record is pre-processed:
Code:
this.total = this.total || 0;
if (FusionPro.Composition.inPreprocessing)
   ++this.total;

var ranges = [ 1, this.total ];
function CheckRanges(val)
{
  for (var i in ranges)
    if (val == ranges[i] || ((ranges[i] instanceof Array) && val >= ranges[i][0] && val <= ranges[i][1]))
      return true;
  return false;
}

FusionPro.Composition.composeThisRecord = CheckRanges(CurrentRecordNumber());
__________________
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 February 16th, 2016, 01:56 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,408
Default Re: Composing 2 records only

Okay, I see what's happening. The thing is, when you do preprocessing, the preprocessing pass figures out which records to compose ahead of time, generally for figuring out imposition stacking. So records that are skipped (composeThisRecord = false) at preprocessing are not included in the totalRecordCount. Therefore, you need to tell FusionPro to skip records only during the main composition pass, not during preprocessing. The easiest way to do that for this case is like so:
Code:
FusionPro.Composition.composeThisRecord = FusionPro.Composition.inPreprocessing || [1,FusionPro.Composition.totalRecordCount].indexOf(CurrentRecordNumber()) > -1;
__________________
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
  #10  
Old February 17th, 2016, 05:06 AM
mclisa81 mclisa81 is offline
Regular Contributor
 
Join Date: Oct 2008
Location: Manchester CT
Posts: 97
Default Re: Composing 2 records only

Dan,

That worked perfectly. Thanks again for all your help.

Lisa
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 09:33 PM.


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