Auto Rotate issue of PdfViewer class

I am trying to print the pdf file by using Aspose.pdf.kit.dll' s for .Net PdfViewer class, but it is printing by rotating the pdf file by 180 degree. (for example it is printin 6 as 9 and this is the issue when i am printing the landscape pdf file. I think there is a bug in Auto Rotate property of PdfViewer class) Following is the code:

Aspose.Pdf.Kit.License license = new Aspose.Pdf.Kit.License();
license.SetLicense("Aspose.Pdf.Kit.lic");

//create PdfViewer object
PdfViewer viewer = new PdfViewer();
viewer.OpenPdfFile(DirectPrintContentPath + DirectPrintContentFileName);
viewer.AutoResize = true;
viewer.AutoRotate = true;
viewer.PrintPageDialog = false;
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
System.Drawing.Printing.PrintDocument pdoc = new System.Drawing.Printing.PrintDocument();

ps.PrinterName = pdgDirectPrint.PrinterSettings.PrinterName;
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);

if (pgs.Landscape == true)
{
pgs.Landscape = true;
ps.DefaultPageSettings.Landscape = true;
pdoc.DefaultPageSettings.Landscape = true;
}
else
{
pgs.Landscape = false;
ps.DefaultPageSettings.Landscape = false;
pdoc.DefaultPageSettings.Landscape = false;
}

pgs.PaperSize = new System.Drawing.Printing.PaperSize(Convert.ToString(prnDoc.DefaultPageSettings.PaperSize), Convert.ToInt32(prnDoc.DefaultPageSettings.PaperSize.Width), Convert.ToInt32(prnDoc.DefaultPageSettings.PaperSize.Height));
for (int i = 1; i <= Convert.ToInt32(pdgDirectPrint.PrinterSettings.Copies); i++)
{
viewer.PrintDocumentWithSettings(pgs, ps);
}

viewer.ClosePdfFile();

Hi,

First off, please try to use the merged Aspose.Pdf for .NET. This merged version contains features of both Aspose.Pdf and Aspose.Pdf.Kit. In order to use your existing code, you only need to include Aspose.Pdf.Facades namespace.

If you still find the same problem then please share the input PDF file with us, so we could investigate the issue at our end.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,

Hi,

This is Vikram Gheewala from Consolidated Graphics(CGX), where the corporate is holding a license copy of ASPOSE PDF Kit for its development center.

One of my client wants to print PDF of custom page size using an Interface, where the user can select an printer that is installed within network and send the PDF to the printer to print.

Well, the issue is that, ASPOSE does not take the custom size and its orientation defined in the PDF.

When we print the PDF directly to printer, the result is as expected.

But when we print the PDF using Aspose.Pdf.kit.dll in .Net code and print the PDF, the result is :

1. The orientation is totally opposite to what is there in PDF.

2. The Font size get change.

3. The alignment get change

For your reference, please find the attached .Net source code and the custom size PDF.

Please provide support for the said issue.

Thanks & Regards,

Vikram Gheewala

ConsolidatedGraphics

Hi Vikram,

I have reproduced this problem at my end and logged it as PDFKITNET-29766 in our issue tracking system. Our team will look into this issue and you’ll be updated via this forum thread once it is resolved.

We’re sorry for the inconvenience.
Regards,

Hi,

Thanks for considering the issue. As this is a very urgent to fix for our client, if possible please provide the time line for resolving this issue.

With Regards,

Vijay Singh Bhadoriya

Hi Vijay,

I have asked our development team regarding the ETA of this issue. You’ll be updated as soon as the response is received. Please spare us some time for initial investigation.

Regards,

Hi,

Is there any update on this issue? Please suggest some solution as the issue is very important for us.

With Regards,

Vijay Singh Bhadoriya

Hi Vijay,

I’m sorry to inform you that the ETA of this issue is not yet available. Our team is looking into this issue and you’ll be updated as soon as the ETA is available. Also, I have increased the priority of this issue. Nevertheless, please spare us some time for detailed investigation.

We’re sorry for the inconvenience.
Regards,

Hi Shahzad,

In case of landscape PDF’s, AutoRoate() method of Aspose viewer class rotate the PDF in clockwise direction during printing of landscape PDF’s, however during printing we need to rotate the supplied PDF’s in anti clockwise direction as the adobe acrobat instance rotate the PDF’s in anticlockwise direction during the printing in case of landscape PDF’s.

I think Aspose development team setting transformation of landscape to transformation.Rotate(90) while adobe acrobat instance setting transformation.Rotate(-90). May this will help your development tean to resolve the issue.

Hi Vijay,

Thank you very much for sharing further thoughts. I have communicated this to our development team. We’ll see if this might help in resolving the issue.

Regards,

Hi Shahzad,

To resolve the above stated issue, i have find the temporarly solution. If possible please reply me after confimation with your development team either this is the right way or i am going wrong.

We have used PdfPageEditor class of Aspose.pdf.kit dll’s. We make an object of this class which take the supplied pdf and find out the width and height of that pdf. We checked either the pdf is of landscape format or of potrait format by comparing the width and height. If the pdf is of potrait format then we are printing it as we printed earlear through aspose but if the pdf is of landscape format then we rotate the pdf in 270 degree and save it in memory stream and then finding the total length of memory stream’s pdf in buffer and reading this memoery streams pdf length from start to end and then send this memory stream for printing with supplied page size, page width and page height.

If possible please try to fix this issue as soon as possible.

The Code:

private void PrintByAspose()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

{

MemoryStream ms = new MemoryStream();

string PrinterName = (string)cboSelectPrinter.SelectedItem;

prnDoc.PrinterSettings.PrinterName = PrinterName;

Aspose.Pdf.Kit.License license = new Aspose.Pdf.Kit.License();

license.SetLicense("Aspose.Pdf.Kit.lic");

//create PdfViewer,PdfPageEditor,PrinterSettings,PageSettings and PrintDocument object

PdfViewer viewer = new PdfViewer();

PdfPageEditor pEdit = new PdfPageEditor();

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

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

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

pEdit.BindPdf(DirectPrintContentPath + DirectPrintContentFileName);

int PDFPages = pEdit.GetPages();

double PDFwidth = pEdit.GetPageSize(1).Width;

double PDFheight = pEdit.GetPageSize(1).Height;

if (PDFwidth < PDFheight)

{

viewer.OpenPdfFile(DirectPrintContentPath + DirectPrintContentFileName);

}

else if (PDFwidth > PDFheight || PDFwidth == PDFheight)

{

pEdit.Rotation = 270;

pEdit.Save(ms);

byte[] buffer = new byte[ms.Length];

ms.Seek(0, SeekOrigin.Begin);

ms.Flush();

ms.Read(buffer, 0, (int)ms.Length);

viewer.OpenPdfFile(ms);

}

viewer.AutoResize = true;

viewer.AutoRotate = false;

viewer.PrintPageDialog = false;

ps.PrinterName = PrinterName;

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

if (((!string.IsNullOrEmpty(txtSKUDefaultPageWidth.Text.ToString())) && (!string.IsNullOrEmpty(txtSKUDefaultPageHeight.Text.ToString()))))

{

pgs.PaperSize = new System.Drawing.Printing.PaperSize(txtSKUDefaultPageSize.Text.ToString().Trim(), intwidthSKU, intheightSKU);

}

else

{

pgs.PaperSize = new System.Drawing.Printing.PaperSize(Convert.ToString(prnDoc.DefaultPageSettings.PaperSize), Convert.ToInt32(prnDoc.DefaultPageSettings.PaperSize.Width), Convert.ToInt32(prnDoc.DefaultPageSettings.PaperSize.Height));

}

for (int i = 1; i <= Convert.ToInt32(txtQtytoPrint.Text.ToString()); i++)

{

viewer.PrintDocumentWithSettings(pgs, ps);

}

viewer.ClosePdfFile();

}

Hi Vijay,

If this workaround is working for you at the moment then it shouldn’t be a problem to use it. We do understand that it is an overhead. I have updated our team with all the details and asked them to provide a proper fix for this issue. You’ll be updated with any updates from our development team.

We’re sorry for the inconvenience.
Regards,

Hi Shahzad ,

Is there any update on this issue. From last 5 months, i am waiting for the solution.

With Regards,

Vijay Bhadoriya

Hi Vijay,

I’m sorry for the inconvenience caused due to this issue. I have contacted our team for the details regarding this issue. You’ll be updated with the status the earliest possible.

We appreciate your cooperation.
Regards,

Hi Vijay,


Thanks for your patience. I am pleased to share that the issue reported earlier has been fixed and its HotFix will be included in upcoming release version of Aspose.Pdf for .NET 6.6.0. Please note that in order to resolve this issue, a new property named AutoRotateMode is introduced in PdfViewer class.
This property can have three available values: None, ClockWise, AntiClockWise.
None - rotation doesn’t perform
ClockWise, AntiClockWise. - rotation performs in proper direction.

Properties AutoRotateMode and AutoRotate are closely related:
if AutoRotateMode is equal None, then AutoRotate will be set to false and vice versa
if AutoRotate is true, then by defatul AutoRotateMode will be set to AntiClockWise.

[C#]
viewer.AutoRotateMode = AutoRotateMode.AntiClockWise;

The issues you have found earlier (filed as PDFNEWNET-29766) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.