Jump to content

step

Registered Users - Approved
  • Posts

    962
  • Joined

Everything posted by step

  1. Sure you can do that from one data file. It's hard to give you examples specific to you without any knowledge of what your data looks like and what the contents of the field you're triggering off of are. At the very least, it would be helpful to know what version of FP you're running. Generally speaking, if you have a field named "Market" that you're triggering off of and the contents of that field are the market that the specific record corresponds with, you could write an OnRecordStart callback rule that creates a new output file whenever that field changes (assuming you're running FP8 or later): if (FieldChanged("Market")) FusionPro.Composition.OpenNewOutputFile("Output-" + Field("Market") + "." + FusionPro.Composition.outputFormatExtension); Here are a couple of related threads that may help you: Output Multiple Records Based on Data Name Output Based on Data Field Dynamic Chunking Based on Rule
  2. The impression I get from your data is that columns 1 and 2 (CODE & DESCRIPTION1) are separated by an underscore and columns 2 and 3 (DESCRIPTION1 & DESCRIPTION2) are separated by a pipe character. The way I would do what you're attempting is: 1. Replace the underscore with a pipe character. 2. Split the string using the pipe character as a delimiter. This will give you an array of your three column values. 3. Use the trim function to remove any extra spaces before/after the actual text. 4. Assign the values of that resulting array to the contents of the table. Here's an example: . . . var header = XDF.GetFieldValue(0, row); var [code,desc1,desc2] = header.replace('_','|').split('|').map(function(s){return Trim(s);}); thisRow.SetContents(code, desc1, desc2, itemCount);
  3. Thanks for sharing this solution, Dan! Admittedly, it took me a few minutes to wrap my head around what was actually going on there but that's very clever. And since I'm itching to try out some of the logic you presented there, I'll offer up yet another way to skin the cat (this time taking into consideration the default null value when both fields are empty): var a = Field("A"); var b = Field("B"); var sentence = []; sentence[1] = "Sentence 1"; sentence[2] = "Sentence 2"; sentence[3] = "Sentence 3"; return sentence[(+!!a*2 + +!!b)] || '';
  4. It sounds like you just need to use an 'else if' statement within your 'if' statement. I've assigned variables for you to edit with your sentences and field names. The first 'if' statement checks to see if 'a' and 'b' both have data, if it does, it sets the result to sentence3. If it doesn't it moves on to the 'else if' statement where it checks to see if 'b' has data and sets the result to sentence1. If 'b' doesn't have data, it finally checks to see if field 'a' has data and sets the result to sentence2. If they're all null, it returns sentence2 as a fallback. You could account for this by adding another 'else if'. var a = "a"; // Your Field var b = "b"; // Your Field var sentence1 = "Sentence 1"; // Your sentence1 var sentence2 = "Sentence 2"; // Your sentence2 var sentence3 = "Sentence 3"; // Your sentence3 var result = ""; if (a && b){ result = sentence3; } else if(b){ result = sentence1; } else { result = sentence2; } return result; Or more succinctly: var a = "a"; // Your Field var b = "b"; // Your Field var sentence1 = "Sentence 1"; // Your sentence1 var sentence2 = "Sentence 2"; // Your sentence2 var sentence3 = "Sentence 3"; // Your sentence3 var result = (a && b) ? sentence3 : (b) ? sentence1 : sentence2; return result;
  5. That's because technically the first time through the repeat, you'll have two pages (cover and static) and every other repeat is just the static page. You'll just need to repeat the record by the quantity + 1 (for the cover) and set the page usage so that the each repeat is only producing 1 page: var qty = StringToNumber(Field("COUNTS ")); FusionPro.Composition.repeatRecordCount = qty + 1; // Plus 1 for cover FusionPro.Composition.SetBodyPageUsage(1, (FusionPro.Composition.repeatRecordNumber == 1)); FusionPro.Composition.SetBodyPageUsage(2, (FusionPro.Composition.repeatRecordNumber != 1));
  6. I was able to do what you're describing by: 1. Creating a Photoshop file with the background set to white. 2. Converting the "Background" layer to a standard layer and setting the opacity to 95%. (You should see the checkered background showing through the layer). 3. Save the file as a Photoshop PDF with "layers" checked 4. Output a PDF with "Preserve Photoshop Editing Capabilities" checked. 5. Creating a graphic rule in FP to return the PDF I created: return CreateResource('/path/to/white.pdf', 'graphic'); 6. Create a graphic frame and assign the rule created in step 5 to it. 7. Set the scaling of the graphic frame to "fill." I should mention that I'm running FP8 rather than FP9 but I don't see why that wouldn't work for you.
  7. You can do this by repeating each record by the quantity in an OnRecordStart rule. So if the quantity in the data is 492, FP will repeat the record 492 times. This is set with "FusionPro.Composition.repeatRecordCount". In addition to that, you want to set the 1st page in your template (your cover page) to only display on the initial run of the repetition. FusionPro keeps track of where it is in the 'repeat' process and allows you to access that information through "FusionPro.Composition.repeatRecordNumber." So you'll only want to display the cover page when the 'repeatRecordNumber' is equal to 1. Like this: var qty = StringToNumber(Field("COUNTS ")); FusionPro.Composition.repeatRecordCount = qty; FusionPro.Composition.SetBodyPageUsage(1, (FusionPro.Composition.repeatRecordNumber == 1));
  8. It looks like the closing '>' on line 34 got converted to a '.' in your rule. If you check to make sure the if statement in the function looks like this (edit in red): //If Text is longer than the frame, adjust leading if (tm.textWidth > width){ result = result.replace(new RegExp('(' + tags + '.)',""), '$1</leading><leading newsize=' + altLead + '[color="Red"]>[/color]'); } you should see more than just the first character of the title. In order to ensure that the leading is adjusted for forced-line breaks ("<br>") you could alter the function to adjust the leading when the text is wider than the width of the text frame OR if the field contains a break tag (in red): function formatText(input, width, config){ //Assign to variables and set defaults var config = (config) ? config : new Object(); var fontFace = config.font || "Times New Roman Italic"; var pt = config.fontSize || 7; var lead = (config.defaultLeading*10) || (pt*12); var altLead = (config.altLeading*10) || (lead*0.75); //Tag the text for TextMeasure var tags = '<span font="' + fontFace + '" pointsize=' + pt + '><leading newsize="'+lead+'">'; var result = tags + input + '</leading></span>'; //Initate TextMeasure & GetWidth var tm = new FusionProTextMeasure; tm.useTags = true; tm.CalculateTextExtent(result); [color="red"]var useAltLeading = ((tm.textWidth > width) || (input.search(/<br>/g) > -1));[/color] //If Text is longer than the frame, adjust leading if ([color="red"]useAltLeading[/color]){ result = result.replace(new RegExp('(' + tags + '.)',""), '$1</leading><leading newsize=' + altLead + '>'); } return result; }
  9. Well, I don't think that not hard-coding the width should case an issue since the code I posted doesn't use a hard-coded width. The error that "result" is not defined, leads me to believe something weird happened when you copied that "formatText" function into your template (since that's where the 'result' variable is used). Could you post your rule? Or even more helpful, collect your template and upload it to this forum so I could have a better idea of what you're working with?
  10. You're missing a closing parenthesis in red: if (RuleChanged("Acronym Rule")[color="Red"])[/color] Though, unless you've defined "RuleChanged" as a function in your template, you're going to get another warning saying that "RuleChanged" isn't defined. The FP function is "FieldChanged." Without knowing what your "Acronym Rule" is doing, I can't really offer any insight other than that.
  11. I think these are the properties that would help you: FusionPro.Composition.totalPages will tell you how many pages are in a specific record. FusionPro.Composition.currentPageNumber will give you the current page of a specific record. In order to determine if you're at the end of an order you'd just do something like this: if (FusionPro.Composition.currentPageNumber == FusionPro.Composition.totalPages){ [i]//Barcode logic[/i] }
  12. If I understand what you're asking, you're trying to have a list of items that have 9pt leading applied to them but if one of those items has to wrap to another line, you want to tighten up the leading on it so that it's not confused for a separate item? If that's the case, I think you can do this by measuring the item, field, variable (or whatever it may be) using text measure to see if it is wider than the frame. If it's not, return it with 9pt leading, if it is, in order to keep the items equally spaced, you want to keep the leading of the first character of that item as 9pt and change everything else to 7pt in order to tighten up the rest of it. I think it would look something like this: /*======================================== // // Edit these variables // //=======================================*/ var field = Field("NAME"); // Your variable var frameWidth = GetSettableTextWidth(FindTextFrame("YOUR FRAME NAME")); // 100th's of a point 1in = 7200 // Object of settings to be passed to the formatText function var settings = { font: "Helvetica", fontSize: 9, // in points defaultLeading: 12, // in points altLeading: 6 // in points } return formatText(field, frameWidth, settings); /*======================================== // // Function adds alternate leading after // the second character in the string if // it determines it will wrap // //=======================================*/ function formatText(input, width, config){ // Assign to variables & set defaults var config = (config) ? config : new Object(); var fontFace = config.font || "Helvetica"; var pt = config.fontSize || 12; var lead = (config.defaultLeading*10) || (pt*12); var altLead = (config.altLeading*10) || (lead*0.75); // Tagged the text for TextMeasure var tags = '<span font="' + fontFace + '" pointsize=' + pt + '><leading newsize="'+lead+'">'; var result = tags + input + '</leading></span>'; // Initiate TextMeasure & Get Width var tm = new FusionProTextMeasure; tm.useTags = true; tm.CalculateTextExtent(result); // If Text is longer than the frame, adjust leading if (tm.textWidth > width){ result = result.replace(new RegExp('(' + tags + '.)',""), '$1</leading><leading newsize=' + altLead + '>'); } return result; } Just remember that if you're going to hard-code the width of the text frame, it needs to be in 100th's of a point in order to be accurate. I hope this helps!
  13. Sure you can create an array of your data file and sort it. The larger your data file, though, the more likely you'll be to run out of resources when it comes to composition. Data should really be properly sorted before it gets to FP. That being said, I see questions about this pretty frequently so I decided to take a stab at this: First things first, we need to set a global variable to flag when the "Order Number" value of a record has changed so that we know to start a new output file. Add this to your JavaScript Globals: flag = ''; Then we need to bring in the data as an array and sort it. You should probably do this in the OnJobStart callback so that you're not sorting it every time you change records: Note: You'll have to hardcode the path to the "input" variable to see the results in preview //================== // (Global) Variables //================== sorted_data = []; inputFields = FusionPro.Fields; sortField = "Order Number" // Name of field to sort by //================== // External Data //================== var input = FusionPro.Composition.inputFileName; var ex = new ExternalDataFileEx(input, ','); var records = ex.recordCount; //================== // Populate Array & // Sort Array //================== for (var i = 1; i<=records; i++) { var obj = {}; for (var l in inputFields){ obj[l] = ex.GetFieldValue(i, l); } sorted_data.push(obj); } // Sort the array based on the sort field specified in variable section sorted_data = sorted_data.sort(function(a,b){return (a[sortField] < b[sortField]) ? -1 : (a[sortField] > b[sortField]) ? 1 : 0;}); Then we can use that array to map the FP fields to the contents of the array. This way any rules that exist that pull in "Field("Order Number")" (or any other field) will be mapped to the fields in the sorted array. This is done OnRecordStart: var recFlag = sorted_data[FusionPro.Composition.inputRecordNumber-1][sortField]; for (var i in inputFields){ FusionPro.Composition.AddVariable(i, sorted_data[FusionPro.Composition.inputRecordNumber-1][i]); } Then we can use the global flag we created and compare it to the value of the "recFlag" in OnRecordStart to determine if it's time to open a new output file: if (flag != recFlag){ flag = recFlag; FusionPro.Composition.OpenNewOutputFile(recFlag + "." + FusionPro.Composition.outputFormatExtension); } Hopefully that helps.
  14. When you say it's not working, how is it not working? What is the result of your three blocks of code above? I would think that something like your first or second attempt would work fine: var Pic = NullResource(); if (Field("Front Image") == "pcon_take_control_brochure_037.jpg"){ Pic = CreateResource(Field("Logo"), "graphic", true); } return Pic; Some dumb questions: 1. Are you creating this as a graphic rule or a text rule? It should be a graphic rule, otherwise you need to return the image with graphic tags. 2. Does the string in the conditional ("pcon_take_control_brochure_037.jpg") match exactly what's in the "Front Image" field? If the field doesn't contain the extension or includes a full path, you need to alter the conditional in order to get it to validate 'true'. 3. Did you actually add the graphics as resources? If you did you don't need the "CreateResource" function. You can just call the resource by name (assuming your resources are named exactly the same as the contents of the "Logo" field): Resource(Field("Logo")); Anyway that's about all that comes to mind at the moment since I don't have a whole lot of information to go off of.
  15. Are you trying to compose the job locally or using FP Direct on a server? Your screen shot leads me to believe you are trying to compose on a server called "rob2-w2d2." Is that address to the computer you're running FP Scheduler on? In any event, if you uncheck "Use FusionPro Direct on Scheduler..." in the composition dialog window, you should be able to compose the job locally without issue.
  16. I think the numbers being off is due to your global variable being incremented during the pre-processing stage. Pre-processing occurs be default when you're imposing the template. I think adding this line to the beginning of your OnRecordStart rule will give you what you want by resetting your global variable when the pre-processing is done (at the first record of the job): incr = (FusionPro.Composition.inputRecordNumber == 1) ? 0 : incr;
  17. Do you get the results you're looking for if you change the composition dialog to compose "all" records and change your OnJobStart callback to: FusionPro.Composition.composeAllRecords = false; FusionPro.Composition.startRecordNumber = 1; FusionPro.Composition.endRecordNumber = 357; start = 63746; incr = 0;
  18. Shouldn't you capitalize the "G" in "Addgraphic?" checktemplate.AddGraphic("CheckPageBackground:", "c:\\outlook\\JPB\\M-105232 META CA CHECK 1446199_85x11 1.pdf");
  19. Sorry, I probably should have specified that by "collect" I meant to select "Collect.." from the "FusionPro" menu. Without doing that, your rules didn't come over. Regardless, I've attached an example in which I've got my code working as I would expect it to. Another way to accomplish what I think you're trying to accomplish would be to insert the "TableNo" variable into your text frame and apply Copyfitting to it (click on the text frame and select "Overflow" from the text pallet). From there you'd select "adjust text to fit" and "allow text to expand to fill." Doing this will create an "OnCopyfit" call back rule that would look something like this: if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72))) ReportWarning("Could not copyfit text in flow " + FusionPro.Composition.CurrentFlow.name); The "25" is the lowest magnification factor it will apply to your text to get it to fit. The "400" is the max. So it will magnify your text a maximum of 400% the original pointsize in order to get the text to fill the frame. The last two numbers are the min and max (respectively) pointsize the function is allowed. So, by default, Copyfit will only increase the size of the text to 72pt. You can change that parameter to "250" and then there's no need for any rule. 122348 Speakers Ball Table Tent Numbers.zip
  20. Can you collect your template and post it to the forum with the data? It's really difficult to figure out the problem without seeing all of the factors that come into play.
  21. It sounds like your text frame is returning your rule as well as the variable. You should set the contents of your text frame to only return the contents of the rule and the change your rule to: if (StringToNumber(Field("TableNo")) < 10){ return "<span pointSize=230>" + TaggedDataField("TableNo") + "</span>"; } else { return TaggedDataField("TableNo"); }
  22. I agree that this would be easier to accomplish through a custom rule, but I think the rule as it stands is comparing a string to a string which seems like it would throw off the comparison between the two numbers. I think you probably want to re-write the if statement condition (first line) to be: if (StringToNumber(Field("TableNo")) < 10)
  23. As far as built in functionality for determining when an OverFlow page is used, I don't think there is any. I tried utilizing FusionPro.Composition.totalPages & FusionPro.Composition.GetBodyPageUsage but those didn't seem to work. That being said, it seems like you could determine if an OverFlow page is needed by using text measure on the frame that's set to overflow to another page and turn on the third page conditionally from OnRecordStart like so: function useOverFlow(frameName){ var text = FindTextFrame(frameName).content; var tm = new FusionProTextMeasure; tm.useTags = true; tm.maxWidth = GetSettableTextWidth(FindTextFrame(frameName)); tm.CalculateTextExtent(text); return tm.textHeight > GetSettableTextHeight(FindTextFrame(frameName)); } FusionPro.Composition.SetBodyPageUsage("Page3",useOverFlow("Frame Name")); I guess the caveat here is that the "content" of the text frame literally returns your variable rule names rather than the contents that the rules generate. Meaning, if your text frame contains rule (for example: "My Table") that you've created to insert a table (for instance) the markup looks like: <variable name="My Table"> so in order to get an accurate measurement of the height, we'd have add this line to the function: function useOverFlow(frameName){ var text = FindTextFrame(frameName).content; [color="Red"]text = text.replace(/<variable name="([^"]*)">/g,function(a,b){return RuleOrField(b);});[/color] var tm = new FusionProTextMeasure; tm.useTags = true; tm.maxWidth = GetSettableTextWidth(FindTextFrame(frameName)); tm.CalculateTextExtent(text); return tm.textHeight > GetSettableTextHeight(FindTextFrame(frameName)); }
  24. Referencing this comment, you could do something like this to align the table to the center: var X = myTable.MakeTags().replace(/^\<table/, "<table alignment=center"); On a side note, leading is measured in 10th's of a point so if you're wanting the paragraph tag to have a leading of 1 point, it should be altered to be: X += "<p leading=10> ";
  25. What's the rule that's generating the graphic in the graphic frame? If you click on the graphic frame in your template, the second field in the "Graphic Frame" pallet should indicate which rule is populating the frame. From there, you can edit that rule to point to your new resource. Alternately, you could just go into your resources, click the existing resource, and click "relink" to relink it to your new graphic.
×
×
  • Create New...