Jump to content

step

Registered Users - Approved
  • Posts

    962
  • Joined

Everything posted by step

  1. I suppose only one record is boggling the modulus operation in the if statement for the output file. I just moved everything into a small output control function and modified that if statement with this: //=================================================== // Output Control //=================================================== function newOutput(recordNumber) { if (FusionPro.Composition.repeatRecordNumber == 1){ return ([1,(recs+1)].indexOf(recordNumber) > -1); } return false; } if (newOutput(curr)){ FusionPro.Composition.OpenNewOutputFile(template.outputName + "." + FusionPro.Composition.outputFormatExtension) } And that should handle files with only 1 record.
  2. Well, judging from your code (snippet below), it looks like you're trying to build the PDF name. switch (Field("Plan").toLowerCase()) /////Plan 1///// { case "1": { switch (Field("State").toLowerCase()) { case "KY".toLowerCase(): { var image = Resource("AF ST CERT KY 714 - The National Congress of Employers (NCE) Plan 1 - Accepted - 4-7-15.pdf"); image.pagenumber = 1 return image; } case "ND".toLowerCase(): { var image = Resource("AF ST CERT ND 714 - The National Congress of Employers (NCE) Plan 1 - Accepted - 4-2-15.pdf"); image.pagenumber = 1 return image; } default: var image = Resource("AF ST CERT 714 - The National Congress of Employers (NCE) Plan 1 - 3-27-15.pdf"); image.pagenumber = 1 return image; } } } switch (Field("Plan").toLowerCase()) /////Plan 2///// { case "2": { switch (Field("State").toLowerCase()) { case "KY".toLowerCase(): { var image = Resource("AF ST CERT KY 714 - The National Congress of Employers (NCE) Plan 2 - Accepted - 4-7-15.pdf"); image.pagenumber = 1 return image; } case "ND".toLowerCase(): { var image = Resource("AF ST CERT ND 714 - The National Congress of Employers (NCE) Plan 2 - Accepted - 4-2-15.pdf"); image.pagenumber = 1 return image; } default: var image = Resource("AF ST CERT 714 - The National Congress of Employers (NCE) Plan 2 - 3-27-15.pdf"); image.pagenumber = 1 return image; } } } . . . switch (Field("Plan").toLowerCase()) /////Plan 16///// { case "16": { switch (Field("State").toLowerCase()) { case "KY".toLowerCase(): { var image = Resource("AF ST CERT KY 714 - The National Congress of Employers (NCE) Plan 16 - Accepted - 4-7-15.pdf"); image.pagenumber = 1 return image; } case "ND".toLowerCase(): { var image = Resource("AF ST CERT ND 714 - The National Congress of Employers (NCE) Plan 16 - Accepted - 4-2-15.pdf"); image.pagenumber = 1 return image; } default: var image = Resource("AF ST CERT 714 - The National Congress of Employers (NCE) Plan 16 - 3-27-15.pdf"); image.pagenumber = 1 return image; } } } You don't need a separate 'switch' statement for each case. That defeats the whole purpose of a switch statement. Also, typing a string in all caps and then passing it through a function to make it lowercased is pretty silly. You could just type the string in lowercase from the beginning: case "ky": // case "KY".toLowerCase(): But if you want the states listed in all caps, I would just force your "State" field to be all caps and set your switch up like this: switch (ToUpper(Field("State")) { case "KY": . . . Along the same lines, there's no point in making your "Plan" field lowercased if you're trying to match numbers. I've never seen a lowercased number, but I imagine they look an awful lot like uppercased numbers. Anyway, you get the idea, that function can go. Anyway, from looking at your rule, it appears that you're trying to build a PDF name with 'switch' rules. To me, it looks like there are 3 basic ways this PDF could be named: "AF ST CERT 714 - The National Congress of Employers (NCE) Plan [PLAN NUMBER] - 3-27-15.pdf" "AF ST CERT KY 714 - The National Congress of Employers (NCE) Plan [PLAN NUMBER] - Accepted - 4-7-15.pdf" "AF ST CERT ND 714 - The National Congress of Employers (NCE) Plan [PLAN NUMBER] - Accepted - 4-2-15.pdf" If that's the case, you can use a switch statement like this: var image = "AF ST CERT 714 - The National Congress of Employers (NCE) Plan " + Field("Plan") + " - 3-27-15.pdf" var state = ToUpper(Field("State")); switch(state){ case "KY": image = "AF ST CERT " + state + " 714 - The National Congress of Employers (NCE) Plan " + Field("Plan") + " - Accepted - 4-7-15.pdf"; break; case "ND": image = "AF ST CERT " + state + " 714 - The National Congress of Employers (NCE) Plan " + Field("Plan") + " - Accepted - 4-2-15.pdf"; break; } image.pagenumber = 1; return image; If you wanted to avoid the switch statement all together and just use a find/replace you could do something like this: var state = ToUpper(Field("State")); var plan = Field("Plan"); var date = (state == "KY") ? "4-7-15" : "4-2-15"; var image = "AF ST CERT 714 - The National Congress of Employers (NCE) Plan " + plan + " - 3-27-15.pdf" image = (~["KY","ND"].indexOf(state)) ? image.replace(/^(.*CERT)(.*)\d+-\d+-\d+(.*)$/,'$1 ' + state + '$2Accepted - ' + date + '$3') : image; image.pagenumber = 1; return image;
  3. Yeah, sorry about that. I thought you wanted the 3rd page to print only when the overflow page was being used. Whoops. The function (useOverFlow) is being passed the name of a frame and from that it pulls in (quite literally) the contents of that frame. If you've ever created a "formatted text" resource with rules or fields and then view the source it will look something like this: <p style="(no style)" br="false" override="true" quad="L" findent="0" lindent="0" rindent="0" leadbefore="0" leadafter="0" widows="2" kerning="true" hyphenate="true" skipifempty="false" skipifemptyvar="false" noparabreakoncopyfit="false"><tracking newsize="0"><f name="Helvetica"><z newsize="12.0"><color name="Black">This is my rule: <variable name="My Rule"> And that's essentially the format that the text frames are in as well. The nice thing about using the contents like that, is that you are able to pass tagged text to the TextMeasure object in the "useOverFlow" function rather than specifying every font, leading, etc. The down side is that TextMeasure is interpreting the "variable" tags literally rather than showing the actual content of the variable. So if you had a rule that was returning tagged text, the measurement would be off. So the replace string is searching the contents of the frame for those tags and then replacing them with their actual content using the "FieldOrRule()" function. As far as the RegExp goes, it's looking (globally) for '<variable name"' followed by anything that's not a quote until it gets to a ">' and it's capturing everything inside the quotes: [color="red"][^[/color]"[color="red"]][/color] Matches: a character that isn't a " [^"][color="Red"]*[/color] Matches: as many characters that aren't quotes in a row as it can [color="red"]([/color][^"]*[color="red"])[/color] Captures: as many characters that aren't quotes in a row as it can Then the replace function is basically taking the found match and piping it into this function with params 'a' and 'b': function(a,b){ return RuleOrField(b); } Where 'a' is the whole match ('<variable="name">') and 'b' is the captured element ( denoted by the parentheses in the RegExp – name). Hopefully my explanation didn't make that more confusing
  4. You need to reference the name of the array ("pages") when you want to call out a value by its position which I'm assuming you're trying to do in "SetBodyPageUsage." So, that line should be changed to this: {FusionPro.Composition.SetBodyPageUsage(pages[i], false)} I'm not sure if it's intentional or not, but you're only turning off 4 pages (Cert 2 - 5) since you're setting 'i' equal to 1 rather than 0. If you want to turn off all pages in the array you need to modify the code to this: var pages = ["Cert 1","Cert 2","Cert 3","Cert 4","Cert 5"]; if(Field("Choose A Certificate")=="NSU Certificates.jpg"){ for (var i=0; i<pages.length; i++){ FusionPro.Composition.SetBodyPageUsage(pages[i], false); } } You could also do it without the array at all: if(Field("Choose A Certificate")=="NSU Certificates.jpg"){ for (var i=1; i<=5; i++){ FusionPro.Composition.SetBodyPageUsage("Cert " + i, false); } }
  5. You'd have to collect your template (FusionPro > Collect...) in order for me to see what's going on in your template. Just supplying the PDF only shows me the PDF and FP frames – no rules. That being said, I noticed a mistake in the code I posted yesterday. The code was set to open a new output file new when the record number is equal to 1 or 10 (the first records in the files: 1-9, 10-18) but since record 10 is set to repeat 3 times, It created the "_Covers" PDF 3 times – overwriting it's content each time before moving on to the next record. One way around that is to add an additional condition to the 'if' statement that checks to make sure the records are on their first repeat: if (!((curr%recs)-1) [color="Red"]&& FusionPro.Composition.repeatRecordNumber == 1[/color]){ FusionPro.Composition.OpenNewOutputFile(template.outputName + "." + FusionPro.Composition.outputFormatExtension) }
  6. That sounds doable but it's not pretty. What you essentially want to do is run through your data file 1 time to create the "tickets" PDF and then run through it again to create the "covers" PDF. The cleanest approach to this would be to have two separate templates that you run your data file against. With FP Server you could even run them concurrently. That being said, there is another way – I'll get to that in a minute. Your code is basically repeating each record by the number in the "Books" field, that part I understood from your original post (though, it didn't sound like you wanted to repeat the records for the "ticket" page) but your if statement confuses me. Anyway, the only way I can think to accomplish this is by unlinking your data file from your template and then reading from it in OnJobStart as an external data file. Doing so will allow you to specify to FP how many records you want to have (since you want to run it two times, you want to double the amount of records). data = new ExternalDataFileEx('/path/to/file/Input.txt', '\t'); recs = data.recordCount; FusionPro.Composition.composeAllRecords = false; FusionPro.Composition.endRecordNumber = (recs*2); Make sure both of your body pages ('p1' and 'ticket') are set to Unused. Those will be turned on in the OnRecordStart Callback rule: if (FusionPro.inValidation) { Rule("OnJobStart") } var curr = FusionPro.Composition.inputRecordNumber //=================================================== // Function to return external data field // values as they relate to this job //=================================================== function ExField(s){ return data.GetFieldValue((curr%recs || recs), s); } //=================================================== // For loop populates variable values in use // elsewhere in the template // *Note: Field() syntax will not work. Use ExField()* //=================================================== for (var i=0; i<data.fieldCount; i++){ var fieldName = data.GetFieldValue(0, i); FusionPro.Composition.AddVariable(fieldName, ExField(fieldName)); } //=================================================== // Settings for ticket & cover pages //=================================================== var isCover = (curr>recs); var template = { outputName: ExField("WO#") + ["_ticket","_Cover"][+isCover], page: ["ticket","p1"][+isCover], copies: [1,Int(ExField("Books"))][+isCover] } //=================================================== // Page control & output //=================================================== FusionPro.Composition.SetBodyPageUsage(template.page, true); FusionPro.Composition.repeatRecordCount = template.copies; if (!((curr%recs)-1)){ FusionPro.Composition.OpenNewOutputFile(template.outputName + "." + FusionPro.Composition.outputFormatExtension) } As I mentioned in the code, if you have rules in your templates that call fields using the 'Field' function (ex: 'Field("Books")' ), you might want to move that 'ExField' function into the JavaScript globals so that you can use that instead. If you have text frames that reference variables, they won't need to be altered since I added all of them back in that 'for' loop. Hopefully I understood your problem well enough to help you get started.
  7. I think you could accomplish this without the "Change detail font color" rule you've made. Just change your main code to this: var spanTag = '<span font="Arial Bold" color="PANTONE 382 U">⇒ </span>'; return Field("Kitchen Detail").split('<p>').filter(String).map(function(s){return spanTag + s;}).join('<p>'); Here's a break down of what's going on: var spanTag = '<span font="Arial Bold" color="PANTONE 382 U">⇒ </span>'; That's your arrow wrapped in span tags. Note: I used the 'font' and 'color' properties of the span tag rather than 'color' and 'f' tags. Field("Kitchen Detail").split('<p>') Create an array of the "Kitchen Detail" field. Each paragraph is now an element of an array. I'm assuming that returns are translated into paragraph tags in MarcomCentral. .filter(String) Filter out empty array positions. This handles the "if Field("Kitchen Detail") != ''" you had in your "Change detail font color" rule. It will also prevent multiple line breaks. .map(function(s){return spanTag + s;}) Map each element in the array (represented by the 's' variable) to be prepended by the 'spanTags' variable. .join('<p>') Converts the array back to a string and adds back the '<p>' tags.
  8. If I'm understanding your question correctly and you want to dynamically add asterisks between the "Magname" and the "Endorse" variables, then you don't need a rule for this at all. In you text editor, insert your first 3 variables, tab, and insert the "endorse" variable. Then click the "Tabs..." button in the text editor dialog box and add a new tab: Position: 3.9in (Note: if the line has to be exactly 4 inches long, set the position to 4 and increase the width of the text box so it doesn't wrap.) Alignment: Right Leader: * If you really wanted to do this with JavaScript, you could use TextMeasure to measure the length of your 4 variables and using a while loop add an asterisk to that string until the line was equal to 28800 (4 inches - TextMeasure returns width in 1/100 of a point). But I think that's unnecessary.
  9. Ahh, I did not know that. I couldn't understand why the (what looked to me like) tabs were being converted to entities so I was just trying to get rid of all of them; but that makes much more sense now. Thanks, Dan. And after learning how Plain Text File Resources are handled that solution seems much safer. As I said in my original post, this solution only works because of the monospaced font and wouldn't work with a font like Helvetica. I am curious to see something like this formatted into a table, though. I wracked my brain trying to figure out how to tackle that one but came up short when trying to wrap my head around how to delimit cells and keep the formatting without editing the original text files.
  10. You can somewhat fake this since you're going to be using a mono-spaced font by converting all of the random entities that come over when you import the file into FP to non-breaking spaces ( ). I also converted all of the regular spaces to non-breaking spaces to make them line up. Here's an example ("Treat returned strings as tagged text" in the Rule Editor must be checked): var page = CreateResource('./Sample\ Page\ without\ font\ command\ lines.txt') return page.content.replace(/&[^;]*;|\s/g,' '); Attached PDF of output. text-import-example.pdf
  11. To be quite honest, I have learned so much about JavaScript through this forum. Users like Dan, Eric, and countless others have given some pretty clever solutions to issues I would have never come up with on my own. I don't know of any one book per se that I would recommend as a "read this and you'll master JS," but I frequently visit W3Schools and CodeAcademy for definitions, examples, terminology, and the like. It's important to keep in mind that most things you'll find on the internet will be JavaScript and how it relates to websites but much of that knowledge can be applied to the way FusionPro uses the language. FP also has certain "FP-specific" functions, objects, etc that won't show up on any website outside of the FP community but their uses and functionality are pretty well documented in their documentation and on this forum. My strongest suggestion would be to search this forum for solutions, ask questions, and try to understand what's happening in solutions that are offered. Inquire about how code works if you don't get it. I'd also highly recommend participating. Try to offer solutions to problems that challenge you because you'll either teach someone something or teach yourself a new way of doing something. Good luck!
  12. That looks like you pulled that code directly out of a text resource. Most of that isn't necessary for what you're trying to return. The paragraph tags, tracking, font, etc is the way that FusionPro marks up the text that you've set in your text editor so if you're adding that into the same text box with the same settings (font, tracking, etc) then all of that code really becomes redundant. The other issue is that the "<variable name=.." tags are also the way that FP markups up your text editor input. If you really want to use the tagged text, you can replace those with your fields like this (note that tags need to be treated as strings i.e. in quotes): if (Field("UA Plus Individual") > "1") { return '<p style="(no style)" br="false" override="true" quad="L" findent="0" lindent="0" rindent="0" leadbefore="0" leadafter="0" keeplines="true" widows="2" kerning="true" hyphenate="false" skipifempty="false" skipifemptyvar="false" noparabreakoncopyfit="false"><tracking newsize="0"><f name="TisaSansOT-Medium"><z newsize="8.0"><color name="Black">Individual:<f name="TisaSansOT-Light"> $' + Field("UA Plus Individual") + '> per' + Field("Pay Period") + '<t>'; } return ""; I think you'd be better off doing something like this though: if (Field("UA Plus Individual") > "1") { return '<f name="TisaSansOT-Medium">Individual:<f name="TisaSansOT-Light"> $' + Field("UA Plus Individual") + '> per' + Field("Pay Period") + '<t>'; } return ""; Or more succinctly: var result = '<f name="TisaSansOT-Medium">Individual:<f name="TisaSansOT-Light"> $' + Field("UA Plus Individual") + '> per' + Field("Pay Period") + '<t>'; return (Field("UA Plus Individual") > "1") ? result : ""; Out of curiosity because it seems like you're working on the same problem, did the solution I posted here not work for you?
  13. Here's a TextMeasure example: var field = Field("clinic"); // Your field goes here. var graphic = '/path/to/your/graphic.jpg'; var graphicHeight = 1; // Height of your line (in points) var font = { face: "Helvetica", // Replace with your font size: 15 // Replace with your font size (in points) } // Tag the text for text measure var tags = '<span font="' + font.face + '" pointsize="' + font.size + '">'; field = tags + field + '</span>'; // Get the text width function getTextWidth(input){ var tm = new FusionProTextMeasure; tm.useTags = true; tm.CalculateTextExtent(input); return tm.textWidth; } // return field with a break (<br>) and the graphic return field + '<br><graphic file="' + graphic + '" width="' + getTextWidth(field) + '" height="' + (graphicHeight*100) + '">';
  14. Posting a picture would help a ton. Is the line an inline graphic? Is the clinic name meant to flow with any other text that my surround it? You could set the width of an inline graphic to match the width of the text using the TextMeasure feature. You could the text in a table cell with a bottom-border. A simpler solution would be to underline the variable in the text editor or using the "<u>" tags.
  15. Okay well open up Terminal (Applications/Utilities/Terminal.app) and we can create the data file: 1. copy the following code into Terminal and press enter echo graphic > ~/Desktop/data.csv That will create a file on your desktop called "data.csv" with the field name "graphic" 2. type "cd " (with a space) and drag-and-drop the folder containing your graphics onto the terminal window and press enter 3. Copy this code into Terminal and press enter ls | grep png >> ~/Desktop/data.csv Now you can link up to that data file that was created on your desktop and pull in your graphics by referencing the "graphic" field. Then you can impose them 3-up using FPImposer.
  16. Make sure you have "Treat return strings as tagged text" checked in the rule editor. You can superscript the registration mark like this: function Plan(title, individual, twoParty, family, unit){ var fonts = { planTitle: '<span font="TisaOT" pointsize="10.0">', optionTitle: '<span font="TisaSansOT-Medium">', option: '<span font="TisaSansOT-Light">'}; title = fonts.planTitle + title + '</span>'; var options = [["Individual: ", individual], ["Two-Party: ", twoParty], ["Family: ", family]]; options = options.filter(function(s){return s[1];}); if (!options.length){ return ''; } options = options.map(function(s){return fonts.optionTitle + s[0] + '</span>' + fonts.option + '$' + FormatNumber("###.00", s[1]) + ' ' + unit + '</span>';}); options.unshift(title); return options.join("<br>"); } var uaPlus = Plan("UltimateAdvisor[color="Red"]<superscript>®</superscript>[/color] Plus", Field("UA Plus Individual"), Field("UA Plus Two-Party"), Field("UA Plus Family"), Field("Pay Period")); var ua = Plan("UltimateAdvisor[color="Red"]<superscript>®</superscript>[/color]", Field("UA Individual"), Field("UATwo-Party"), Field("UA Family"), Field("Pay Period")); return [ua,uaPlus].filter(String).join('<p verticalstart="topofcolumn">');
  17. To my knowledge, that is not functionality that FP has. And while I'm not entirely sure what you mean by "place the first image in this folder and then place the next image in this folder," I think your best bet would be to create a data file that has your graphics in it. You declare specific paths programmatically for different files but I don't really see how you could do that without a data file. Are you saying all of your images are in different folders? If they all have a common folder, making a data file can be done pretty simply using bash scripting. Can you be more specific about where the files are located/named/etc? Are they PDFs? EPS's?
  18. It could just be something fishy going on with my computer but I still wasn't able to get a whole lot out of that attachment since I don't have your fonts and for some reason all of the rules you had applied to the text frames did not come over for me. You must be running a different version of FP than I am. Anyway, the way I would do this is to have one rule that returns your plans to your text box. And then I'd set the text box (or a text box that I assumed was supposed to have your plans in it) to be two columns. That way you can force the first plan to return in the first column and the second plan in the second column and if there's only one, it adjusts. You could do the same thing with a table if you wanted but that seems a little overkill for a textbox that is only displaying the plans. Here's the code I came up with: function Plan(title, individual, twoParty, family, unit){ var fonts = { planTitle: '<span font="TisaOT" pointsize="10.0">', optionTitle: '<span font="TisaSansOT-Medium">', option: '<span font="TisaSansOT-Light">'}; title = fonts.planTitle + title + '</span>'; var options = [["Individual: ", individual], ["Two-Party: ", twoParty], ["Family: ", family]]; options = options.filter(function(s){return s[1];}); if (!options.length){ return ''; } options = options.map(function(s){return fonts.optionTitle + s[0] + '</span>' + fonts.option + '$' + FormatNumber("###.00", s[1]) + ' ' + unit + '</span>';}); options.unshift(title); return options.join("<br>"); } var uaPlus = Plan("UltimateAdvisor® Plus", Field("UA Plus Individual"), Field("UA Plus Two-Party"), Field("UA Plus Family"), Field("Pay Period")); var ua = Plan("UltimateAdvisor®", Field("UA Individual"), Field("UATwo-Party"), Field("UA Family"), Field("Pay Period")); return [uaPlus,ua].filter(String).join('<p verticalstart="topofcolumn">'); I've attached a screenshot. You'll notice that the text frame editor has that text frame's columns set to "2" (highlighted in green). screenshot.pdf
  19. How do you determine if a pricing option should show up? Is it based on whether or not the field contains numbers? If so, you could test to see if the field contains anything after you remove everything that isn't numbers, if it does return the field, if it doesn't, you'll know it was empty: var field = "$70.00 per month"; // Your field name here return (field.replace(/[^\d]/g,'')) ? field : ''; If you post your collected template and a sample of your data, someone might be able to give a more specific answer.
  20. That is exactly why I decided to post. I've learned a lot through other people doing the same thing. I was really hoping that I didn't come off condescending by replying when you had already given a working solution Yeah, there are certainly ways to convert an array to a string and using the toString method would work but you want to be careful not to use it on the entire array if the length is greater than 1. Essentially what you're doing when you split a string is creating an array at the split character. So, splitting the email address at the @ would create an array with a length of 2 where position 0 is the name (everything before the @) and position 1 is the domain (everything after the @): var email = "ste.pennell@email.com"; email = email.split("@"); // <-- basically creates this array: ["ste.pennell", "email.com"] return email; // <-- returns "ste.pennell,email.com" //return email.toString(); // <-- returns "ste.pennell,email.com" You can access the strings at each of those positions by specifying the position: return email[0]; // "ste.pennell" //return email[1]; // "email.com" Since you specified '1' as the second paramater in the split, you're basically saying "only split the string once" (or "the resulting array should have a length of 1"). So it still creates an array but since the length is only 1 position, it doesn't look weird when you return it because there's no comma separating the second position from the first: var email = "ste.pennell@email.com"; email = email.split("@",1); // <-- basically creates this array: ["ste.pennell"] return email; // <-- returns "ste.pennell" It looks like it's a string but it's still an array and here's how you can tell: return typeof email; // object While specifying the position, gives you the actual string that you split: return typeof email[0]; // string Arrays can be very helpful but it sometimes seems easier to use string specific methods like "replace" in order to keep the string a string and avoid muddying up the code with converting the array back to a string. Though, as long as you understand what's happening to the string when you use a "split" then it shouldn't be a problem to figure out how to access the string again if you need to.
  21. One way of handling this scenario is to assign your data fields to variables that are set in the OnRecordStart callback rule and referencing the new variables in your rules/text frames rather than the actual field names. That way re-mapping your variables is as easy as opening the OnRecordStart rule and re-assigning the field names to the variables without having to edit every specific rule or text box that references that field name. For example if I have a data file with fields "Name", "Phone" and "Address", my OnRecordStart callback would look like this: FusionPro.Composition.AddVariable("temp_name", Field("Name")); FusionPro.Composition.AddVariable("temp_phone", Field("Phone")); FusionPro.Composition.AddVariable("temp_address", Field("Address")); I prefixed "temp_" to names to distinguish between the variables I assigned and the variables that are in the data. Then in your rules you'd reference Field("temp_name") instead of Field("Name"). If you want to use the variable you created in a text rule, simply type "temp_name" in the "variable" selector of the Text Editor and click "Insert". I know that's not as elegant as a GUI pop-up that remaps the variables for you but depending on how much time you spend re-mapping variables in your template, it might still end up saving you some time.
  22. This will more than likely work for this particular use case, however I just want to point out that using the split function creates an array from the string. Specifying '1' as the second parameter limits the length of the array to 1 but the result is still an array. The only reason I bring this up is because you will run into issues later if you try to perform String specific methods to that resulting variable. For example, let's say my email address is "ste.pennell@email.com". I can split that string at the "@" to get my first and last name: var email = 'ste.pennell@email.com'; var name = email.split('@',1); return name; // ste.pennell But if I wanted to split the 'name' variable on the 'period' to get just the first name, it will throw an error because 'split' works on strings – not arrays: var email = 'ste.pennell@email.com'; var name = email.split('@',1); // ste.pennell var firstName = name.split('.',1); return firstName; // type error: firstName.split is not a function You can make a minor modification to your original code and specify the position in the array you'd like to return to return the actual string like so: var email = 'ste.pennell@email.com'; var name = email.split('@',1)[color="Red"][0][/color]; // ste.pennell var firstName = name.split('.')[color="red"][0][/color]; // ste var lastName = name.split('.')[color="red"][1][/color]; // pennell return firstName; // ste But honestly for this scenario, since you have no intention of using the '@' or anything after it, I would just replace it all together: var email = 'ste.pennell@email.com'; var name = email.replace(/@.*$/,''); // ste.pennell var firstName = name.split('.')[0]; return firstName; // ste Or specifically to your case: return Field("Email").replace(/@.*$/,'');
  23. This sounds like a question specific to MarcomCentral so I doubt I'll be able to lend much assistance but: 1. What happens when the template is composed? Does the image show up? If not, what does the .msg log say? 2. Does the field you're referencing in the CreateResource function contain the full path of the image or just the image name? 3. It may be a silly question, but is the image small enough to fit in the text frame? If it's not you might want to look at constraining the size of the image. Posting an example of your data/template or even your .msg log would be extremely helpful if you can.
  24. I would think you could put something like this in your OnRecordStart rule to define the CMYK values of the color you've defined in your template: var field = "100,0,100,0"; // Your CMYK Field var [c,m,y,k] = field.split(',').map(function(s){ s=StringToNumber(s); return (s>100) ? 100 : (s < 0) ? 0 : s;}) new FusionProColor("schoolColor", c, m, y, k); I'm assuming that the field you're keying off of is a comma-separated CMYK definition but I'm sure you could easily adapt this solution to your particular scenario.
  25. If I had to guess, I'd bet that this functionality is restricted to the first page in the document. If you were to rearrange your template so that "PAGE B" was the first page in the template, you'd see that the authoring meta-data was only created for the "PAGE B.pdf" output file. So having the pages set to "Unused" or not is really irrelevant. If all of your pages were set to unused (and toggled on and off by OnRecordStart) the output files that use the first page in your template would honor your authoring meta-data. This is similar to how FPImposer works. If the first page in the template is 8.5x11 and the second page is 5x5, you won't be able to properly impose the 5x5 page even with the 8.5x11 page set as unused. To my knowledge, in order to get the results you're looking for, you'd have to split your template into multiple single-paged templates, unfortunately.
×
×
  • Create New...