We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Designing a label in pdf and printing to a Zebra thermal printer

I am developing an application that creates a label with text and barcode using PDF API and printing through PDFViewer API.  However, I cannot seem to correctly print the PDF label on a Zebra thermal printer.  Below are the actual PDF label sample, print output using Acrobat Reader, and print output through PDFViewer.  

PDF label output


Acrobat reader print output


PDFViewer print output


As you can see, the printing is almost OK with Acrobat reader but rotated when printed using PDFViewer.  Also, I cannot seem to silently print through code, whether through a stream or by saving to PDF first.  I was able to print only when pdf file was opened in PDFViewer.  Below is my code for printing the label, the commented lines are for the other printing options (through a stream).

private void PrintBarcode()
        {
            // Initialize print dialog.
            viewer.Load(Application.StartupPath + @"\barcode.pdf");
            //viewer.Load(stream);
            viewer.PrintDocument.DocumentName = "BG Label";
            //viewer.PrintDocument.Print();
            viewer.Print(false);
            //stream.Dispose();
        }

By the way, would like to ask for advice if this is the best way to implement a label designer and print it in Windows forms.  I know there is a separate barcode control but printing it with text seems cumbersome.

3 Replies

US Uthandaraja Selva Sundara Kani Syncfusion Team December 17, 2019 11:04 AM UTC

Hi San, 
 
Thanks for contacting Syncfusion support. 
 
We are unable to reproduce the issue “Printed Document is rotated when using PdfViewerControl.Print()” with our PDF documents and provided code snippet. Kindly refer the sample in the below link which we used to reproduce the reported issue, 
 
 
Note: In the sample, we have added the code snippet to view the PDF document using Stream. 
 
However, you can customize the Orientation and Size of the printed PDF document using PdfViewerControl.PrinterSettings API. Please find the UG documentation from below link, 
 
 
Please try the above suggestion and if you still face the same issue, kindly share the following details to analyze more on this and assist you a better solution,    
    
1.            PDF document used 
2.            Simple / Modified sample to reproduce the issue.     
3.            Replication procedure to reproduce the issue    
4.            Syncfusion product version.     
5.            .Net Framework     
6.            Visual Studio version.     
7.            Operating System     
 
Regards, 
Uthandaraja S 



SA San December 18, 2019 06:08 AM UTC

Sorry forgot to attach the image for the supposedly rotated print out.   Please see below.





But I was able to finally get the right output.  I think it has something to do with how I set the page size.  I'm a bit confused with the unit used in the size settings.  Is it in points or pixels? I think the page is automatically rotated if the page size settings do not fit the label size settings of the printer. Also although this is just a trivial issue, the print status dialog still is showing even though the ShowPrintStatusDialog is set to false, even with your sample.  I was able to only hide the status dialog by changing the PrintController to StandardPrintController.  


US Uthandaraja Selva Sundara Kani Syncfusion Team December 19, 2019 02:21 PM UTC

Hi San, 
 
We are glad to hear that you have resolved the issue at your end. Please find the details below, 
 
I think it has something to do with how I set the page size.  I'm a bit confused with the unit used in the size settings.  Is it in points or pixels? I think the page is automatically rotated if the page size settings do not fit the label size settings of the printer. 
We need more details about the page size you mentioned. Please let us know whether you mentioned our PdfViewerControl.PrinterSettings.PageSize or Microsoft PrintDocument.DefaultPageSettings.PaperSize API. So that, it will be helpful for us to analyze on this and provide you more details. 
Also although this is just a trivial issue, the print status dialog still is showing even though the ShowPrintStatusDialog is set to false, even with your sample.  I was able to only hide the status dialog by changing the PrintController to StandardPrintController.   
The ShowPrintStatusDialog hides the PrintStatusDialog when we use the PdfViewerControl Print methods. Please find the workable sample from below link, 
 
 
The PdfViewerControl.PrintDocument exposed for customize the print in sample level. So, if we use the PdfViewerControl.PrintDocument.Print method in sample level, then we need to handle the PrintStatusDialog hiding operation in sample level as you mentioned and this is the behavior. 
 
 
Regards, 
Uthandaraja S

Loader.
Live Chat Icon For mobile
Up arrow icon