Bartender Trial Sdk Not Generating Barcodes In Pdf Files Correctly.
Hello,
I am trying to print the barcodes into a PDF file using Enterprise automation trial version with C# Asp.net. If this succeeded I would like to buy that version.
Can you help me for the code? I have already gone through the samples available. The code below SUCCESSFULLY generates the PDF file at the given location but when I try to open it, it return error message “it is either not a supported file type or because the file has been damaged. I have installed and used PDF drivers like (PDFCreator, BULLZIP, DOPDF) for printing into PDF (not on actual printer). I have tried with all these three known pdf drivers but still, generated PDF seems corrupt because its not opening.
protected void Button1_Click(object sender, EventArgs e)
{
BarTenderPrintClient.Printer printClient = new BarTenderPrintClient.Printer();
// Create a new print to file license key
string printLicense = null;
bool success;
success = printClient.CreatePrintToFileLicense("PDFCreator", out printLicense);
if (success)
{
Engine btEngine = new Engine();
// Start a BarTender print engine
btEngine.Start();
// Open a label format
LabelFormatDocument btFormat = btEngine.Documents.Open(@"C:\Users\Admin\Desktop\Labels\LBSC.btw");
// Set the TextFile database connection file name
((TextFile)btFormat.DatabaseConnections[0]).FileName = @"C:\Users\Admin\Desktop\Labels\FIMS055.txt";
//Assign printer name
btFormat.PrintSetup.PrinterName = "PDFCreator";
//// Set the print license
btFormat.PrintSetup.PrintToFileLicense = printLicense;
//// Set print to file to true
btFormat.PrintSetup.PrintToFile = true;
//// Specify the name of the output file
btFormat.PrintSetup.PrintToFileName = @"C:\Users\khanm6\Desktop\Labels\PrintFile.pdf";
// Print the label format document
Result result = btFormat.Print();
// Stop the engine
btEngine.Stop();
}
}
Please Help!
-
The PrintToFile() method you're trying to make use of via automation can only be used for web printing purposes (Internet Printing) using our "Enterprise Automation Edition of BarTender". This function will not work unless a "PrintToFileLicense" property value has been obtained via the License Server. This is so we can still keep control of the printers being used by the BarTender process. Currently only the BarTender Enterprise Automation Edition is able to use the PrintToFile() method via automation. The print job which will be sent back from the server part of your web based application to the client side is encrypted.
You cannot use the PrintToFile() method for what you're trying to achieve. In the past we had seen that some customer’s were trying to make an abusive use of the “PrintToFile()” method while automating BarTender via a front-end application, so this is why we've disabled it for this use.
If you want to generate a PDF out of a BarTender document via Automation, try configuring the PDF printer driver so that it makes a PDF file when you use the Print() method. Normally, the PDF printer driver will show an interactive dialog of some kind, but this is configurable (please notice that some PDF printer drivers have a server and client installation, so you would probably need to choose the server installation).
Another option you could make use of to generate the PDF is to use BarTender XMLScript within your .NET SDK application. Do this by making use of the <ImageFormatType> property in the <ExportPrintPreviewToImage> BTXML tag. Although we natively don't support PDF for this property, you can tweak this to export to PDF. Do this by opening the "C:\Program Files (x86)\Seagull\BarTender Suite\btxmlscript_base_2.0.xsd" file and find the section that says "<!-- ImageFormatExportType enumeration type -->". Add a line that says "<xs:pattern value="[Pp][Nn][Gg]" />"
Hope this helps.
0 -
Legacy Poster
★ BarTender Hero ★
Thank You Domingo!
I have tried configuring PDF printers to auto save the files at particualr location. Then there are page settings that i have tried.
And I have tred it removing below lines from above code:
success = printClient.CreatePrintToFileLicense("PDFCreator", out printLicense);
btFormat.PrintSetup.PrintToFileLicense = printLicense;
but no luck yet! I am checking is there any PDF printer server version available?
Can you bring some light on this. some kind of solution example. I am sure this is something not a new requirement. Somebody must have already done this. Please help. I am searching for the solution since long time and i keep visiting this page everyday hoping someday someone would respond with exact solution what i need.
0 -
- You mention "I have tried configuring PDF printers to auto save the files at particular location" and "I have tried it removing below lines from above code". Once applying these 2 changes, are the PDF files being automatically generated in the first place? Or you see no PDF files at all?
- What about the second option I gave you, exporting the BT document / Print preview to PDF?
- What is the purpose of generating PDF files via automation? Why would you not directly print the print job to the printers? Could you offer some detailled information as to why this is required?
0 -
Legacy Poster
★ BarTender Hero ★
Hi Domingo,
1. I see the PDFs are generating at the location given in the above code like below. But it is not opening up (returning error). The only difference i can notice is the size of these auto generated PDFs are big compared to the PDF that i generate manually with BTW. Other thing is - If i remove the below line of code, PDFs are not generating at all. So that means even if i define the auto-save location in PDF driver settings, bartender print function is not directing it correctly. How can link that?
btFormat.PrintSetup.PrintToFileName = @"C:\Users\khanm6\Desktop\Labels\PrintFile.pdf";
2. Please provide me some kind of working example for 2nd option. I am not aware of this.
3. We need to provide these PDF files with barcodes to our users. So there's no requirement to print on windows printers. Requirement is just to print into PDF.
0 -
Legacy Poster
★ BarTender Hero ★
On 3rd Point: Requirement
We want to put a web page on our primary website, which has the details to select, required for generating barcodes in PDF format.
So user will come to that website and should be able to select the details and generate the barcodes as their convinience.
Currently they are sending the request to us with the details on email and we are generating the barcodes manually with bartender professional version that we have. and send the generated PDF file to them back on that email. So we want to eliminate this process and make a website, host it on our server so they can do it at their own on just a few clicks.
0 -
After looking at your latest post, it now looks to me that you're wishing to develop a web based application, where an operator opens the web based application on the client side, chooses a BarTender document and then wishes to export this document to a PDF file, and finally present the PDF document in your web browser? Is that how you would like things to work?
Please note that Seagull already has a closed web based solution which supports PDF printing. The only requirement is that you install Adobe Acrobat Distiller or the Adobe PDF Converter printer driver at the server side. This closed application is called BarTender Web Print Server: http://www.bartenderbarcodesoftware.com/label-software/whitepapers/Web-based-Barcode-and-Label-Printing.pdf
You could develop a very similar solution using our .NET Print Server SDK and using any PDF printer driver, but unfortunately we don't have any example on how this could be done. We have an example called "WebLabelPrint" which you'll find under the following Windows folder "C:\Program Files (x86)\Seagull\BarTender Suite\SDK\Print Server SDK Samples\WebLabelPrint", but this sample lacks the needed code for generating PDF printing. You would need to add the necessary code for doing Internet Printing, and then display the resulting PDF in the web browser.
Sorry, but I don't think I will be able to further assist you in this.
0 -
Legacy Poster
★ BarTender Hero ★
After looking at your latest post, it now looks to me that you're wishing to develop a web based application, where an operator opens the web based application on the client side, chooses a BarTender document and then wishes to export this document to a PDF file, and finally present the PDF document in your web browser? Is that how you would like things to work?
Please note that Seagull already has a closed web based solution which supports PDF printing. The only requirement is that you install Adobe Acrobat Distiller or the Adobe PDF Converter printer driver at the server side. This closed application is called BarTender Web Print Server: http://www.bartenderbarcodesoftware.com/label-software/whitepapers/Web-based-Barcode-and-Label-Printing.pdf
You could develop a very similar solution using our .NET Print Server SDK and using any PDF printer driver, but unfortunately we don't have any example on how this could be done. We have an example called "WebLabelPrint" which you'll find under the following Windows folder "C:\Program Files (x86)\Seagull\BarTender Suite\SDK\Print Server SDK Samples\WebLabelPrint", but this sample lacks the needed code for generating PDF printing. You would need to add the necessary code for doing Internet Printing, and then display the resulting PDF in the web browser.
Sorry, but I don't think I will be able to further assist you in this.
I think you are right! :wub:
0
請登入寫評論。
評論
7 條評論