Jump to content

step

Registered Users - Approved
  • Posts

    962
  • Joined

Everything posted by step

  1. Basically what you want to do is link to your primary data file as an external data file when you're creating the address page. This will give you visibility to all of the records in your data file. From there, you find all of the records that match the current records "Order" field value using the 'findRecords' method. The method returns an array of record numbers that have matching order numbers – i.e., record numbers for items in the current "order." It's not really clear to me what you're trying to do with that information from there, but you can use the record number to access any of the other field values and format it however you'd like. In the example below, an array of record numbers which have the same value in the "Order" field as the current record is created and the values are mapped to the value of the item's "Detail" field: var data = new ExternalDataFileEx(PrimaryInputFile(), FusionPro.inputFileDelimiter); var order = data.FindRecords("Order", Field("Order")) .map(function(item) { return data.GetFieldValue(item, "Detail"); }).join('<br>'); return order;
  2. There is something wrong with your syntax. It's that "FusionPro.Composition.outputFileName is not a function." Try writing it like this: FusionPro.Composition.outputFileName = Field("LastName") + '_' + Field("FirstName"); You'll probably also want to include an extension for the file name: FusionPro.Composition.outputFileName = Field("LastName") + '_' + Field("FirstName") [color="Red"]+ '.' + FusionPro.Composition.outputFormatExtension[/color];
  3. If all five pages in your template are set to be "used," you should be able to wrap the previous logic in an 'if' statement that's only executed when the template isn't being previewed. That way, none of the pages are disabled and all of the pages in the template are returned when a user is previewing/proofing: [color="Red"]if (!IsPreview()) {[/color] FusionPro.Composition.repeatRecordCount = 4; for (var i = 2; i <= 5; i++) FusionPro.Composition.SetBodyPageUsage(i, i == (FusionPro.Composition.repeatRecordNumber + 1)); [color="red"]}[/color]
  4. It would be easier to tell where the issue is if you'd attach an example of your job. At first glance, it sounds like you're doing something a little different than what Jimmy was doing. It sounds like you want 250 copies of each record and you want the first 50 copies of that record to have "Back A," the second 50 copies to have "Back B," etc. Do I understand that correctly? If so, try this: FusionPro.Composition.repeatRecordCount = 250; for (var pg = 2; pg <= 6; pg++) FusionPro.Composition.SetBodyPageUsage(pg, pg == (Math.ceil(FusionPro.Composition.repeatRecordNumber / 50) + 1)); You probably need to tweak your imposition definition a little to get the results you want as well but like I said before, it would be easier to help if you'd post your files.
  5. It sounds like you just need to repeat each record 4 times – one time for each unique back. Then you'd use FusionPro.Composition.SetBodyPageUsage to toggle the appropriate back for each iteration of the repetition. So, assuming that page one of your template is the front and pages 2, 3, 4, and 5 are your backs: OnRecordStart FusionPro.Composition.repeatRecordCount = 4; for (var i = 2; i <= 5; i++) FusionPro.Composition.SetBodyPageUsage(i, i == (FusionPro.Composition.repeatRecordNumber + 1));
  6. Are you trying to use the heart as a character or as an inline graphic? If you're using a character, one way to do it would be to print the decimal code for the heart character in "Zapf Dingbats": return 'YesVirginia.org Virginia <span font="Zapf Dingbats">[font="Courier New"]&[/font]#9829;</span> Pocket Folder'; Or you could create a text resource that returns the heart in a font that supports that character. By the way, you could also simplify your code a little by using an array: var heart = '<span font="Zapf Dingbats">[font="Courier New"]&[/font]#9829;</span>'; var result = ['CLASSIFICATION','PRESENTED TO','TITLE','CUSTOMER','DESIGNER','AGENCY'] .map(function(s){ if (Field(s + ' 2')) return '<f name="TradeGothic Light"><z newsize="6">' + ToUpper(Field(s + ' 1')) + '</f><br>' + '<leading newsize="105"><f name="Weiss"><z newsize="9">' + Field(s + ' 2') + '</f></leading>'; }).filter(Boolean); result.push('YesVirginia.org Virginia ' + heart + ' Pocket Folder'); return result.join('<br>');
  7. var price = "$20" // Your field here return '$' + StringToNumber(price.replace(/[^\d\.]/g, '')) * 2;
  8. Not sure what you mean by that. Are you getting an error that gives you that impression? Could you share it? Are you entering it exactly like that? If so, you need to capitalize the "field" function so that it pulls in your field value correctly. The only other thing I could think that you might want to try is ensuring that all of your variables are of the same type. In my example, all of the numbers in the array were integers being compared to integers. This might help: // List of pages that should be enabled in your template var enabledPages = [[color="red"]Field[/color]("record number"), 101][color="Red"].map(Int);[/color] var page = 0; while (++page && !FusionPro.inValidation) { try { FusionPro.Composition.SetBodyPageUsage(page, enabledPages.indexOf(page) > -1); } catch(e) { break; } }
  9. One way to do that is to add this to your OnRecordStart callback rule: // List of pages that should be enabled in your template var enabledPages = [ 4, 10, 11, ]; var totalPages = 1000; // Total number of pages in your template for (var page = 1; page <= totalPages; page++) { FusionPro.Composition.SetBodyPageUsage(page, enabledPages.indexOf(page) > -1); } You can also get away with not defining the total number of pages in your document by using this code instead: // List of pages that should be enabled in your template var enabledPages = [ 4, 10, 11, ]; var page = 0; while (++page && !FusionPro.inValidation) { try { FusionPro.Composition.SetBodyPageUsage(page, enabledPages.indexOf(page) > -1); } catch(e) { break; } }
  10. Evenly distributing the number of bullets in each column is doable and you only need one rule to do it: return [ Field("Bullet 1"), Field("Bullet 2"), Field("Bullet 3"), Field("Bullet 4"), Field("Bullet 5") ].filter(String).map(function(s,p,a) { var res = ''; if (p == Math.ceil(a.length/2)) res += '<p verticalstart="topofcolumn">'; res += Resource('Bullet-Red').content.replace('/>', 'height="300" />') + s; return res; }).join('<br>'); That being said, as evident in the example you originally posted, there are more factors that come into play when trying to evenly distribute the columns. Just because you have two bullets on the left and two bullets on the right you aren't guaranteed that the left and right columns will be even (which I'm assuming is your goal). Take a look at this thread and see if it helps http://forums.pti.com/showthread.php?t=4423
  11. Yes, you should have the same graphic variable assigned to the graphic frame on every page. You should only have 1 "page" body page. In addition to that, you should have the following body pages (all set to "unused"): form form-CO form-LA form-NC form-NV form-SD Each of those "form*" body pages should have the variable frames required by that version's form in the positions required by that version's form. Your OnRecordStart should have this (and only this) in it: var state = Field("State"); var file = '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) file += ' ' + state; pdf = CreateResource('G:\\BTS\\Variable Elements\\LifeShield STM UltraCare\\' + file + '.pdf', 'graphic', true); var pages = pdf.countPages; FusionPro.Composition.repeatRecordCount = pages; var isForm = FusionPro.Composition.repeatRecordNumber == form; FusionPro.Composition.SetBodyPageUsage('page', !isForm); FusionPro.Composition.SetBodyPageUsage(['form', file.split(' ')[1]].filter(Boolean).join('-'), isForm); You can name the graphic rule whatever you want to but in an effort to minimize the room for error, name it "background" and paste this into it: pdf.pagenumber = FusionPro.Composition.repeatRecordNumber; return pdf; Apply the "background" rule to every graphic frame in the template – there should be seven in total.
  12. No variable is assigned? I said you need to create a graphic rule to return the graphic:
  13. There are several ways you can do that. One way is to write some if/if else/else statements like you mentioned. 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: 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);
  14. Yeah, of course. You can define "width" and "height" properties (both defined in 100ths of a point). If you define one without the other, the missing attribute will be scaled proportionally: if (Field("Bullet 1")) return Resource('Bullet-Red').content[color="Red"].replace('/>', 'height="300" />')[/color] + Field("Bullet 1"); The above sets the height of the graphic to 3 points.
  15. 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: var pdf = CreateResource('/path/to/' + Field("Version") + '.pdf'); pdf.pagenumber = FusionPro.Composition.repeatRecordNumber; return pdf; 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: 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: 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; 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.
  16. Your code looks good so I'm assuming the location of the bullet file isn't in FP's search path. You could define the path or add the path to FusionPro's search path (under the "Advanced" tab of the composition settings). But perhaps the easiest solution would be to add the file as a resource named "bullet" and change your code to: if (Field("Bullet 1")) return Resource('bullet').content + Field("Bullet 1");
  17. 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: Create an 8.5x11 template Put a graphic frame on it that will return your graphic rule Duplicate that page FusionPro > Manage Pages > Page Usage and name the first page "page" and the second page "form" Draw your variable frames on the "form" page Create an onRecordStart rule that toggles the appropriate body page based on the state OnRecordStart 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: FusionPro.Composition.SetBodyPageUsage(['form',state].filter(Boolean).join('-'), isForm);
  18. What error are you getting? From the looks of the file you attached, it appears you just copied the rule I posted without swapping out the static string with your field name. For the record, what front end are you using? MarcomCentral? If so, you might considering asking this question in the MarcomCentral forum. I am not able to get your template to work with the data you supplied but I'm assuming that's because I don't have a MarcomCentral license so it isn't honoring the field list specified in your XML file. Okay, that's a little confusing. You say that there is "essentially one text field" but then you reference multiple fields when you say "these will all be user input fields." What do you mean by "essentially one text field"? Is it one field or multiple? Assuming you mean they now want the first sentence in uppercase, that's a simple enough change: var paragraph = 'This is the first line. This is the second line'; // Or Field("YOUR PARAGRAPH FIELD"); return paragraph.replace(/^([^\.\?!]+.)\s*/, function(s,p) { return ToUpper(p) + '<br>'; });
  19. As you know, to create two separate files containing the same records, you have to run your data twice because FP does not have the capability to write multiple files at once. One way you can do this by duplicating your entire data file and adding a field that indicates the stock to each record. Meaning: if your data file contains 6 records, your modified data file would contain 12 records where the 7th record is just the first record again but with a different value in the "stock" field. But, as that's still a manual step, I think the second option is better. Without altering the data file, we can tell FusionPro to import the data as an external data file which gives us visibility of all of the records at once. Then with a little trickery, we can determine the number of records in the data file, double it, and tell FP to repeat the first record by that amount and don't compose any of the other records. So in the example above, we would tell FP to repeat the first record 12 times. Then based on the iteration in the repeat, we reference the external data file to reassign the field values to give the illusion of producing more than one record. We can enable pages 1 and 2 when the iteration in the repetition is less than or equal to half (1-6) and enable pages 3 and 4 when it is greater than half (6-12). Having said all that, I think you can get the results you're looking for if you throw this in your OnRecordStart rule: // Only compose the first record FusionPro.Composition.composeThisRecord = FusionPro.Composition.inputRecordNumber == 1; // Link to your data file as an external data file var data = new ExternalDataFileEx(PrimaryInputFile(), FusionPro.inputFileDelimiter); // Count the records var recs = data.recordCount; // Double the number of records we're composing FusionPro.Composition.repeatRecordCount = recs * 2; // Consider the number of times record 1 has been repeated the record number. var rec = FusionPro.Composition.repeatRecordNumber; // Redefine the "Field" function so that calling it from other rules will // still return the correct field value for the current "record" Field = function(str) { return data.GetFieldValue(rec % recs || recs, str); } // Define how many pages are in each output file. var pages = 4; // Enable pages 1 and 2 when 'rec' is < the total number of records // Enable pages 3 and 4 when 'rec' is >= the total number of records while(pages--) FusionPro.Composition.SetBodyPageUsage(pages + 1, Math.floor(pages / 2) ^ rec <= recs); // Map the field values to the value of the new 'Field' function // so that text frames that call a field will have the correct value. for (var i in FusionPro.Fields) FusionPro.Composition.AddVariable(i, Field(i)); // Open a new output file for each stock. if (rec % recs == 1) { // Only get the output file name once (you can hard code this if you prefer) this.out = this.out || FusionPro.Composition.outputFileName; // Get the appropriate extension. var ext = '.' + FusionPro.Composition.outputFormatExtension; // Set the stock var stock = rec <= recs ? 'letterhead' : 'plain'; // Open a new output file called "[OUTPUT FILE NAME]-letterhead.pdf" FusionPro.Composition.OpenNewOutputFile(this.out.replace(ext, '-' + stock + ext)); }
  20. You can adjust the ratio and offset of the superscript by setting the appropriate attributes of the paragraph tag: return '6€<superscript>90</superscript>' + [color="Red"]'<p br=false superoffset=80 superratio=50><superscript>*</superscript>';[/color] Check out page 44 of the TagsRefGuide.pdf in the documentation for more information.
  21. The reason you have 44 pages in the output file is because you have 22 records producing 2 pages each. You could change your composition settings to only compose records 1-1. Or, if you're going to have more than 1 record in a composition, you would need to keep track of the field that identifies each "record" and only compose the unique ones. For example, if you want to compose records with unique "reservation numbers," you could do something like this: JavaScript Globals ids = []; OnRecordStart var unique = ids.indexOf(Field("Reservation Number")) == -1; ids.push(Field("Reservation Number")); FusionPro.Composition.composeThisRecord = unique;
  22. JavaScript Globals names = {}; OnRecordStart var fieldKey = 'Signator'; // Key to sort on // Only compose unique fieldKeys FusionPro.Composition.composeThisRecord = names[Field(fieldKey)] == undefined; // Link to Primary data file as external data file (comma delimited) var data = new ExternalDataFileEx(PrimaryInputFile(), ','); // Get an array of fields whose fieldKey value match that of the current record var cursor = data.SortBy(fieldKey).FindRecords(Field(fieldKey)); // Repeat this record based on the number of matches FusionPro.Composition.repeatRecordCount = cursor.length; // Open a new output file at the start of the record's composition if (FusionPro.Composition.repeatRecordNumber == 1) FusionPro.Composition.OpenNewOutputFile('Test_Output_' + Field(fieldKey) + ".pdf"); // Flag this fieldKey as done if (FusionPro.Composition.repeatRecordNumber == cursor.length) names[Field(fieldKey)] = false; // Remap the fields for each iteration of the repeat for (var field in FusionPro.Fields) FusionPro.Composition.AddVariable(field, data.GetFieldValue(cursor[FusionPro.Composition.repeatRecordNumber-1], field)); Howbowdah?
  23. Well, that's not exactly how it works – you aren't really repeating only the first page. In FusionPro "repeating" is done at the record level – not the page level. If you composed your template as is with only one record, you would get a 21 page record that FusionPro believes should collate so you'd probably find that it didn't impose as you'd expect as well. What you want to do is repeat each record 20 times and use "SetBodyPageUsage" to programmatically toggle which back is enabled. That way you'll end up with 20 records that are two pages each (front and back). Just add this to an OnRecordStart callback rule: FusionPro.Composition.repeatRecordCount = 20; for (var page = 2; page <= 21; page++) FusionPro.Composition.SetBodyPageUsage(page, page == FusionPro.Composition.repeatRecordNumber + 1); That tells FusionPro to repeat each record 20 times. During each repetition, it cycles from 2 to 21 enabling the page that corresponds to the current iteration and disabling the others. In other words, on the first iteration of the repetition (repeatRecordNumber = 1) it enables the first back (page 2; or repeatRecordNumber + 1) and disables pages 3 - 21 because they are not equal to the repeatRecordNumber. On the second iteration (repeatRecordNumber = 2) it enables the second back and disables the others and so forth. Also, from looking at your template, it looks like there's really only 6 unique backs to each card. In the future, if you wanted to save yourself the trouble of duplicating those pages to pad your document to 21 pages, you could just have a 7 page template and use a remainder operator to cycle through those 6 backs until 20 cards have been created: FusionPro.Composition.repeatRecordCount = 20; for (var page = 2; page <= 7; page++) FusionPro.Composition.SetBodyPageUsage(page, page == ((FusionPro.Composition.repeatRecordNumber + 1) % 7 || 7));
  24. Does it matter if they're in order or not? If not, you could do something like this: JavaScript Globals versions = {}; OnRecordStart var isProof = true; // false to compose job normally var version = Field("version"); // Field that indicates version if (isProof) { if (!versions[version]) versions[version] = 0; FusionPro.Composition.composeThisRecord = ++versions[version] <= 10; } The code creates a global 'versions' object and at the start of each record, it counts how many times each version has been composed. If a specific version has been composed more than 10 times, FP won't compose the record. If you need grouped by version, you'd probably have to link to your data as an external data file and sort the versions up front.
×
×
  • Create New...