#1
|
|||
|
|||
![]()
Hey All,
I am still familiarizing myself with all of the capabilities of FusionPro as well as the FP global variables. I am trying to create a rule that will allow me to check the composition settings and check whether or not the "Output to Multiple Files" box is checked. If it is I want to know how many records are output to each file. Here is what I have so far. Code:
begin_data=Field("Presort Se"); records_per_file = 450; // Ideally this would be a rule that checked if it needed multiple files and set this number to the record count per file records_per_file=parseInt(begin_data) + records_per_file - 1; // Conversion to string end_data= records_per_file.toString(); // Creation of name new_name="Field("Filename") + "_" + begin_data + "_" + end_data + ".pdf"; // CHANGE JOB# NAME AND SECTION // Sets name of PDF FusionPro.Composition.outputFileName= new_name; return 0; ![]() |
#2
|
||||
|
||||
![]()
You can determine if the the multiple files box is checked like this:
Code:
var isChunked = FusionPro.Composition.JobOptions['OutputSource'] == 'bychunk'; return isChunked; // returns true when "Output to multiple files" is selected Code:
var recsInChunk = FusionPro.Composition.JobOptions['RecordsPerChunk']; if (recsInChunk) { // Do something if "Output to multiple files" is checked }
__________________
Ste Pennell FusionPro VDP Creator 9.3.15 Adobe Acrobat X 10.1.1 Mac OS X 10.12 |
#3
|
||||
|
||||
![]()
The FusionPro.Composition.JobOptions object has a property/value pair for each entry in the CFG (job options) file. So you can just look at what changes in the CFG file that gets generated when you compose with different settings to see what to key off of.
The "Output to multiple files" box and the associated edit boxes on the Output tab of the Composition Settings dialog correspond to the CFG entries "OutputSource", "RecordsPerChunk", and "FirstChunkRecords". In JavaScript, they're these properties:
The value of the "OutputSource" setting is "bychunk" when the "Output to multiple files" box is checked; otherwise it's "onefile". The other two values correspond to those two edit boxes; "FirstChunkRecords" is undefined (empty) unless the "Different number of records in first file" box is checked.
__________________
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)}); ![]() |
#4
|
||||
|
||||
![]()
Note also that multiple file output (i.e. "chunking") can also be accomplished by calling FusionPro.Composition.OpenNewOutputFile in OnRecordStart, even if the "Output to multiple files" box is not checked. This feature is called "arbitrary chunking." If you use that, then your rule can decide how many records are output to each file, instead of needing to query the CFG options to find out. If you want to start a new file for every 450 records, your OnRecordStart rule could do something like this:
Code:
if (CurrentRecordNumber() % 450 == 1) { var new_name = Field("Filename") + "_" + Field("Presort Se") + "_" + 450 + "." + FusionPro.Composition.outputFormatExtension; FusionPro.Composition.OpenNewOutputFile(new_name); }
__________________
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)}); ![]() |
#5
|
|||
|
|||
![]()
Thank you so much, I tested this out and it accomplished exactly what I needed. I had seen those fields but they weren't filled because I was looking at them with "preview template."
|
#6
|
|||
|
|||
![]() Quote:
I was going to try something like this, but I am trying to prepare templates for people who won't be able to code and I want them to be able to use the CFG and not realize what is going on in the background. Thanks for the help! |
#7
|
|||
|
|||
![]()
Correction, I thought that this was working, but it was not naming the files correctly. For some reason it isn't pulling the "RecordsPerChunk" information. I can get everything else to work, but it acts like that variable isn't there (Even though it will compile when I am using it.)
|
#8
|
||||
|
||||
![]()
What exactly was it that you thought was working? Can we see the current rule?
What is the correct result you're expecting? What is it that you're actually getting? And precisely how are they different? Quote:
Code:
Print("RecordsPerChunk=" + FusionPro.Composition.JobOptions.RecordsPerChunk); Code:
Print("OutputSource=" + FusionPro.Composition.JobOptions.OutputSource);
__________________
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)}); ![]() |
#9
|
|||
|
|||
![]()
This is what I had been doing. I wanted to make sure that the PDF name was not dependent on the job title so I had two different "name" statements that I separated based on the existence of "RecordsPerChunk".
Code:
var jobtitle = "Job_#_"; var chunkSize = FusionPro.Composition.JobOptions["RecordsPerChunk"]; if(FusionPro.Composition.inputRecordNumber % chunkSize == 1) { var beginfile = FusionPro.Composition.inputRecordNumber; var outputName1 = jobtitle + Field("Filename") + "_" + beginfile + "_" + (beginfile + (chunkSize-1)); FusionPro.Composition.OpenNewOutputFile(outputName1 + "." + FusionPro.Composition.outputFormatExtension); if(boolflag == 0) { boolflag = 1; } } if(boolflag == 0) { var InputType = ""; if (FusionPro.inputFileName.indexOf("_ALL") > -1) InputType = "ALL"; if (FusionPro.inputFileName.indexOf("_LS") > -1) InputType = "LS"; var outputName2 = jobtitle + Field("Filename") + "_" + InputType; FusionPro.Composition.OpenNewOutputFile(outputName2 + "." + FusionPro.Composition.outputFormatExtension); boolflag = 1; } Job_#_FILENAME_firstRecord_lastRecord.pdf and if it wasn't I wanted the file name to be Job_#_FILENAME_InputFile.pdf What was happening last night is when I went to compose with the multiple file selection checked and a set chunk size, it was outputting the first PDF with the second filename option, and the rest with the default JobTitle-Output#.pdf However, when I composed this morning, it worked like it was supposed to. I never figured out why it wasn't working last night, but I thought my code looked right. It is working now though, thank you for your help! |
#10
|
||||
|
||||
![]()
I think you're going to want to convert the "chunkSize" variable to an integer using the "Int" function.
What is the purpose of the "boolflag" variable? Are you including that as some sort of exit status for the function? If so, that's not necessary. If you're using it to determine whether the job is being chunked or not, as I said in my other post, you can determine that based on the "chunkSize" variable. The correct way to access the input file's name is FusionPro.Composition.inputFileName. FusionPro.inputFileName will not return anything and your "outputName2" will end in a trailing underscore (_) as a result. Using the "building blocks" will allow you to access the properties of the FusionPro object as well as give a description. From the Building Blocks, click Objects > FusionPro (Global) > Composition > Input and Output > inputFileName. Double-clicking on the "inputFileName" will insert it into your rule editor. I would consider changing your code to something like this for: Code:
var output = 'Job_#_' + Field('Filename'); var input = FusionPro.Composition.inputFileName; var chunkSize = Int(FusionPro.Composition.JobOptions["RecordsPerChunk"]); var beginfile = FusionPro.Composition.inputRecordNumber; var range = beginfile + (chunkSize-1); output += chunkSize ? '_' + beginfile + '_' + range : (input.match(/_ALL|_LS/) || [''])[0]; if (beginfile % chunkSize == 1 || beginfile == 1) FusionPro.Composition.OpenNewOutputFile(output + '.' + FusionPro.Composition.outputFormatExtension); To handle that scenario, you'd have to force FusionPro to preprocess the job by putting this in an "OnJobStart" callback: Code:
FusionPro.Composition.forcePreprocessing = FusionPro.Composition.JobOptions["RecordsPerChunk"]; Code:
var output = 'Job_#_' + Field('Filename'); var input = FusionPro.Composition.inputFileName; var totalRecords = FusionPro.Composition.totalRecordCount; var chunkSize = Int(FusionPro.Composition.JobOptions["RecordsPerChunk"]); var beginfile = FusionPro.Composition.inputRecordNumber; var range = beginfile + (chunkSize-1); if (range >= totalRecords) range = totalRecords; output += chunkSize ? '_' + beginfile + '_' + range : (input.match(/_ALL|_LS/) || [''])[0]; if (beginfile % chunkSize == 1 || beginfile == 1) FusionPro.Composition.OpenNewOutputFile(output + '.' + FusionPro.Composition.outputFormatExtension);
__________________
Ste Pennell FusionPro VDP Creator 9.3.15 Adobe Acrobat X 10.1.1 Mac OS X 10.12 |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|