Free Support Forum - aspose.com

Printing page orientation

Hi,

I have document with two pages, first portrait, second landscape. Same files as in my previous post (http://www.aspose.com/community/forums/thread/369401/converting-xps-to-pdf-page-sizes-not-the-same.aspx)

When I print it with the following code:

                var printerSetttings = new System.Drawing.Printing.PrinterSettings
                                           {
                                               Copies = 1,
                                               PrinterName = PrinterName
                                           };
            <span style="color: blue;">var</span> pageSettings = <span style="color: blue;">new</span> System.Drawing.Printing.<span style="color: rgb(43, 145, 175);">PageSettings</span>
                                   {
                                       Margins = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">Margins</span>(0, 0, 0, 0)
                                   };

            <span style="color: blue;">var</span> pdfViewer = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">PdfViewer</span>();
            pdfViewer.OpenPdfFile(pdfFileName);
            <span style="color: blue;">try</span>
            {
                pdfViewer.AutoResize = <span style="color: blue;">true</span>;
                pdfViewer.AutoRotate = <span style="color: blue;">false</span>;
                pdfViewer.PrintPageDialog = <span style="color: blue;">false</span>;
                pdfViewer.PrintDocumentWithSettings(pageSettings, printerSetttings);
            }
            <span style="color: blue;">finally</span>
            {
                pdfViewer.ClosePdfFile();
            }
 -------------------------------------
it prints first page as landscape and the second one properly (i.e. landscape)
Why page orientation are not respected when printing?
regards
Rafal
 

Hi Rafal,

Thanks for your interest in our products.

Kindly set the AutoRotate to true in your code as mentioned below.

pdfViewer.AutoRotate = true;

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,

setting

pdfViewer.AutoRotate = true;

will cause first page to be printed in Landscape and second in Portrait...

Note that the first page is Portrait and second Landscape.

In other words, it swaps orientation.

Hi Rafal,

Thanks for you feedback.

I tested the scenario with below code using Aspose.Pdf for .NET v6.8 and unable to find any issue, the resultant file is attached for your reference. Kindly use the latest version and check it fits your need.

[C#]
var printerSetttings = new System.Drawing.Printing.PrinterSettings
{
Copies = 1,
PrinterName = "Microsoft XPS Document Writer",
PrintToFile = true,
PrintFileName = @"d:\pdffiles\AutoRotate.xps"
};

var pageSettings = new System.Drawing.Printing.PageSettings
{
Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0)
};

var pdfViewer = new PdfViewer();
pdfViewer.OpenPdfFile(@"d:\pdffiles\33481fb2-bd19-440f-81e6-0331cb8f36ca.pdf");
try
{
pdfViewer.AutoResize = true;
pdfViewer.AutoRotate = true;
pdfViewer.PrintPageDialog = false;
pdfViewer.PrintDocumentWithSettings(pageSettings, printerSetttings);
}
finally
{
pdfViewer.ClosePdfFile();
}

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,

my scenario is:

1. create XPS

2. use aspose to convert XPS to PDF

3. use aspose to print PDF to printer (not XPS again!)

issue still remains

Hi Rafal,

Thank you for sharing the details, I tried to test your issue but I was unable to replicate the scenario at my end. However, to exactly replicate your issue at our end, we would appreciate, if you create a sample application and post here to show us the issue. This will help us to regenerate the issue and get the cause of the issue soon.

We apologize for your inconvenience.

Thanks & Regards,

attached is sample file that want to print

1st page - portrait

2nd page - landscape

(note: in the future can be all permutations :))

code that I use to print:

            var printerSetttings = new System.Drawing.Printing.PrinterSettings
            {
                Copies = 1,
                PrinterName = tbPrinterName.Text
            };
        <span style="color:blue;">var</span> pageSettings = <span style="color:blue;">new</span> System.Drawing.Printing.<span style="color:#2b91af;">PageSettings</span>
        {
            Margins = <span style="color:blue;">new</span> System.Drawing.Printing.<span style="color:#2b91af;">Margins</span>(0, 0, 0, 0)
        };

        <span style="color:blue;">var</span> pdfViewer = <span style="color:blue;">new</span> <span style="color:#2b91af;">PdfViewer</span>();
        pdfViewer.OpenPdfFile(tbFileName.Text);
        <span style="color:blue;">try</span>
        {
            pdfViewer.AutoResize = <span style="color:blue;">true</span>;
            pdfViewer.AutoRotate = <span style="color:blue;">true</span>;
            pdfViewer.PrintPageDialog = <span style="color:blue;">false</span>;
            pdfViewer.PrintDocumentWithSettings(pageSettings, printerSetttings);
        }
        <span style="color:blue;">finally</span>
        {
            pdfViewer.ClosePdfFile();
        }</pre></p><p>-------------------</p><p>attached is sample WPF application that makes the printing</p><p>third file as name suggest, is result of what comes out when I print it to PDF Writer (of course this is not the final printer but it demonstrate the issue)</p><p><br></p><p>Guys, just do not give me another answer that everything is OK...</p><p><br></p><p>provide solution!</p><p><br></p><p>thank you</p><p><br></p><p><br></p>

Hi Rafal,

Thanks for sharing the source code and template documents with us. The third file which you generated using PDF Writer shows the contents of 1st page in portrait layout and 2nd page in landscape layout and you also want to print first page in portrait layout and second page in landscape layout.
For your convenience, I have generated two documents using Adobe PDF printer, first document (Aspose PDF Landscape.pdf) is generated by using pdfViewer.AutoRotate = true;, as per my understanding there is no issue in this document, printer will print 1st page in portrait layout and 2nd page in landscape layout. Second document (Aspose PDF Portrait.pdf) is generated by using pdfViewer.AutoRotate = false;, printer will print this document in portrait layout. Both PDF documents are attached for your reference.

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,

Dear Ali,

With your post, you just proved my point!

Can you really not see the difference?

In your output second page should be landscape where as it is printed as portrait!!! Excatly my point! THIS IS WRONG!!!

/rp

see the attached picture, maybe this will help you understant what is WRONG

Hello Raphael,


Thanks for your patience and sharing details.

I have tested the scenario and have managed to reproduce the same problem. As per your observation, I have also noticed that even setting pdfViewer.AutoRotate value to true, the second page is still being printed in Portrait orientation. For the sake of correction, I have logged this issue as PDFNEWNET-33442 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. Please be patient and spare us little time. We are sorry for your inconvenience.

Hello Raphael,


Thanks for your patience.

I am pleased to share that the issue PDFNEWNET-33442 reported earlier has been fixed and its hotfix will be included in upcoming release version of Aspose.Pdf for .NET 6.9.0 which is expected to release early next month. Please be patient and wait for the new release. Your patience and comprehension is highly esteemed in this regard.

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


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

Hello, although I’m glad to see that a fix has been released for this issue, the autorotate behavior still doesn’t behave correctly in all cases. When printing to a normal printer (A4), the pages are filled properly, but we’re printing to card printers where the card is wider than it is tall (CR-80 format, 3.4" x 2.14"). Both landscape and portrait pages are rotated incorrectly, leaving more than half the card empty.

It looks like the autorotate code doesn’t take the output size into account, and simply assumes a ‘tall’ output. Note that the content isn’t being stretched - the aspect ratio is still correct. See the attached image for a comparison between how the same document is printed to an A4 sheet and a CR-80 card.

Hi Pieter,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the details and sorry for the delay in response.

I am able to reproduce your mentioned issue. I have re-opened the issue and shared the details with the development team to further look into your issue. I will update you via this forum thread regarding any updates.

Sorry for the inconvenience,

Hello, there have been some updates since the last post. Has this issue been fixed in one of the latest versions?

Hi Pieter,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for being patient.

Please download and try the latest version of Aspose.Pdf for .NET v7.4 as your reported issue regarding CR-80 has been fixed. In case you face any issue, please do let us know.

Sorry for the inconvenience,