Jump to content

Dan Korn

Members
  • Posts

    4,882
  • Joined

  • Days Won

    17

Everything posted by Dan Korn

  1. FP version 10 is pretty old, and likely not compatible with the (presumably recent) version of Acrobat you're running, though you don't specify your exact version of Acrobat Pro DC. I recommend upgrading to FP 13.
  2. Well, I can't test it out without the rest of the job, including the primary data file and the XDF, but that looks right. Though you can also accomplish this without any JavaScript at all by setting up the XDF as a Secondary Data Source (from the menu, FusionPro -> Data Definition -> Secondary Data Sources, click Add to define the Excel file as a data source), then check the "Filter/map records where" box, set up the mapping between the XDF field "Manager" and the primary field "Text_Manager", and check the "Add to field list with prefix" box. Then the matched fields from the XDF will appear in the Text Editor variables list, and you can use them directly.
  3. From the New Rule dialog, click on the Event button, then select "Repeat Record Rule" and click Next, then select the Quantity field in the drop-down.
  4. Thomas's solution is good, but there's a handy FormatPhoneNumber function built into FusionPro which will do most of the heavy lifting for you. So you should be able to just do something like this: var nums = { "Direct": Field("Direct Number"), "Mobile": Field("Mobile Number"), "Fax": Field("Fax Number"), }; var result = []; for (var label in nums) { if (nums[label]) result.push(label.bold() + " " + FormatPhoneNumber(nums[label])); } return result.join(" ");
  5. You're doing fine. It's a complicated program with a lot of features. I don't know if there's anyone who understands everything about it. I'm still learning new tricks, and I've been working on FusionPro since its inception, 25 years ago. I don't mean to discourage you from writing code. Far from it: I'm a big fan of coding. (It's what I do!) I just wanted to clarify that this, like many tasks, can be accomplished without any coding, which many people prefer. Interesting that you mention Python. We actually had a bit of a debate years ago when we added the rules scripting system about what language to use. The finalists were JavaScript and Python. I think we ultimately made the right choice with JavaScript. (It's a bit more forgiving in some ways that Python, given Python's mandatory whitespace for one thing, though I know there are differences of opinion.) But Python has its charms as well.
  6. I don't think that's true. If you create a Graphic Drag-and-Drop rule, it will tell you to put either a Graphic Resource or a Graphic Rule into the "Return" box. I was able to create two other graphic rules: One based on the "Insert Picture Rule" Form, for the "if the image is uploaded" case, and another based on the Graphic "QR Barcode" Form, for the "generated by code" case, then use both of them in a Graphic Drag-and-Drop rule. But if you have it working in JavaScript, that's great.
  7. Error 5 is a Windows error code meaning "Access denied." It seems that the account under which Producer is running, as configured on the General Setup tab of the FusionPro Producer Configuration app, does not have sufficient permissions to write or copy files to the designated hot folder.
  8. You could just have a single graphic frame, and have it call out a graphic rule that returns either the generated or uploaded QR code. That graphic rule could call another graphic rule as necessary. Something like: if (Field("Upload") != "") return CreateResource(Field("Upload")); //else return Rule("QR Barcode: Barcode Data"); This could be probably accomplished with a Drag-and-Drop Wizard rule as well, without any code. Posting the template would allow me to make a more specific recommendation.
  9. It would be easier to help with a bit more information, at the very least the versions of FusionPro, Acrobat, and Windows or Mac that you're running. Posting a collected sample job would be even better, so that whoever is helping does not have to recreate a template with this scenario from scratch.
  10. A graphic in an image collection in MarcomPortal is referenced by the graphic's file name. So you would need this variation: if (Trim(ToLower(Field("YourFieldName"))) != "yes") return ""; // else something that returns a graphic, such as: return CreateResource("somefile.jpg", "graphic"); Note that since this is going to be an inline graphic, that is, a graphic that flows inline with text, you need to do this in a Text rule.
  11. Correct. A data source is input, not output. Other than the primary composed output, the log (.msg) file, an optional XML log file, and ancillary temp files, a FusionPro composition doesn't write anything to disk. This is by design, mostly because creating any other files is outside of the intended scope, but also because allowing arbitrary files to be written could be a security issue. That seems like something that could be accomplished with a script of some kind, such as PowerShell, Python, VBA, bash, etc. It's basically a table merge or join in database lingo; apps such as Excel have some functionality like this built in, as do, of course, actual database apps such as Access. But it's not really in the purview of what FusionPro VDP does directly.
  12. if (Trim(ToLower(Field("YourFieldName"))) != "yes") return ""; // else something that returns a graphic, such as: return Resource("ResourceName"); // or: return CreateResource("somefile.jpg", "graphic"); // or: return '<graphic file="somefile.jpg">';
  13. I don't understand your aversion to nested rules, but I suppose if you want to do this all in one rule, then you could just create the "Choose Phone Format" rule with the desired formatting, then convert it to JavaScript, and add any other logic you want.
  14. If you're in FP 11 or later, then the code you have in that JavaScript rule is fine, and you don't need to make any changes at all to it. What you need to do is create a new rule, select the "Choose Phone Format" Form Rule, select the name of your JavaScript rule in the "choose field" drop-down list, then select your format. Then use that form rule in your text frame, and it will format the phone number selected by your script logic.
  15. This is another "unmaking the soup" kind of thing, but it's doable. Probably the easiest thing is to just have a list of substitutions to apply to the entire string of text. And you'll want to use regular expressions to match whole words, and not just replace, say, every E that's part of another word with East. A regular expression can also be told to match the abbreviation either with or without the trailing dot/period. Something like this: var subs = { N: "North", S: "South", E: "East", W: "West", Ave: "Avenue", Bl: "Boulevard", Blvd: "Boulevard", St: "Street", Ste: "Suite", // etc., add more as needed }; var address = "512 N Elm Blvd., Ste. 200, Meadowville, NY 12345"; // or Field("Address") etc. for (var s in subs) { var re = new RegExp("\\b(" + s + "\\b\\.?)", "g"); // word boundaries, and zero or one dot/period address = address.replace(re, subs[s]); } return address;
  16. You would just call the Field function to grab the value from the named data field, for Excel or any other input data format, something like this: var s = Field("Title"); return s.replace(/\s*[IVXL]+$/, ''); Or if it's from an XDF, something like: var s = XDF.GetFieldValue(recordNum, "Title");
  17. You can call the SetFieldValue and Save functions on an ExternalDataFileEx object representing a tab-delimited file to update data in an XDF.
  18. var s = "AVP, Digital Media Specialist"; return s.split(',')[0].replace(/(A?)(VP)/, function(m, A, VP) { return (A ? "Assistant " : "") + "Vice President"; } ) Or: var s = "AVP, Digital Media Specialist"; var result = s.split(',')[0]; var parts = result.match(/(A?)(VP)/); if (parts) result = (parts[1] ? "Assistant " : "") + "Vice President"; return result;
  19. This is another one you could Google for, something like "javascript strip roman numerals." Assuming that the Roman numerals are at the end of the string, and that they're numbers less than 90, then it's pretty simple: var s = "Digtal Media Specialist III"; // field value etc. return s.replace(/\s*[IVXL]+$/, '');
  20. This isn't really a question about XDFs specifically, it's just about how to split up a single-field address into multiple lines. The good news is that, for questions like this, you can just Google something like "split address in JavaScript" and see lots of examples. The bad news is that there's no perfect solution. It's a "how to unmake the soup" question. Obviously it's better to have the city, state, street, etc. in their own discrete data fields, then you can combine them as needed. Once they're joined, there's no completely reliable way to split them up. (It's similar to the problems with un-capitalizing proper names.) That said, depending on how consistent the formatting is in the data, something like this should work: function splitAddressLines(address) { var result = address.split(/,\s*/); result = result.slice(0, -2).concat(result.slice(-2).join(", ")); return result.join("\n"); } return splitAddressLines("87 Maple Street, Suite 300, Willowdale, CA 90210"); // or a data field, XDF field, etc.
  21. Wow, you're on version 7.2? That's almost 13 years old and out of support. I don't even remember how much of the current functionality of FusionPro was present back then. That said, I think (but don't hold me to it) that there was a version of the ExternalDataFile object that you could invoke via a JavaScript rule in 7.2. And (I think) you could set FusionPro.Composition.repeatRecordCount in the OnRecordStart rule, and pull data from the ExternalDataFile object based on the repeat number. But the easiest thing for you, other than upgrading to a much more recent, and supported, version of FusionPro, may be to simply edit the data file to add a line for each combination of name and date that you want. It also shouldn't be too hard to write an Excel macro or batch file or some other kind of script to generate that.
  22. Sure you can. It's a page of type Template, which is usually used for a repeatable component, but it can still have variable frames when used as a slip sheet. You'll need a rule that calculates what the start and end record numbers from the chunk will be, but that's not too hard to do, then you can use that rule in a text frame on the slip sheet page.
  23. It's not an issue of the version installed on your desktop. What gets composed online in DSF is determined by the version of FusionPro Server that's installed on the DSF machine, because it's that FP Server that's doing the composition work. If version 13 is installed on DSF, then the job will be composed by FusionPro 13, regardless of what version you used to design and upload the template. My conjecture is that, at some point, the version of FP Server on the DSF machine was updated, which triggered the difference in the output. Whatever older version of FP Server that had been on DSF previously was composing differently than the FP 13 that's installed on DSF now. The way to confirm this is to look at the two different outputs from the online DSF compositions, open them both in Acrobat, and view their Document Properties, which specify the version of FusionPro used for the composition (which may be different than the version used to design the template). At any rate, reworking the job to use record repeats rather than overflow pages is probably worthwhile.
  24. You're very close. The "if" line should be: if (option != "" && !outlaw.test(option)) { //if the optional field is not blank and doesn't contain "PO Box" then add to array You created a regular expression object to test against a string for a match, but you then have to call RegExp.test, or a similar method such as String.match, to check the string against the regular expression for a match.
  25. So the file you attached was made with FP 13.0.2. I wonder if the older version of the output, when it worked differently, was made with an older version of FusionPro which had been installed on the DSF server before it was upgraded to FP 13. Regarding record repeats, it's fairly easy to do in OnRecordStart, by setting the repeat count, something like this: FusionPro.Composition.repeatRecordCount = PDFresourceRef.countPages; And you can call out the page from the PDF resource that corresponds to the repeat number in the graphic rule, like so: PDFresourceRef.pagenumber = FusionPro.Composition.repeatRecordNumber; Then you don't need any extra Overflow or Template (Repeatable Component) pages. It's really a much simpler way to build a job like this.
×
×
  • Create New...