Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > FusionPro® VDP Creator

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 9th, 2019, 12:50 PM
ScottHillock ScottHillock is offline
Regular Contributor
 
Join Date: Mar 2010
Posts: 92
Default Replacing all text occurrences

I'm looking to create a rule that will replace all occurrences of a string of text, even when that text is not part of a rule.

Specifically we're having an issue where the notdef symbol is being inserted when some fonts don't have the   character. I'd like to replace the font for this character to one which does have the   glyph defined.

I know how to make this change when the text is returned from a rule. I'm just looking for the FusionPro way of searching through all text frames and replacing characters.
Reply With Quote
  #2  
Old April 16th, 2019, 03:58 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,381
Default Re: Replacing all text occurrences

FusionPro VDP 10.1 has a cool new text replacement feature, which does exactly what you want: globally replace all occurrences of any text in the job.

You can even do this without writing any JavaScript code, with the new "Global Replace Text" XML Template callback rule.

However, in this, case, since the text you're replacing is the "special" non-breaking space character, you do have to use JavaScript, but handling that character is easy enough with the RawTextFromTagged function.

So, in FusionPro 10.1, you can do this in OnJobStart, replacing the font name with whatever font you want:
Code:
FusionPro.Composition.AddTextReplacement(RawTextFromTagged("&nbsp;"), '<span font="Times New Roman">&nbsp;</span>');
That said, I suspect this is all a bit of an "XY problem," where what you're really trying to do is accomplish non-breaking text, and you're doing this by inserting &nbsp; entities. But there's a better way to accomplish non-breaking text, or what we prefer to call a "horizontal keep," in FusionPro 10.1, with <hkeep> and </hkeep> tags.

(And really, the font shouldn't be trying to output an &nbsp; character anyway; there's no glyph to draw for white space. That's part of why we have the <hkeep> tag now.)

It's not clear to me exactly what you're doing with the &nbsp; entities, nor how you're inserting them, but you should be able to rework whatever logic you have that's relying on the &nbsp; entities to use the tags instead.

If you have just a particular phrase that you want to never break in your job, you can use another handy XML Template callback rule, "Format Specific Word or Phrase", and simply check the "Don't break or hyphenate" box (which inserts <hkeep> and </hkeep> tags).

If you are doing something more complicated with programmatically inserting &nbsp; tags in a rule, then you will have to modify that rule to use the tags instead. For instance, where previously you would have markup like this:
Code:
return "Never&nbsp;break&nbsp;this&nbsp;text";
You can now do this:
Code:
return "<hkeep>Never break this text</hkeep>";
The bottom line is, with FusionPro 10.1, in my opinion, the real solution is to use <hkeep> and </hkeep> tags instead of &nbsp; in the first place.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old April 16th, 2019, 04:03 PM
ScottHillock ScottHillock is offline
Regular Contributor
 
Join Date: Mar 2010
Posts: 92
Default Re: Replacing all text occurrences

Excellent Dan, thank you. I'll keep in mind the <hkeep> tags when I need them.

The &nbsp; character accidentally shows up sometimes in FusionPro text frames when the InDesign source document has returns with a normal space on an empty line. So ^p ^p ends up turning into ^p&nbsp;^p.

I have a few InDesign scripts to clean things up for FusionPro but on some documents we can't run the scripts, so I was looking for an automated solution to fix the notdef character from basically ever showing up in a document with a &nbsp; character.
__________________
FusionPro 9.3.36 - Acrobat 11 - macOS 10.14

Last edited by ScottHillock; April 16th, 2019 at 04:07 PM..
Reply With Quote
  #4  
Old April 16th, 2019, 04:18 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,381
Default Re: Replacing all text occurrences

Quote:
Originally Posted by ScottHillock View Post
Excellent Dan, thank you. I'll keep in mind the <hkeep> tags when I need them.
Okay. Though your signature says you're still running FusionPro 9.3. Everything I mentioned requires 10.1 or later.
Quote:
Originally Posted by ScottHillock View Post
The &nbsp; character accidentally shows up sometimes in FusionPro text frames when the InDesign source document has returns with a normal space on an empty line. So ^p ^p ends up turning into ^p&nbsp;^p.
I'd love to take a look at one of these InDesign documents.
Quote:
Originally Posted by ScottHillock View Post
I have a few InDesign scripts to clean things up for FusionPro but on some documents we can't run the scripts, so I was looking for an automated solution to fix the notdef character from basically ever showing up in a document with a &nbsp; character.
Well, I think the code I posted with the call to FusionPro.Composition.AddTextReplacement would work. But I can't really try it without one of your InDesign files.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #5  
Old April 16th, 2019, 04:45 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,381
Default Re: Replacing all text occurrences

Also, you might be able to get the &nbsp; to work with your font by simply unchecking the "Limit to Latin-1" or "Limit to Mac Roman" box, as Steve Davenport notes here:
http://forums.pti.com/showthread.php?t=5328
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #6  
Old April 17th, 2019, 10:02 AM
ScottHillock ScottHillock is offline
Regular Contributor
 
Join Date: Mar 2010
Posts: 92
Default Re: Replacing all text occurrences

Dan, sample files attached.

Unchecking the Limit processing to.. checkbox does make the notdef character not appear. And it's a viable solution. But, I usually leave that checked to make sure the data source doesn't contain characters that might cause issues on output. But, I should probably move that "checking" to a different workflow process.

We do have FusionPro 9, so the <hkeep> and AddTextReplacement aren't available to us to use yet, but we're looking at the upgrade to 10 in the near future.
Attached Files
File Type: zip Archive.zip (534.7 KB, 2 views)
__________________
FusionPro 9.3.36 - Acrobat 11 - macOS 10.14
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:49 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.