|
#1
|
|||
|
|||
![]()
I've got a rule in a file that looks for a PDF on a server in a folder based on the file name. It's looking for the file based on a field in my data but I'm adding two zeros in the rule because the data field does not contain the zeros.
For example, the data field has "9" in it. The file it is looking for has "009" in it. My current rule is this: Code:
var issueNumber = 'GH00' + Field("MagIDShort"); var pathName = "X:\\EDITORIAL\\FinalGutsforProofs\\GHM\\"; var FullResourcePath = pathName + issueNumber + "\\" + 'GH_magazine-00' + Field("MagIDShort") + ".pdf"; //change to match your data file field var x = new FusionProResource(FullResourcePath, "graphic", 1); if (!x.exists) ReportError("Graphic not found: " + FullResourcePath); var pdfString = ''; var pages = (x.countPages); for (var pgnbr = 1; pgnbr <= pages; pgnbr++) { x.pagenumber = pgnbr; pdfString += x.value + '<p>\n'; } Print("Result is: " + pdfString); return pdfString; Is there some reg ex that would look for one or two zeros? I'm not good at reg ex so I'm looking for a solution that can be used for either file name, 009 or 010. Thanks in advance.
__________________
Bryan Mathes, Print Production Specialist FusionPro Designer 10.1.11, FusionPro Producer (Server) API 10.1.11 Mac OSX 10.12.6 Mac Pro 2.8 GHz Quad Core Intel Xeon |
#2
|
||||
|
||||
![]()
I think what you are looking for is the FormatNumber function
FormatNumber("000", inputNumber) |
#3
|
|||
|
|||
![]()
Thomas,
Would that go in place of the 00 in the code below? Code:
+ 'GH_magazine-00'
__________________
Bryan Mathes, Print Production Specialist FusionPro Designer 10.1.11, FusionPro Producer (Server) API 10.1.11 Mac OSX 10.12.6 Mac Pro 2.8 GHz Quad Core Intel Xeon |
#4
|
||||
|
||||
![]()
Like this if I'm reading your code right:
Code:
... "\\" + 'GH_magazine-' + FormatNumber("000", Field("MagIDShort")) + ".pdf"; |
#5
|
|||
|
|||
![]()
That's what I thought you meant. I will try that. Thanks!
__________________
Bryan Mathes, Print Production Specialist FusionPro Designer 10.1.11, FusionPro Producer (Server) API 10.1.11 Mac OSX 10.12.6 Mac Pro 2.8 GHz Quad Core Intel Xeon |
#6
|
||||
|
||||
![]()
If you want to test for multiple possibilities, you can do that in a loop, something like this:
Code:
var x; for (var zeros = 0; zeros <= 3; zeros++) { var issueNumPadded = new Array((zeros || 0) + 1).join("0") + issueNumber; var FullResourcePath = pathName + issueNumber + "\\" + 'GH_magazine-' + issueNumPadded + ".pdf"; x = new FusionProResource(FullResourcePath, "graphic", 1); if (x.exists) break; } if (!x || !x.exists) ReportError("Graphic not found for " + issueNumber);
__________________
Dan Korn FusionPro Developer / JavaScript Guru / Forum Moderator PTI Marketing Technologies | Printable | MarcomCentral 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)}); ![]() |
#7
|
|||
|
|||
![]()
Thanks Dan. I did get it to work with the code ThomasLewis put in here. That was a huge help.
__________________
Bryan Mathes, Print Production Specialist FusionPro Designer 10.1.11, FusionPro Producer (Server) API 10.1.11 Mac OSX 10.12.6 Mac Pro 2.8 GHz Quad Core Intel Xeon |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|