Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 31st, 2016, 08:33 AM
EricC EricC is offline
Regular Contributor
 
Join Date: Nov 2008
Posts: 87
Arrow Location of Email field based on CopyFit

I have a business card with two text boxes: TextBoxLeft and TextBoxRight.

TextBoxLeft contains the following fields/rules:
- Name
- Title 1
- Title 2
- Title 3
- Email Address

TextBoxRight contains the following fields/rules:
- Address Line 1
- Address Line 2
- City, State Zip Code
- Phone Number
- Fax Number
- Website

Regarding TextBoxLeft ... sometimes the titles are so long that the Email Address gets truncated (even with CopyFit).

So I want to write a rule that does this:
- If all of the text in TextBoxLeft does not fit
Move the Email Address field to TextBoxRight
- Otherwise, Email Address remains in TextBoxLeft
__________________
--
Eric Carbone
IT/Project Manager, MOR Printing Inc.

Windows 10 |Adobe Acrobat XI | FusionPro 9
Reply With Quote
  #2  
Old March 31st, 2016, 01:06 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,322
Default Re: Location of Email field based on CopyFit

It's hard to say without seeing the job, but you can probably accomplish what you want by connecting the two text frames into a single flow. Make the first box just big enough to hold the email address if it's one one line, then it will flow to the other box if it doesn't fit. Make sure to turn off hyphenation for the paragraph containing the email address (actually, you probably want it off for every paragraph in this case). You can tweak the results a bit if you replace the hard returns between lines with soft returns (by typing Ctrl-Enter instead of just Enter) and adjusting the Widows setting for the single paragraph.

For a more specific answer, I would need to see the job, or at the very least know what kind of copyfitting you're doing. Are you using full-flow copyfitting, by checking the "Adjust text to fit" box in the Overflow Options dialog? Or are you using per-line copyfitting, by calling CopyfitLine or a similar function?
__________________
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 March 31st, 2016, 01:21 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,322
Default Re: Location of Email field based on CopyFit

If you're doing full-flow copyfitting, you can do some tricks in the OnCopyfit callback rule. For instance, you can have the text completely move to another frame if it doesn't fit, like so:
Code:
if (FusionPro.Composition.CurrentFlow.name == "TextBoxLeft")
{
  if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72)))
  {
    ReportWarning("Could not copyfit text in flow " + 
                  FusionPro.Composition.CurrentFlow.name);
    FusionPro.Composition.CurrentFlow.content = "";
    FindTextFrame("TextBoxRight").content = FusionPro.Composition.CurrentFlow.originalContent;
  }
}
For your specific requirements, there are several things you could do. Without having to mess around with parsing tags and such, I think you can do this: Set up two completely separate sets of two frames each, one with the two frames in the nominal layout (with the email in the left frame), and another with the two frames in the alternate layout (with the email in the right frame). So four frames total, named something like TextBoxLeft, TextBoxRight, TextBoxLeftAlt, and TextBoxRightAlt. Set the two alternate frames to be suppressed in OnRecordStart:
Code:
FindTextFrame("TextBoxLeftAlt").suppress = true;
FindTextFrame("TextBoxRightAlt").suppress = true;
Then in OnCopyfit, if things don't fit, suppress the nominal frames and show the alternate ones:
Code:
if (FusionPro.Composition.CurrentFlow.name == "TextBoxLeft")
{
  if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72)))
  {
    ReportWarning("Could not copyfit text in flow " + 
                  FusionPro.Composition.CurrentFlow.name);

    FindTextFrame("TextBoxLeft").suppress = true;
    FindTextFrame("TextBoxRight").suppress = true;
    FindTextFrame("TextBoxLeftAlt").suppress = false;
    FindTextFrame("TextBoxRightAlt").suppress = false;
  }
}
__________________
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
  #4  
Old March 31st, 2016, 02:03 PM
EricC EricC is offline
Regular Contributor
 
Join Date: Nov 2008
Posts: 87
Default Re: Location of Email field based on CopyFit

Hi Dan,

I like your first idea - moving all of the text from the left frame to the right frame. However in my scenario, I only want to move one FIELD (Email Address) from the left text frame to the right text frame.

So, I tried out your second idea:

1. Create 2 left text boxes and 2 right text boxes

2. OnRecordStart, suppress TextBoxLeftAlt and the TextBoxRightAlt

3. OnCopyfit, if things don't fit in TextBoxLeft, suppress the nominal frames and show the alternate ones

I am pretty sure I did this correctly, but when I preview the template in Acrobat, I see the content in all 4 frames.

The TextBoxLeft text box has the solid red line at the bottom (the visual indicator that the text is not fitting), so I would have expected the two nominal boxes to be suppressed. But they're not.

Any ideas?
__________________
--
Eric Carbone
IT/Project Manager, MOR Printing Inc.

Windows 10 |Adobe Acrobat XI | FusionPro 9
Reply With Quote
  #5  
Old March 31st, 2016, 02:20 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,322
Default Re: Location of Email field based on CopyFit

Quote:
Originally Posted by EricC View Post
I am pretty sure I did this correctly, but when I preview the template in Acrobat, I see the content in all 4 frames.

The TextBoxLeft text box has the solid red line at the bottom (the visual indicator that the text is not fitting), so I would have expected the two nominal boxes to be suppressed. But they're not.

Any ideas?
Run a regular composition instead of a preview and see what warning or error messages it has.

You may need to modify the OnCopyfit rule to this:
Code:
if (FusionPro.Composition.CurrentFlow.name == "TextBoxLeft")
{
  if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72)))
  {
    ReportWarning("Could not copyfit text in flow " + 
                  FusionPro.Composition.CurrentFlow.name);

    FusionPro.Composition.CurrentFlow.content = "";
    FindTextFrame("TextBoxRight").suppress = true;
    FindTextFrame("TextBoxLeftAlt").suppress = false;
    FindTextFrame("TextBoxRightAlt").suppress = false;
  }
}
This works for me in a test job. I can post it here if you want.
__________________
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 March 31st, 2016, 02:29 PM
EricC EricC is offline
Regular Contributor
 
Join Date: Nov 2008
Posts: 87
Default Re: Location of Email field based on CopyFit

Hi Dan,
Thanks for the quick reply.

The error log says:

Code:
Job started 17:02:06 - 1459458126.
Creator: FusionPro(TM) VDP Designer 9.3.21

Composing record #1, input record 6
OnCopyfit, line 6: warning: Could not copyfit text in flow TextBoxLeft
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <TextBoxLeft>.  Text is truncated.
Text does not fit in the last frame on page 1 at (0.22, 0.72).
Job ended 17:02:07 - 1459458127.
Total Job Time: 1s
Using your modified code, it made the content of TextBoxLeft disappear, but the content of TextBoxRight also needs to disappear.
__________________
--
Eric Carbone
IT/Project Manager, MOR Printing Inc.

Windows 10 |Adobe Acrobat XI | FusionPro 9
Reply With Quote
  #7  
Old March 31st, 2016, 02:59 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,322
Default Re: Location of Email field based on CopyFit

Quote:
Originally Posted by EricC View Post
Using your modified code, it made the content of TextBoxLeft disappear, but the content of TextBoxRight also needs to disappear.
Hmm, I'm not sure why that's not working for you. It might have to do with the order in which the frames are processed.

You could try to just set the contents of the right frame to nothing instead of suppressing it:
Code:
FindTextFrame("TextBoxRight").content = "";
The other thing you can do, if the "alt" frames are showing and suppressing properly, and if your template has a white background, is set those "alt" frame to fill with White. Then they'll just cover up the other frames.

There are other possible solutions as well.

Anyway, I've attached a sample job which seems to do what you want. Place it in the Cellphone Tutorial folder and compare the preview of records 1 and 2.
Attached Files
File Type: pdf cellphone-EricC-copyfit.pdf (2.59 MB, 10 views)
__________________
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
  #8  
Old March 31st, 2016, 03:10 PM
EricC EricC is offline
Regular Contributor
 
Join Date: Nov 2008
Posts: 87
Default Re: Location of Email field based on CopyFit

I tried
Code:
FindTextFrame("TextBoxRight").content = "";
and it still shows the contents of TextBoxRight.

I can't figure it out and I've been at it off and on all day today. I'll try again some more tomorrow. Thanks for your help Dan.
__________________
--
Eric Carbone
IT/Project Manager, MOR Printing Inc.

Windows 10 |Adobe Acrobat XI | FusionPro 9
Reply With Quote
  #9  
Old April 1st, 2016, 01:52 PM
EricC EricC is offline
Regular Contributor
 
Join Date: Nov 2008
Posts: 87
Default Re: Location of Email field based on CopyFit

Dan,
I deleted all of the text boxes, recreated them and now the rule is working. Thanks a ton for your help!
__________________
--
Eric Carbone
IT/Project Manager, MOR Printing Inc.

Windows 10 |Adobe Acrobat XI | FusionPro 9
Reply With Quote
Reply

Tags
copyfit, onrecordstart, textbox measure

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 06:32 PM.


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