We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF printing error

Dear Aspose team,

I have a PDF file generated from a html file and when I try to
send the generated PDF to a printer using LPR/LPD the PDF it isn’t printed correctly.
I tried all
the existing Aspose.Pdf.PdfFormat’s but none are printed correctly and the output
result was slightly differed for each Aspose.Pdf.PdfFormat

I attached zipped html file

I hope you
can help me,

Kind regards,
Paul Haerkens

my Code

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(“Aspose.Total.lic”);

Aspose.Pdf.HtmlLoadOptions htmlLoadOptions = new Aspose.Pdf.HtmlLoadOptions();
htmlLoadOptions.PageInfo.Margin.Bottom = 10;
htmlLoadOptions.PageInfo.Margin.Top = 10;
htmlLoadOptions.PageInfo.Width = Aspose.Pdf.PageSize.A4.Width;
htmlLoadOptions.PageInfo.Height = Aspose.Pdf.PageSize.A4.Height;

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html)), htmlLoadOptions);

MemoryStream stream = new MemoryStream();
pdfDocument.Convert(stream, Aspose.Pdf.PdfFormat.v_1_5, Aspose.Pdf.ConvertErrorAction.Delete);
pdfDocument.Save(ticket.FullName, Aspose.Pdf.SaveFormat.Pdf);

pdfDocument.Dispose();
stream.Dispose();

Printing command sample

c:> lpr -Sprinter’s IP address [-Poption] [-ol] \path\file name

<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>NL</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;}

<![endif]–>

Hi There,


Thanks for contacting support.

I am looking into it in detail and will share my findings with you shortly.

Best Regards,

Hi Paul,


Thanks for contacting support.

I have tried printing the PDF documents using Adobe Soft printer and Microsoft XPS Document writer while using Aspose.Pdf for .NET 17.4.0 while using following code snippet and I am unable to notice any issue.

However for the sake of correction, I have logged an investigation ticket regarding LPR/LPD problem as PDFNET-42587 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. We are sorry for this inconvenience.

[C#]

Aspose.Pdf.HtmlLoadOptions
htmlLoadOptions = new Aspose.Pdf.HtmlLoadOptions();<o:p></o:p>

htmlLoadOptions.PageInfo.Margin.Bottom = 10;

htmlLoadOptions.PageInfo.Margin.Top = 10;

htmlLoadOptions.PageInfo.Width = Aspose.Pdf.PageSize.A4.Width;

htmlLoadOptions.PageInfo.Height = Aspose.Pdf.PageSize.A4.Height;

// Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(@"C:\pdftest\AE10-Ticket\AE10-Ticket.html", htmlLoadOptions);

MemoryStream stream = new MemoryStream();

// pdfDocument.Convert(stream, Aspose.Pdf.PdfFormat.v_1_5, Aspose.Pdf.ConvertErrorAction.Delete);

// pdfDocument.Save(@"C:\pdftest\AE10-Ticket\AE10-Ticket_17_4_0.pdf", Aspose.Pdf.SaveFormat.Pdf);

// Create PdfViewer object

PdfViewer viewer = new PdfViewer();

// Open input PDF file

viewer.BindPdf(@"C:\pdftest\Samples+result+Native+PDF+printing.pdf");

// Set attributes for printing

viewer.AutoResize = true; // Print the file with adjusted size

// viewer.AutoRotate = true; // Print the file with adjusted rotation

viewer.PrintPageDialog = false; // Do not produce the page number dialog when printing

// Create objects for printer and page settings and PrintDocument

System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();

System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();

System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();

// Set printer name

ps.PrinterName = prtdoc.PrinterSettings.PrinterName;

// Set PageSize (if required)

pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);

// Set PageMargins (if required)

pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);

// Print document using printer and page settings

viewer.PrintDocumentWithSettings(pgs, ps);

// Close the PDF file after priting

viewer.Close();

// pdfDocument.Dispose();

stream.Dispose();