Print a PDF in C# with non standard size on a label printer
<p>I create a PDF in a C# web application containing a label that has to be printed on a <a href="http://global.dymo.com/itIT/Products/LabelWriter_450.html" rel="nofollow">Dymo LabelWriter 450</a>.</p>

<p>To create and print the label I am using <a href="http://www.e-iceblue.com/Introduce/pdf-for-net-introduce.html#.Vt24dPnhDIU" rel="nofollow">Spire.PDF</a>.</p>

<p>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).</p>

<p>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.</p>

<p>My code looks as follows:</p>

<pre><code>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();
</code></pre>