Jump to content

mcmahand

Registered Users - Approved
  • Posts

    22
  • Joined

Converted

  • Location
    Charlotte, NC

Converted

  • Occupation
    Document Composition Developer

Converted

  • FusionPro Products
    Yes

Converted

  • FusionPro VDP software version
    10.0.26

Converted

  • OS
    Windows 8

Converted

  • Acrobat Version
    Acrobat DC

mcmahand's Achievements

Apprentice

Apprentice (3/14)

  • First Post Rare
  • Collaborator Rare
  • Conversation Starter Rare
  • Week One Done
  • One Month Later

Recent Badges

10

Reputation

  1. Yeah, I had some concerns about composition time with any of the approaches. Testing so far is promising with the text measure and RegEx taking the same amount of time as looping through strings. Another approach of using a RegEx to split at n characters and no other operations saved about a minute in my test run. Then again, for this job, even double composition time would still be a savings compared to hand editing the data files.
  2. Actually, I am not setting the margins but am leaving defaults. This table has to overflow to multiple pages, and I found in the past that setting margins does not work well with that. Below is a stripped-down version of my code. The cell width is actually less than 7/8", and the font size is 8pt, but that is accounted for in the code. function breakText(input,cellWidth){ var tm = new FusionProTextMeasure; tm.pointSize = "8 pt"; tm.font = "Helvetica"; tm.maxWidth = cellWidth; tm.CalculateTextExtent(input); var breaks = tm.textLines-1; if (!breaks) return input; input = input.match(new RegExp('(.{' + Math.floor(input.length/breaks) + '})','g')) || []; return input.join('<br>'); } FPTable.prototype.NewRow = function() { table.AddRows(1); return table.Rows[table.Rows.length-1]; } //Setup column widths for table var Column00Width = 0.8125 * 7200; var Column01Width = 0.5 * 7200; //Start table var table = new FPTable; table.AddColumns(Column00Width,Column01Width); // Add rows as we go... // Row 1 ------------------------------------------- var row = table.NewRow(); var cell = row.Cells[0]; var margins = 0; if (cell.Margins) { margins += cell.Margins.Left || 0; margins += cell.Margins.Right || 0; } row.Cells[0].Content = breakText('Subject_Name_1', Column00Width-margins) + '<br><br>[Record ID]'; row.Cells[1].Content = '[DOB]'; // Row 2 ------------------------------------------- row = table.NewRow(); row.Cells[0].Content = breakText('Jane Neverendinglastname', Column00Width-margins) + '<br><br>[Record ID]'; row.Cells[1].Content = '[DOB]'; // Apply formatting to all the rows. for (var a = 0; a < table.Rows.length; a++) { for (var b = 0; b < table.Columns.length; b++) { table.Rows[a].Cells[b].SetBorders("Thin", "Black", "Left", "Right"); table.Rows[a].Cells[b].SetBorders("Thick", "Black", "Top", "Bottom"); } } return table.MakeTags(); The result is that FP lists an error for each name in the log and does its own wrapping (or lack thereof) that happens without the function. The second row shows that the entire cell content disappears if a word requires more than 2 lines. If I hardcode a value like 3000 for the parameter, the function does work and the errors go away. But I had an idea in mind for this project to just set a character limit instead. While I have the green light for arbitrary breaks, I still wanted to try to break lines at spaces where possible. I found almost exactly what I was thinking of in a post at stack overflow, so I used that instead for the breakText function. I am getting good results, so I will probably stick with the character limit option (as shown below). // Found at // http://stackoverflow.com/questions/14484787/wrap-text-in-javascript function testWhite(x) { var white = new RegExp(/^\s$/); return white.test(x.charAt(0)); }; function breakText(str, maxChars) { var newLineStr = '<br>'; done = false; res = ''; do { found = false; // Inserts new line at first whitespace of the line for (z = maxChars - 1; z >= 0; z--) { if (testWhite(str.charAt(z))) { res = res + [str.slice(0, z), newLineStr].join(''); str = str.slice(z + 1); found = true; break; } } // Inserts new line at maxWidth position, the word is too long to wrap if (!found) { res += [str.slice(0, maxChars), newLineStr].join(''); str = str.slice(maxChars); } if (str.length < maxChars) done = true; } while (!done); return res + str; } FPTable.prototype.NewRow = function() { table.AddRows(1); return table.Rows[table.Rows.length-1]; } //Setup column widths for table var Column00Width = 0.8125 * 7200; var Column01Width = 0.5 * 7200; //Start table var table = new FPTable; table.AddColumns(Column00Width,Column01Width); // Add rows as we go... // Row 1 ------------------------------------------- var row = table.NewRow(); var cell = row.Cells[0]; var margins = 0; if (cell.Margins) { margins += cell.Margins.Left || 0; margins += cell.Margins.Right || 0; } row.Cells[0].Content = breakText('Subject_Name_1', 10) + '<br><br>[Record ID]'; row.Cells[1].Content = '[DOB]'; // Row 2 ------------------------------------------- row = table.NewRow(); row.Cells[0].Content = breakText('Jane Neverendinglastname', 10) + '<br><br>[Record ID]'; row.Cells[1].Content = '[DOB]'; // Apply formatting to all the rows. for (var a = 0; a < table.Rows.length; a++) { for (var b = 0; b < table.Columns.length; b++) { table.Rows[a].Cells[b].SetBorders("Thin", "Black", "Left", "Right"); table.Rows[a].Cells[b].SetBorders("Thick", "Black", "Top", "Bottom"); } } return table.MakeTags(); Thanks for your help on this. I like to see different code options--and especially want to understand RegEx better.
  3. Thanks Ste. Unfortunately, I still have issues using your function with my test data placed in a table cell. I had to set the width to less than half my column width--there are margins but not that much--to break the test names at all. And I still have a real name that errors for some reason when I compose. (I adjusted the code for my font and size, so it's not that either). Not sure what's going on. It seems like your code should work. For the particular job I'm working on, I may use a more "crude" solution. I'm thinking along the lines of figuring out a safe character count for each line and breaking the text at the character count.
  4. I am setting up a template for a client that requires me to pull in a list of information from an external file and place in a table for each letter. There are several pieces of information that go into each cell and some columns are rather narrow. Unfortunately, one of the columns requires placing names but only leaves about 7/8" width for them. Some of the names (and all of my test data names) can be too long to fit on one line. The result is I get errors like: The composed results will usually show an arbitrary line break (which is OK), but I know from a similar job last year that if a "word" requires more than 2 lines, the entire cell content will be blank. There could be hundreds (if not thousands) of errors like this in the .msg file. Last year, I had to manually edit the data to force breaks myself. This year, the job is too big to do that. Is there some way to force arbitrary line breaks (and not give errors and not give up at just 2 lines)? Or any ideas for how to make a function that efficiently creates forced line breaks? This would be OK result -------------- |Testexamp | |le_Name_1 | | | |RecordID | -------------- I do not need copy fitting or other sizing changes. I don't need it to look pretty--it is far more important to include all of the information. I need to keep breaking to new lines as needed.
  5. When you go to Create Resources and click Add, there is an option for a Type called "Formatted Text". Choose that and click the Edit... button. From there you will be in a text editor just like editing a text frame in your layout. You can copy & past text in, change formatting, and place variables (or even text rules). Click OK when you're done, and optionally, change the name of the resource. You can use the same text rule you tried before to select between resources.
  6. You can create more than one barcode rule and place each rule in a text box where the barcode should go. In the rules dialog, either use the duplicate button and then edit each rule to adjust the rule name and which column is used. Or you can start again with creating a new rule and using the 128 barcode template and using a unique rule name. Your existing rule will still be there.
  7. Another way to you could do this is actually a text box, and that would only require 1 rule. You can make one large text box roughly similar to the area covered by the 9 graphic boxes now. The text box may have to be slightly wider than your page (or crop off part of the right edge of the graphic resource). And you'll have to play with the position and height of the text box. Create a text rule with code similar to below, and check to "Treat returned strings as tagged text". var returnText = ""; var allFields = [Field("userid1"),Field("userid2"),Field("userid3"),Field("userid4"),Field("userid5"),Field("userid6"),Field("userid7"),Field("userid8"),Field("userid9"),Field("userid10")]; var counter = 0; for (var i=0; i<allFields.length; i++) { if(allFields[i] != "") { returnText += "<P>"; } } return returnText + "\<graphic resource=\"PTI Resource\" position=\"afterline\"\>"; This code is crude and just adds paragraph tags to push the inline graphic down the page. I'll leave it as another exercise to get the leading and line spacing just right. Tidying up more, you could create a variable length table for the userids and include the graphic inline below it without needing the paragraph tags at all.
  8. To shed additional light on the question, I frequently use the exact font in your sample: Archer. If you are using the OpenType version of Archer, it is like there are multiple versions available within a font style. InDesign allows you to select Archer Book, for example, and then choose options through the character palette. However, those additional font features are not available to you in FusionPro. So, for Archer Book, the default style, with shifted numbers, is what you get. The work-around that I found was to use a postscript font set of Archer. Many of the alternate styles are available as separate named fonts. In my case, I needed Archer Book LF, Archer Bold LF, Archer Semibold LF, etc. instead of Archer Book, Archer Bold, and so on. So anywhere, I need numbers aligned to the baseline, I might pick Archer Book LF for the whole block of text. In summary... 1) Try to get the postscript set of Archer. (I can't remember where we purchased, or I would provide a link.) 2) Find the font style within the set that fits your needs and use that instead. 3) The style may work for all of your body copy, but if you need to use an alternate style for specific segments of text, then Dan's suggestions for code to change the font will work.
  9. What you describe seems OK for producing the code itself. As for matching customer art, you may have to play around the font (e.g. IDAutomationC128M instead of IDAutomationC128L font or whatever) and try different point sizes. Also, you may have to expand the text box more than you think to truly see the results. More importantly, you have to make sure what you produce is acceptable to the USPS. All I can say is that I use IDAutomationC128L set at 21pt in a text box, and happen to use only the Zip (not Zip+4) in the routing portion. That it has been mailable for Priority Mail. I have attached a sample. Priority Mail Label Test.pdf
  10. I can't tell much from what you have described, but here are a few suggestions... 1) The digits of a combined code when using Zip+4 in routing portion (i.e. after the 420), should be 34 characters (38 once you add 2 sets of parentheses). Your example is 33 characters (37 with parentheses), so it appears there may be a digit missing from your package code. 2) I'm not sure if you used a template for the barcode rule or started with an empty text rule and added JavaScript. If it is an text rule with JS, make sure "Treat returned strings as tagged text" is checked at the top.
  11. I am testing upgrading our FP7 templates to FP8. One of the issues that I've found is when attempting to compose with Producer (formerly Direct). The file composes (can find it in the "working" folder) but it does copy to the designated output folder when completed. And the .msg does not have the usual "Copied file..." line before "Job ended". The problem does not seem to be with our Producer settings. Templates created from scratch in FP8 do not have this issue with or without naming rules (see background below). Also, I can get the FP7 templates to work as expected through trial and error and multiple re-save attempts. Has anyone else run into an issue like this? Could it be a bug? Background: 1) We make extensive use of file naming rules to rename output based on the name of the data file driving it. Starting around 7.2, I had to add a call in OnJobStart to force the OnNewOutputFile to fire when not chunking output. 2) With this code commented out, the file does copy to the expected output folder. But it's not named what I want, of course. For problematic templates, some attempts with the code commented out, saved, uncommented, and re-saved seems to work. 3) The attached template was created from scratch in FP7 and then re-saved in FP8. Saving in FP8, composing with Producer, saving again, and re-composing seems to work. "FP7" = FusionPro Desktop 7.2P1d, Acrobat 9.5.0, Mac OS X 10.6.8 "FP8" = FusionPro VDP Creator 8.2.7, Acrobat 10.1.1, Mac OS X 10.8.2 "Producer" = FusionPro VDP Producer 8.2.5, Windows Server 2008 SP2 fp8_filename_test.zip
  12. I use 21pt for the font size, but you may have to play around with that size (and the S, M, L, or XL font version) depending on where you're trying to fit the barcode. Of course, make sure it meets the USPS specs. I recommend doing a test mailing if you can. Also, I take a cruder approach to getting the bars and other text around the barcode. I just make separate text boxes for everything and position to keep all of the spacing required between elements. Yes, even the bars are two empty text boxes with black background and the height I need. It's not elegant, but I know what everything is doing and position precisely. Screenshot is attached. Priority Barcode Screenshot.pdf
  13. I have to frequently produce these for Priority Mail projects. As Dan said, you can use the MakeEAN128Barcode function to create the barcode itself. One thing you may have to tweak is what data you feed into the rule. We format it as needed (a barcode field and a separate human readable field) in our data files, but the formatting could be done with JavaScript in FusionPro. The barcode is actually two codes combined (the ZIP code routing and the package code). The USPS just wants the package code (formatted with spaces between groups of numbers) now for the human readable. But the barcode can still have ZIP routing in it. From your example... ZIP routing: 42020026 Package code: 9402805213683062522920 Now the first parts of each code (420 for the ZIP & 94, in this case, for the package code) are actually "application identifiers". I've found that you need wrap the application identifiers in parentheses () before running through a barcode rule. Below are the two formats to use (either feed in your data, or format with rules/functions). Barcode: (420)20026(94)02805213683062522920 Human Readable: 9402 8052 1368 3062 5229 20 Here's an example of the actual barcode rule. I place this in a text box and format with the IDAutomationC128L font. var barcodeData = Field("USPS PACKAGE SERVICES BARCODE"); if (barcodeData == "") { return barcodeData; } else { return NormalizeEntities(MakeEAN128Barcode(barcodeData)); }
×
×
  • Create New...