Jump to content

step

Registered Users - Approved
  • Posts

    962
  • Joined

Everything posted by step

  1. What's the file format of the images? PDF? Looks like part of the circle is outside of the artbox to me but I can't really help you any more than that just based off of a screenshot.
  2. Make sure "treat returned strings as tagged text" is checked in the rule editor.
  3. I'll bet that the issue has less to do with the GetFileName function and more to do with the special character (é) in the field name. It seems like that character might work fine locally on a Mac but could be translated incorrectly on a server (especially if it's a Windows server). You should probably use a function like "TaggedTextFromRaw" to better handle the special characters. It will convert the é to its HTML entity: é Then you would be able to change your if statement to: if (TaggedTextFromRaw(Field("Type-flux")) == "Bi-flux" || TaggedTextFromRaw(Field("Type-flux")) == "Bi-flux projet métal") Or using a Regular Expression: if (!TaggedTextFromRaw(Field("Type-flux")).search(/Bi-flux( projet métal)?/g)) And if you really want reduce your code to eliminate the excessive if/else statements, you could change your OnRecordStart rule to look like this: var flux = TaggedTextFromRaw(Field("Type-flux")).search(/Bi-flux( projet métal)?/g); pg = [['One','Three'],['Two','Four']][+!!Field("LogoColl2")][+!!(flux)]; FusionPro.Composition.SetBodyPageUsage(pg, true);
  4. Oh, I'm just noticing that you're running FusionPro 7 which uses JavaScript 1.5. The 'filter' and 'map' functions were introduced in JavaScript 1.6. You could insert Array.prototype.filter and Array.prototype.map to the beginning of the previously mentioned code or you can just change the code to this: // Number logos: var cellImg = Resource("cell").content; var phoneImg = Resource("phone").content; var faxImg = Resource("fax").content; // Number offset from baseline var offset = 50; var result = []; var numbers = [[cellImg, Field('cell')],[phoneImg, Field('phone')],[faxImg, Field('fax')]]; for (var i in numbers) if (numbers[i][1]) result.push(numbers[i][0] + '<p br=false superoffset=' + offset + ' superratio=100><superscript>' + numbers[i][1] + '</superscript>'); return result.join('<br>');
  5. In your rule editor, if you have "building blocks" turned on, you can get the syntax for functions and objects by double-clicking on them: Objects > External Data > ExternalDataFileEx: new ExternalDataFileEx(Filename, Delimiter) So in your case: DepData = new ExternalDataFileEx('X:\\Data Source\\2015\\32703 Brinkers Open Enrollment\\Test Data\\BI_Dep_Detail_08282015_TEST.csv', ','); // Assuming comma-delimited. '\t' for tab-delimited
  6. Actually, all you'd have to change is the map function: // Number logos: var cellImg = '/path/to/cell.png'; var phoneImg = '/path/to/phone.png'; var faxImg = '/path/to/fax.png'; // Number offset from baseline var offset = 50; var numbers = [ [cellImg, Field('cell')], [phoneImg, Field('phone')], [faxImg, Field('fax')] ].filter(function(s){return s[1]}).map( function(s){ [color="Red"]return '<p br=false superoffset=' + offset + ' superratio=100><superscript>' + s[1] + '</superscript>' + CreateResource(s[0],'graphic').content;[/color] }).join('<br>') return numbers; Within that function is where all of the "magic" is happening. That's where the image path is being converted to a resource and where the inner array ([img, number]) is being converted to a string where 's[0]' is the img and 's[1]' is the number. Sure you could create them as graphic resources, but you'd have to make a few changes to account for that: // Number logos: [color="red"]var cellImg = Resource("cell").content; var phoneImg = Resource("phone").content; var faxImg = Resource("fax").content;[/color] // Number offset from baseline var offset = 50; var numbers = [ [cellImg, Field('cell')], [phoneImg, Field('phone')], [faxImg, Field('fax')] ].filter(function(s){return s[1]}).map( function(s){ [color="red"]return '<p br=false superoffset=' + offset + ' superratio=100><superscript>' + s[1] + '</superscript>' + s[0];[/color] }).join('<br>') return numbers;
  7. Rather than drawing 25 text frames, you'd be better off generating a table and displaying it in one big text frame. Here's what that would look like: // Link as external data file var ex = new ExternalDataFileEx('BINGO Questions.txt','\t'); // Create an object of each field value var cols = {}; for (var n=0; n<ex.fieldCount; n++) { var col = ex.GetFieldValue(0, n); cols[col] = []; for (var i=1; i<=ex.recordCount; i++) cols[col].push(ex.GetFieldValue(i,col)); } // Shuffle the fields and then take 5 values for (var i in cols) cols[i] = shuffle(cols[i]).splice(0,5); cols['N Answers'][2] = ''; // Free space // Create 1.5" x 1.5" spaces in a 5x5 table var table = new FPTable; table.AddColumns(10800,10800,10800,10800,10800) for (var i=0; i<5; i++) { var row = table.AddRow(); var cell = row.Cells[0]; row.minHeight = 10800; cell.VAlign = "Middle"; cell.HAlign = "Center"; cell.SetBorders('Thin','White','Left','Right','Top','Bottom'); row.CopyCells(0,1,2,3,4); row.SetContents(cols['B Answers'][i],cols['I Answers'][i],cols['N Answers'][i],cols['G Answers'][i],cols['O Answers'][i]); } return table.MakeTags(); /*============================================ / || Shuffle function || http://bost.ocks.org/mike/shuffle/ / ===========================================*/ function shuffle(array) { var currentIndex = array.length, temporaryValue, randomIndex ; // While there remain elements to shuffle... while (0 !== currentIndex) { // Pick a remaining element... randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; // And swap it with the current element. temporaryValue = array[currentIndex]; array[currentIndex] = array[randomIndex]; array[randomIndex] = temporaryValue; } return array; }
  8. One way to do this would be to use inline graphics in a text rule: // Number logos: var cellImg = '/path/to/cell.png'; var phoneImg = '/path/to/phone.png'; var faxImg = '/path/to/fax.png'; // Number offset from baseline var offset = 50; var numbers = [ [cellImg, Field('cell')], [phoneImg, Field('phone')], [faxImg, Field('fax')] ].filter(function(s){return s[1]}).map(function(s){return CreateResource(s[0],'graphic').content + '<p br=false superoffset=' + offset + ' superratio=100><superscript>' + s[1] + '</superscript>';}).join('<br>') return numbers; Note that the 'offset' variable is just used to superscript the actual phone number in order to give it the appearance that it's vertically aligned to the middle of the icons.
  9. What does your data file look like? Assuming your B,I,N,G, and O fields contain a list of answers separated by a comma, you could do something like this: var answers = Field("B").split(','); // Create an array of answers var result = []; // Create an array to hold the facts at random for (var i=0; i<15; i++){ var number = Math.floor(Math.random()*answers.length); // generate a random number between 0 and length of the array result.push(answers[number]); // push the fact into the result array answers.splice(number,1); // remove that fact from the Answers array so that it won't be pulled again } return result.join('<br>'); The above code will generate 15 random answers from the 'B' field separated by a break tag (<br>). The idea being that you would apply that rule to a text frame that will make up the "B" column. If you wanted to, you could name all of the "column" text frames by the data field they correspond to (B-O), check "Re-evaluate this rule for every text flow," and apply this rule to each frame: [color="Red"]var column = FusionPro.Composition.CurrentFlow.name; var answers = Field(column).split(','); // Create an array of answers[/color] var result = []; // Create an array to hold the facts at random for (var i=0; i<15; i++){ var number = Math.floor(Math.random()*answers.length); // generate a random number between 0 and length of the array result.push(answers[number]); // push the fact into the result array answers.splice(number,1); // remove that fact from the Answers array so that it won't be pulled again } return result.join('<br>'); Of course you could use a table as well. If you supply a copy of your template, data, or intended output, I'd be able to give you a better idea of how to accomplish this.
  10. Just split the client-supplied file in Photoshop and create a PDF to use for the left ticket's background and another for the right side. Then, by placing a graphic frame over the entire ticket background, you can alternate the left and right backgrounds by applying this code to it: var left = '/path/to/leftTicket.pdf'; var right = '/path/to/rightTicket.pdf'; return CreateResource([right,left][FusionPro.Composition.inputRecordNumber%2]); When you impose the files, assuming you cropped them correctly in Photoshop, the background will be seamless.
  11. Does the current date change after each composition? I may have just time traveled. I assumed seymoujd was wanting to put the date somewhere on his composed file. So if he composed today and had to re-compose later today he'd still want it to say "September 2, 2015." I suppose if he wanted a unique date per each composition (in the case of file name for example) your unformatted approach is probably the better option.
  12. If you only want the date, you can format it like so: return FormatDate(new Date(), 'lm d, yyyy'); The Date object by default will return the day, date, and time.
  13. I would make them two separate files (cover and tickets) and manually sort them post-production. Your current code in which you're adding 1 to your current record to get the content of the second ticket (on the right) is going to lead to issues. Specifically: you're ticket sheets will look like this: Making your template a 1up version of the ticket will save you a lot of headache and processing time and you can just impose it 2 up with FPImposer. As a side note, you can combine rules "FirstBox_L1"-L4 to be: var firstBox = [ Field("Opponent"), Field("VS"), Field("Wild"), Field("Date"), Field("Time") ].filter(function(s,p,a){return a[0]?s:0;}).join('<br>'); return firstBox.replace(Field("Date") + '<br>' + Field("Time"), Field("Date") + ', ' + Field("Time"));
  14. Do you have a sample of how the output should look?
  15. The paragraph tag by default starts a new paragraph. In other words, adds a break. Making this small modification should resolve your issue: if(Field("HeadShot") == "") { return '<p [color="Red"]br=false[/color] quad=C>' + Rule("RuleNameToUpper"); } else { return Rule("RuleNameToUpper"); }
  16. FusionPro > Edit Rules and then click the "JavaScript Globals..." button in the bottom left.
  17. Okay, here's how to make it work. And, I've actually tested it this time to verify that it's working. This goes in the JavaScript Globals and this is where you'll set the name of the PDF you're importing and the number of copies per card: var card = CreateResource("CKteamBusinesscards.pdf",'graphic',true); // Your PDF Resource var copies = 10; // 10 copies of each card var pages = []; This goes in OnJobStart: var pgCount = card.countPages; for (var i=0; i<pgCount; i=i+2) pages.push([i+1,i+2]); FusionPro.Composition.composeAllRecords = false; FusionPro.Composition.endRecordNumber = pgCount/2; Here the PDF that is defined global, will have its pages counted. The number of pages will be used to build the 'pages' array at the beginning of the job. It was also use the number of pages to determine the end "record" which was previously defined by the 'cards' variable. That way you don't have to manually change anything in the OnJobStart rule if the PDF you've defined globally contains more than 5 cards (10 pages). This goes in OnRecordStart: FusionPro.Composition.repeatRecordCount = copies; var [front,back] = pages[FusionPro.Composition.inputRecordNumber-1].map(function(s){ card.pagenumber = s; return card.content;}); FindGraphicFrame("ckfront").SetGraphic(front); FindGraphicFrame("ckback").SetGraphic(back); This is where the front and back is determined and assigned to its corresponding graphic frame. I believe you should still have my PayPal information
  18. I can't check the code with the template you've supplied because you didn't include the PDF that you're trying to pull in. You also haven't included any message log or really any feedback other than "it didn't work." As I said in my last post, I was merely trying to give you an idea of how to accomplish duplexing in this scenario and explain why it wasn't working as you had it set up originally. As far as it being "stuck in some type of loop," there's only one loop (a for loop) and I don't see why it would be failing but, like I said, I didn't test it. You could always try to put some "Print" commands in the code and check the message log to debug what's going on: for (var i=0; i<cards; i=i+2) pages.push([i+1,i+2]); [color="Red"]Print(pages.join('<br>\n'));[/color] The above will should print the contents of the 'pages' array which is being created in the 'for' loop. The 'pages' array should contain the page numbers that will be assigned to the 'front' and 'back' variables as the record repeats:
  19. If you want the imposition to duplex, your template should create 2 pages per record. In this case, the template should be two pages: the first page containing a graphic frame to display the front of the card and the second page containing a graphic frame to display the back of the card. I have no idea what that sentence means. Why do you have to split the fronts/backs if you add a second page? Are all of the fronts/backs in the same PDF? If so, you're making 5 sets of cards - not 10. I think you should be able to do something like this to get the template to create a duplexed card: OnJobStart cards = 5; // Number of cards you have FusionPro.Composition.composeAllRecords = false; FusionPro.Composition.endRecordNumber = cards; OnRecordStart var pages = []; cards = cards*2; for (var i=0; i<cards; i=i+2) pages.push([i+1,i+2]); FusionPro.Composition.repeatRecordCount = cards; var card = CreateResource("CKteamBusinesscards.pdf",'graphic',true); var [front,back] = pages[FusionPro.Composition.inputRecordNumber-1].map(function(s){ card.pagenumber = s; return card.content;}); FindGraphicFrame("ckcard").SetGraphic(front); FindGraphicFrame("ckcard_back").SetGraphic(back); Note that in the code above the graphic frame on the second page is named "ckcard_back." Also, understand that I haven't verified that this code works, it's more of an example than a complete solution.
  20. One way you could do that is to put your graphic in a table that has a border on it. var width = 25000; var graphic = '<graphic file="' + Field("Order ID") + "_" + Field("Document ID") + '.pdf" width="' + width + '" pagenumber=1>'; var myTable = new FPTable; myTable.AddColumns(width); var row = myTable.AddRow(); var cell = row.Cells[0]; cell.SetBorders("Thin","Black","Top","Bottom","Right","Left"); cell.Margins = {Top:1, Bottom:1, Left:0, Right:0}; row.SetContents(graphic); return myTable.MakeTags();
  21. According to page 66 of the "TagsRefGuide.pdf": return '<hypertext url="http://www.google.com">Upload Here</hypertext>';
  22. Sure: return (Field("Local Address")) ? Field("Local Address") : Field("Perm Address");
  23. If 'domain.com' is not found in 'uEmail', then indexOf would return -1. If it is found, indexOf will return the position in the string at which it's found (0 - length of uEmail). So, if you want to return the error when 'domain.com' is not found, you need to modify your if statement to return the error if the indexOf is equal to -1 or when it is less than zero. Also, by putting 'uEmail' in quotes, you're searching the string "uEmail" rather than the variable you've assigned the value of the "Email" field to. Obviously, "domain.com" is not found in "uEmail," so it will always return the error. You just need to modify it a bit: if(uEmail.indexOf('domain.com') < 0) { return '<para style="(no style)"><f name="Arial"><z newsize="7.0">' + "Must contain 'domain.com'. Please adjust or call support." + '</para>'; } Just as a side note, resizing text based on character count can be a (somewhat) risky move unless you're using a fixed-width font. For example: "will" has the same number of letters as "been" but "been" is wider. You might want to look into using the "CopyfitLine" function like so: var uEmail = Trim(Field("Email")); var frameWidth = 72; // 72 points == 1 inch if(uEmail.indexOf('domain.com') < 0) uEmail = "Must contain 'domain.com'. Please adjust or call support."; return CopyfitLine("", uEmail, "Arial", 7.5, frameWidth, 7);
×
×
  • Create New...