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

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 30th, 2015, 04:21 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default OnCopyfit on Server

Does the OnCopyfit callback work differently when composing on the server (via command line) than it does when composing locally?

My OnCopyfit rule looks like this:
Code:
if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72))) {
    ReportWarning("Could not copyfit text in flow " + FusionPro.Composition.CurrentFlow.name);
}
Upon examining the .msg file after a local composition, I see the warning that I printed (in red) followed by a pretty specific log of what went wrong:
Quote:
OnCopyfit, line 2: warning: Could not copyfit text in flow headline
Word <TESTTEST> does not fit in frame after line 0.
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <headline>. Text is truncated.
Text does not fit in the last frame on page 2 at (0.31, 4.62).
When composing on the server, I only get the detailed version and anything that I put within that 'if' statement is ignored. That leads me to believe that the 'Copyfit' function always returns true when composing on the server. Could that be true? With that in mind, I tried this:
Code:
if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72))) {
    Print("doesn't fit");
}
else {
    Print("fits");
}
and got the following output when composing on the server:
Quote:
fits
Word <TESTTEST> does not fit in frame after line 0.
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <headline>. Text is truncated.
Text does not fit in the last frame on page 2 at (0.31, 4.62).
Ultimately, the reason I'm asking is because I'm trying to move that information into an XML log file to parse out later but it doesn't appear that copyfitting warnings are something that the XML log reports by default. My suspicion is that the errors that get reported in the XML log are system error codes and they'd be referenced by number. But, to me, a record failing to copyfit is an error I'm concerned about so I'd like to put it in the log like so:
Code:
if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72))){
	var warning = "Could not copyfit text in flow " + FusionPro.Composition.CurrentFlow.name;
    ReportWarning(warning);
    FusionPro.Composition.LogXMLMetadata('copyfit',warning);
}
For what it's worth, the templates are FP8.2.7 and the servers (I've tried 2 with the same results) are versions 8.2.5 and 9.3.15. Anyway, any insight or suggestions would be much appreciated!
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #2  
Old July 31st, 2015, 10:37 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,623
Default Re: OnCopyfit on Server

Quote:
Originally Posted by step View Post
Does the OnCopyfit callback work differently when composing on the server (via command line) than it does when composing locally?
No. For the same job, with the same fonts, and the same version of FusionPro, it should work the same way.
Quote:
Originally Posted by step View Post
When composing on the server, I only get the detailed version and anything that I put within that 'if' statement is ignored. That leads me to believe that the 'Copyfit' function always returns true when composing on the server. Could that be true?
No. Well, you do seem to get consistent results from this particular job, but in general, it would a major issue affecting thousands of templates in lots of applications, such as MarcomCentral, if copyfitting was just a no-op in Server.
Quote:
Originally Posted by step View Post
With that in mind, I tried this:
Code:
if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72))) {
    Print("doesn't fit");
}
else {
    Print("fits");
}
and got the following output when composing on the server:
That output looks basically the same to me. The text doesn't fit at all. Now, that said...
Quote:
Originally Posted by step View Post
For what it's worth, the templates are FP8.2.7 and the servers (I've tried 2 with the same results) are versions 8.2.5 and 9.3.15.
There may be a subtle difference in whether the Copyfit function returns true or false right away if it can't fit anything between versions 8.2 and 9.3. Our regression testing is focused on making sure that output is identical between versions, but not so much on whether all the warning messages in the log file are the same.

Or perhaps there's something different about the way the fonts are handled. You are using the Assets.dat file for the Server composition, right?

Either way, at the end of the day, both output files should look the same, and your text simply doesn't fit, and that's really all that matters, right? But it's also true that you're going to have the best results if the versions of FusionPro on your Desktop and Server machines are at least the same major version.
Quote:
Originally Posted by step View Post
Ultimately, the reason I'm asking is because I'm trying to move that information into an XML log file to parse out later but it doesn't appear that copyfitting warnings are something that the XML log reports by default.
Correct. Well, it's not just copyfitting warnings, it's anything that you write out with ReportWarning or Print. These messages appear in the main composition log (.msg) file, but not in the XML log. The only way to put custom information into the XML log is to call FusionPro.Composition.LogXMLMetadata.

Now, the ReportError function is a bit different. That still only writes to the main log file, but it does set a Medium error severity level for the record. We'll come back to that in a bit...
Quote:
Originally Posted by step View Post
My suspicion is that the errors that get reported in the XML log are system error codes and they'd be referenced by number.
No, the "status" attribute in the <summary> tags the end of the XML log is the FusionPro error code for the composition, which also gets returned from the FusionPro.exe process. These codes are listed in the "Message Codes in FusionPro" section of the "ServerFPDGuide.pdf" reference.

The "status" attribute of the <record> tag that gets reported for each record is actually an error severity level, which corresponds to the values in the "Abort on errors of this type" drop-down list on the Advanced tab of the Composition Settings dialog (where 1=Severe, 3=Medium, 5=Minor).

Speaking of which, that brings us to what it seems you're really trying to accomplish, which is to treat a record with a fitting failure as an error record:
Quote:
Originally Posted by step View Post
But, to me, a record failing to copyfit is an error I'm concerned about
Sure. But it seems to me that what you're really concerned about isn't so much that a text flow failed to copyfit, but the more general condition that a text flow failed to fit, right? In other words, I think the error you're really concerned about is "The amount of text inserted into a flow exceeds the depth of all frames in the flow <headline>. Text is truncated." (That's a "Medium", or "3" error.)

And you want to fail the record in that case, right? That can be done with that "Abort on errors of this type" drop-down, and the other drop-down right below it. Set the first drop-down to "Minor" or "Medium", and the other to "Skip the record with error." Then you don't really need to log any specific message to the XML file like this to know that the record was bad:
Quote:
Originally Posted by step View Post
so I'd like to put it in the log like so:
Code:
if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72))){
	var warning = "Could not copyfit text in flow " + FusionPro.Composition.CurrentFlow.name;
    ReportWarning(warning);
    FusionPro.Composition.LogXMLMetadata('copyfit',warning);
}
Because if the record fails, you'll see that "status" attribute set to something other than zero. That's what you can key off of when you parse the XML log.

You can still write the metadata to the XML log if you want to, but it's already designed to do what you want, with those error-handling settings on the Advanced tab.

However, as I mentioned earlier, the ReportError function, while still not writing its message to the XML log, does set an error level for the record. So if you call that, it will set the error level to Medium, which will also cause the record to abort if you have it set to do so.

The other thing you can do, in FusionPro 9.2 or later, is call FusionPro.Composition.Abort. This takes three parameters, all optional:
  • errorMessage (string): The custom error message.
  • recordOnly (true/false): True to skip the record, false to abort the whole the composition (just like that second drop-down). Defaults to false.
  • errorCode (number): A custom error code, which either becomes the status for the record, or the return code for the composition, based on the "recordOnly" flag. Defaults to 1042 if not specified.
So, you can set that third parameter to whatever number you want, and that number will become the "status" code, for either the record or the composition, in your XML log file. You could even have multiple places to check for errors in your JavaScript rules, where each one calls FusionPro.Composition.Abort with your own custom error code, then the process that parses the XML log can use those error codes to determine what the failure mode was, instead of having to parse textual messages. That's a much more reliable way to handle errors in an automated system.

Note also that, if any records are skipped/aborted with an error, either via the error level from the Advanced tab or with a call to FusionPro.Composition.Abort, FusionPro also creates a "bad record" file (with the same name as the output file, but with "-bad" and the input file extension at the end) to contain all the records which failed. (The idea here is that you can easily see which records were bad, or even re-compose the job again with just those records and their data.)

So you should be able to use one of more of these strategies for "bad" record handling, without having to write a custom message to either log file.

That all said, if you want to collect up the job and post it, I can take a look and see why copyfitting isn't working as expected.
__________________
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 July 31st, 2015, 04:16 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: OnCopyfit on Server

Thanks for the reply, Dan.
Quote:
Originally Posted by Dan Korn View Post
No. Well, you do seem to get consistent results from this particular job, but in general, it would a major issue affecting thousands of templates in lots of applications, such as MarcomCentral, if copyfitting was just a no-op in Server.
Well yeah, I wasn't saying it doesn't work in Server – it obviously does. I was just saying that it seemed like the way the "Copyfit" function validated on the Server might be different. I guess the way I rationalized that to myself was: "Well, it's not like it doesn't say the text didn't fit. It just doesn't print the error because I'm not watching the composition run from the dialog box on my desktop."
Quote:
Originally Posted by Dan Korn View Post
That output looks basically the same to me.
What? It printed "fits" right above the message telling me it doesn't fit. So, that made me think it always validated as true on the Server.

Quote:
Originally Posted by Dan Korn View Post
Or perhaps there's something different about the way the fonts are handled. You are using the Assets.dat file for the Server composition, right?
I created an Assets.dat file when I collected my template and it's in the same directory as my template, but I have not specifically called it from the command line if that's what you're asking. I'm running the file like this:
Code:
C:
CD C:\Program Files (x86)\PTI\FusionPro\
FusionPro "\\server\path\to\templates\test\data.csv" "\\server\path\to\templates\test\test.dif" "\\server\path\to\templates\test\test-o.cfg" "\\server\path\to\templates\test\output.pdf"
Quote:
Originally Posted by Dan Korn View Post
The "status" attribute of the <record> tag that gets reported for each record is actually an error severity level, which corresponds to the values in the "Abort on errors of this type" drop-down list on the Advanced tab of the Composition Settings dialog (where 1=Severe, 3=Medium, 5=Minor).
That's how I was hoping that worked.
Quote:
Originally Posted by Dan Korn View Post
But it seems to me that what you're really concerned about isn't so much that a text flow failed to copyfit, but the more general condition that a text flow failed to fit, right? In other words, I think the error you're really concerned about is "The amount of text inserted into a flow exceeds the depth of all frames in the flow <headline>. Text is truncated." (That's a "Medium", or "3" error.)
Can you give an example of a "severe" error? If a "medium" error is something reported by "ReportError," is it correct to assume that a minor error is something reported with "ReportWarning?" And with that assumption in mind, does that mean that "medium" and "minor" errors can only be generated if I were to physically call them from code or can FP also throw those?

Quote:
Originally Posted by Dan Korn View Post
And you want to fail the record in that case, right? That can be done with that "Abort on errors of this type" drop-down, and the other drop-down right below it. Set the first drop-down to "Minor" or "Medium", and the other to "Skip the record with error." Then you don't really need to log any specific message to the XML file like this to know that the record was bad:

Because if the record fails, you'll see that "status" attribute set to something other than zero. That's what you can key off of when you parse the XML log.
That's precisely it except I'm not sure I want to fail the record as much as I want to be prompted to check the log and find out what didn't copyfit. There are some cases where the truncated text isn't necessary and I don't want to have to re-run the entire job in an instance like that.

Quote:
Originally Posted by Dan Korn View Post
The other thing you can do, in FusionPro 9.2 or later, is call FusionPro.Composition.Abort. This takes three parameters, all optional:
  • errorMessage (string): The custom error message.
  • recordOnly (true/false): True to skip the record, false to abort the whole the composition (just like that second drop-down). Defaults to false.
  • errorCode (number): A custom error code, which either becomes the status for the record, or the return code for the composition, based on the "recordOnly" flag. Defaults to 1042 if not specified.
So, you can set that third parameter to whatever number you want, and that number will become the "status" code, for either the record or the composition, in your XML log file. You could even have multiple places to check for errors in your JavaScript rules, where each one calls FusionPro.Composition.Abort with your own custom error code, then the process that parses the XML log can use those error codes to determine what the failure mode was, instead of having to parse textual messages. That's a much more reliable way to handle errors in an automated system.
That sounds neat. I definitely like the ability to add custom error codes that seems very helpful I just want to do so without skipping the record or aborting the job.

Quote:
Originally Posted by Dan Korn View Post
Note also that, if any records are skipped/aborted with an error, either via the error level from the Advanced tab or with a call to FusionPro.Composition.Abort, FusionPro also creates a "bad record" file (with the same name as the output file, but with "-bad" and the input file extension at the end) to contain all the records which failed. (The idea here is that you can easily see which records were bad, or even re-compose the job again with just those records and their data.)
That's a good idea too but a lot of our jobs (this one in particular) is pre-sorted. So if a record(s) get deemed as "bad" it would become a headache for our kitting department.

Anyway, again, thanks for the feedback and the ideas. I have been working on a test file to upload to the forum (the actual file is very large and contains a bunch of customer sensitive data that I don't feel comfortable uploading) but I haven't been able to reproduce the problem. Which...I guess is good? Now I just have to figure out what it is about my actual template that's different from my testing one.
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #4  
Old August 3rd, 2015, 09:56 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,623
Default Re: OnCopyfit on Server

Quote:
Originally Posted by step View Post
Well yeah, I wasn't saying it doesn't work in Server – it obviously does. I was just saying that it seemed like the way the "Copyfit" function validated on the Server might be different.
With computers, it's always more relevant to say that something works "differently" than it is to so that something "worked" or not. But still, if it worked differently like that between Desktop and Server for most jobs, we would have heard about it.
Quote:
Originally Posted by step View Post
I guess the way I rationalized that to myself was: "Well, it's not like it doesn't say the text didn't fit. It just doesn't print the error because I'm not watching the composition run from the dialog box on my desktop."
Of course there's no Composition Status dialog for a Server composition (though Server will write to the Command Prompt window). But the log file should be basically the same.
Quote:
Originally Posted by step View Post
What? It printed "fits" right above the message telling me it doesn't fit. So, that made me think it always validated as true on the Server.
Obviously it doesn't always validate as true, at least not with all templates. But I was saying that it looked basically the same because you still got the message from the composition engine about the line not fitting.
Quote:
Originally Posted by step View Post
I created an Assets.dat file when I collected my template and it's in the same directory as my template, but I have not specifically called it from the command line if that's what you're asking
No, I meant it should just be in the same folder. It seems that it's not a font issue.
Quote:
Originally Posted by step View Post
Can you give an example of a "severe" error?
Sure. Some examples are: failed to open the input data file, or the format (DIF) file, or the CFG file; failed to write the output file; missing a graphic resource; and other various problems with malformed or missing files or resources.
Quote:
Originally Posted by step View Post
If a "medium" error is something reported by "ReportError," is it correct to assume that a minor error is something reported with "ReportWarning?"
No. ReportWarning doesn't raise an error status.
Quote:
Originally Posted by step View Post
And with that assumption in mind, does that mean that "medium" and "minor" errors can only be generated if I were to physically call them from code
No.
Quote:
Originally Posted by step View Post
or can FP also throw those?
Yes. Most of the errors are "internal" and come from FusionPro itself.
Quote:
Originally Posted by step View Post
That's precisely it except I'm not sure I want to fail the record as much as I want to be prompted to check the log and find out what didn't copyfit. There are some cases where the truncated text isn't necessary and I don't want to have to re-run the entire job in an instance like that.
That sounds like something that could be automated, so that you don't need that manual step.
Quote:
Originally Posted by step View Post
That sounds neat. I definitely like the ability to add custom error codes that seems very helpful I just want to do so without skipping the record or aborting the job.
I'm not sure what a custom error code means, if there's no actual error state for the either the record or the job. But still, if you just want to add a note to the log file, it's still probably better to add it as metadata to the XML log than to add "plain" text to the .msg file.
Quote:
Originally Posted by step View Post
That's a good idea too but a lot of our jobs (this one in particular) is pre-sorted. So if a record(s) get deemed as "bad" it would become a headache for our kitting department.
It's my understanding that the concept of "bad" records which need to be reprinted for one reason or another, and that there's a separate "exception" workflow to handle them, even with presorted data, is a standard one in the printing industry.
Quote:
Originally Posted by step View Post
Anyway, again, thanks for the feedback and the ideas. I have been working on a test file to upload to the forum (the actual file is very large and contains a bunch of customer sensitive data that I don't feel comfortable uploading) but I haven't been able to reproduce the problem. Which...I guess is good? Now I just have to figure out what it is about my actual template that's different from my testing one.
That is the $64,000 question. Give me something to reproduce and I'll definitely analyze it.
__________________
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
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 05:57 AM.


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