Combining Exportprintpreviewtoimage And Namedsubstring Does Not Give Any Result 追蹤

0
Avatar
Legacy Poster

Hello, 

 

I have been trying the example of a print to image and everything works fine:

<?xml version="1.0" encoding="utf-8"?>
<XMLScript Version="2.0">
 <Command Name="Job1">

<ExportPrintPreviewToImage ReturnImageInResponse="true"> 
<Format CloseAtEndOfJob="true">D:\Formats\pd02.btw</Format>
<Folder>D:\BTXML\</Folder> 
<FileNameTemplate>Preview_Label%PageNumber%.jpg</FileNameTemplate> 
<ImageFormatType>JPG</ImageFormatType> 
<Colors>btColors24Bit</Colors> 
<DPI>300</DPI> 
<Overwrite>true</Overwrite> 
<IncludeMargins>true</IncludeMargins> 
<IncludeBorder>true</IncludeBorder> 
<BackgroundColor>16777215</BackgroundColor> 
</ExportPrintPreviewToImage> 

</Command>

</XMLScript> 
 

My problem comes when I try to combine the print to image feature and NamedSubString: this label print to image but without the customised field.

 

In other words, this second batch of code does not provide any difference with previous one!

 

<?xml version="1.0" encoding="utf-8"?>
<XMLScript Version="2.0">
 <Command Name="Job1">

<ExportPrintPreviewToImage ReturnImageInResponse="true"> 
<Format CloseAtEndOfJob="true">D:\Formats\pd02.btw</Format>
<Folder>D:\BTXML\</Folder> 
<FileNameTemplate>Preview_Label%PageNumber%.jpg</FileNameTemplate> 
<ImageFormatType>JPG</ImageFormatType> 
<Colors>btColors24Bit</Colors> 
<DPI>300</DPI> 
<Overwrite>true</Overwrite> 
<IncludeMargins>true</IncludeMargins> 
<IncludeBorder>true</IncludeBorder> 
<BackgroundColor>16777215</BackgroundColor> 
</ExportPrintPreviewToImage> 

<Print>
<NamedSubString Name="V19">
<Value>Test CVE</Value>
</NamedSubString>
</Print>

</Command>

</XMLScript> 

 

 

4 意見

0
Avatar
Ian Einman
評論操作 永久連結

The "Print" command is intended to actually print a label.  If you are merely trying to set the named substrings, you should try using the <FormatSetup> command instead.  Additionally, that should really come before the <ExportPrintPreviewToImage> command otherwise the preview will be exported prior to the substring values being changed.

 

<?xml version="1.0" encoding="utf-8"?>
<XMLScript Version="2.0">
 <Command Name="Job1">

<FormatSetup>
<Format>D:\Formats\pd02.btw</Format>
<NamedSubString Name="V19">
<Value>Test CVE</Value>
</NamedSubString>
</FormatSetup>

<ExportPrintPreviewToImage ReturnImageInResponse="true"> 
<Folder>D:\BTXML\</Folder> 
<FileNameTemplate>Preview_Label%PageNumber%.jpg</FileNameTemplate> 
<ImageFormatType>JPG</ImageFormatType> 
<Colors>btColors24Bit</Colors> 
<DPI>300</DPI> 
<Overwrite>true</Overwrite> 
<IncludeMargins>true</IncludeMargins> 
<IncludeBorder>true</IncludeBorder> 
<BackgroundColor>16777215</BackgroundColor> 
</ExportPrintPreviewToImage> 

</Command>

</XMLScript> 

 

So now loading it and setting the named substrings happens in the first command, and then it is exported.  Try this.

0
Avatar
Legacy Poster
評論操作 永久連結

Hello Ian,

 

Thank a lot for your answer.

 

Unfortunately, it seems that there are a few issues with your answer..

 

As soon as I remove <Format CloseAtEndOfJob="true">D:\Formats\pd02.btw</Format> from the enclosing ExportPrintPreviewToImage tags, no jpeg file is created.

 

So, the code below is creating a jpg file, while the one you gave me prints nothing:

 

Note that text in label is still the default one and NamedSubString has no effect.

<?xml version="1.0" encoding="utf-8"?>
<XMLScript Version="2.0">
<Command Name="Job1">
<FormatSetup>
<Format CloseAtEndOfJob="true">D:\Formats\pd02.btw</Format>
<NamedSubString Name="V19">
<Value>Test CVE</Value>
</NamedSubString>
</FormatSetup>
<ExportPrintPreviewToImage ReturnImageInResponse="true"> 
<Format CloseAtEndOfJob="true">D:\Formats\pd02.btw</Format>
<Folder>D:\BTXML\</Folder> 
<FileNameTemplate>Preview_Label%PageNumber%.jpg</FileNameTemplate> 
<ImageFormatType>JPG</ImageFormatType> 
<Colors>btColors24Bit</Colors> 
<DPI>300</DPI> 
<Overwrite>true</Overwrite> 
<IncludeMargins>true</IncludeMargins> 
<IncludeBorder>true</IncludeBorder> 
<BackgroundColor>16777215</BackgroundColor> 
</ExportPrintPreviewToImage> 


</Command>


</XMLScript>
 
0
Avatar
Ian Einman
評論操作 永久連結

Sorry, there was still a problem with it.  Go back to my original sample, but note I have removed "CloseAtEndOfJob" from the Format tag.  The name of that tag is misleading, it doesn't close at the end of the "job" but actually at the end of the command, so it was closing the format as soon as it hits the </FormatSetup> tag (that's why the following <Print> command didn't work).

 

Because the change is not saved, if you close the document in <FormatSetup> and then specify the <Format> tag again in <ExportPrintPreviewToImage> it closes and reopens the document so your change did not take effect.  I've verified that the revised sample does work so if it still seems to not take effect we might have to look at other causes like the substring names not matching up.

0
Avatar
Legacy Poster
評論操作 永久連結

Thank a lot for your help!

 

Working fine now.

登入寫評論。