I create a PDF in a C# web application containing a label that has to be printed on a Dymo LabelWriter 450.
To create and print the label I am using Spire.PDF.
If I save the PDF in a folder and then print it using Acrobat Reader, it is printed correctly (and so I can confirm the page size set in my application is correct).
When I print directly from the application, the PDF is stretched abnormally, with reduced width and enlarged height, going beyond the boundaries of the label.
My code looks as follows:
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(fileName);
SizeF pageSize = doc.Pages[0].Size;
PageSettings ps = new PageSettings();
ps.PaperSize = new PaperSize("MyPaperSize", (int)pageSize.Width, (int)pageSize.Height);
doc.PrintDocument.DefaultPageSettings = ps;
doc.PrinterName = printerName;
doc.PrintDocument.PrinterSettings.DefaultPageSettings.Margins.Left = 0;
doc.PrintDocument.PrinterSettings.DefaultPageSettings.Margins.Right = 0;
doc.PrintDocument.PrinterSettings.DefaultPageSettings.Margins.Top = 0;
doc.PrintDocument.PrinterSettings.DefaultPageSettings.Margins.Bottom = 0;
PrintDocument printDoc = doc.PrintDocument;
printDoc.Print();