Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > FusionPro® VDP Server (API)

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 21st, 2011, 03:08 PM
Doug Pershing's Avatar
Doug Pershing Doug Pershing is offline
Junior Community Member
 
Join Date: Aug 2008
Location: Phoenix, AZ
Posts: 35
Default Pad Batched Output Numbers with Zeros

When composing chunked output files FP appends a number to the end of the filename. Is there a way to pad that number with zeros?
Reply With Quote
  #2  
Old October 24th, 2011, 10:16 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,623
Default Re: Pad Batched Output Numbers with Zeros

Quote:
Originally Posted by Doug Pershing View Post
When composing chunked output files FP appends a number to the end of the filename. Is there a way to pad that number with zeros?
Yes, if you create the OnNewOutput file rule, you can name the output file whatever you want by setting FusionPro.Composition.outputFileName. You can base it on a record number such as FusionPro.Composition.processedRecordNumber, or you can keep your own global counter variable. You can use FormatNumber to pad with zeros.
__________________
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 May 27th, 2015, 01:13 PM
DSweet's Avatar
DSweet DSweet is offline
Senior Contributor
 
Join Date: Sep 2008
Location: Oberlin, Ohio
Posts: 253
Default Re: Pad Batched Output Numbers with Zeros

Dan, a while back you had given me this script to pad zeros in a batched output file where I could set the amount of padding...
Code:
if (Int(FusionPro.Composition.JobOptions["FinalPrint"]))  {
var oldEnding = FusionPro.Composition.currentOutputFileNumber +
    "." + FusionPro.Composition.outputFormatExtension
var originalNameNoExt = FusionPro.Composition.outputFileName.replace(oldEnding, "");
FusionPro.Composition.outputFileName = originalNameNoExt + 
    FormatNumber("000", FusionPro.Composition.currentOutputFileNumber) +
    "." + FusionPro.Composition.outputFormatExtension;
}
Up to now it has been working like a charm...as do most if not all of your suggestions...however I have now made the jump to FusionPro 9.3.15 (need to update my signature line) and it is not working as per normal.

I would expect output names such as..."JobName_001.pdf", "JobName_002.pdf", "JobName_003.pdf", and so on. I've set it to 3 digits in the script so I expect a three digit number with leading zeros. However I am now getting "JobName_1001.pdf", "JobName_1002.pdf", "JobName_1003.pdf". FOUR digits and the first is always a "1".

At first I thought it might be because the batched amount was going to be larger that the 3 digits will allow, but what I added a fourth zero to the script it just added another zero to the padded section and still put the 1 in front.

Also if I put the extension ".pdf" in the output name section command line I'm giving to FP Server I get output names like "JobName_.pdf1001.pdf", "JobName_.pdf1002.pdf", "JobName_.pdf1003.pdf".

What happened from FP8 to FP9? A new command for padding zeros in the output?

.
__________________
David A. Sweet
Variable Data Specialist
HKM Direct Market Communications
Windows 7, Acrobat 10.x
FusionPro Desktop and Server 10.0.26
Reply With Quote
  #4  
Old May 27th, 2015, 01:53 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: Pad Batched Output Numbers with Zeros

David, that sounds like the issue that was being discussed here where there was a 1 being appended to the file name in earlier versions of FP9. However, Dan also says that problem was fixed in the 9.3.12 release so if you're running 9.3.15, I wouldn't think it's the same problem but it sounds too familiar not to bring up.

That being said, I guess you could try to remove all numbers preceeding the extension and replacing it with the formatted output file number (rather than just replacing the output file number and extension):
Code:
FusionPro.Composition.outputFileName = FusionPro.Composition.outputFileName.replace(new RegExp('\\d*\\.' + FusionPro.Composition.outputFormatExtension + '$',''), function(){return FormatNumber("000", FusionPro.Composition.currentOutputFileNumber) + "." + FusionPro.Composition.outputFormatExtension;});
__________________
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 May 27th, 2015, 02:11 PM
DSweet's Avatar
DSweet DSweet is offline
Senior Contributor
 
Join Date: Sep 2008
Location: Oberlin, Ohio
Posts: 253
Default Re: Pad Batched Output Numbers with Zeros

Thanks Step. If I use your expression would that only remove the number exactly prior to the extension such as just the 1 in the name "JobNumber_1.pdf"?

Would that expression also effect the number 12345 as is "12345-JobName_1.pdf", or again would it only effect the "1.pdf"?

I sometimes have to put job numbers within the name of the output file prior to a "descriptive name" or "client name" in the output file.
__________________
David A. Sweet
Variable Data Specialist
HKM Direct Market Communications
Windows 7, Acrobat 10.x
FusionPro Desktop and Server 10.0.26
Reply With Quote
  #6  
Old May 27th, 2015, 02:19 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: Pad Batched Output Numbers with Zeros

The regular expression is starting at the end of the file and matching the extension, the period, and then as many numbers as it can find so in your example it would match (in red):
Quote:
12345-JobName_1.pdf
As long as you have the underscore separating the JobName, you should be safe.
__________________
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 05:38 AM.


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