PdfViewer Print document - Fit to Page
I use Syncfusion.PdfViewer.WPF for PDF printing.
When I print a PDF wich doesn't match the selected paper, I want it to be printed scaled down so it fits onto the smaller paper.
Currently it gets printed 1:1 and therefore gets truncated either on the bottom or the right side when the paper is smaller than the document.
Example: Print a landscape A4 in portrait mode or vice-versa
How can I achieve an automatic "Fit to page" with Syncfusion?
My code is as follows (I use .NET 5.0):
PdfDocumentView document = new();
document.Load(somePdfStream);
PrintQueue printQueue = new(new PrintServer(), "Microsoft Print to PDF");
PrintTicket requestedTicket = new()
{
PageMediaSize = new(PageMediaSizeName.ISOA4)
};
PrintDialog printDialog = new()
{
PageRangeSelection = PageRangeSelection.AllPages,
PrintQueue = printQueue,
PrintTicket = requestedTicket
};
printDialog.PrintDocument(document.PrintDocument.DocumentPaginator, "test doc");
SIGN IN To post a reply.
5 Replies
1 reply marked as answer
VS
Vikas Sekar
Syncfusion Team
November 18, 2020 12:24 PM UTC
Hi Manuel,
Thank you for contacting Syncfusion Support.
In PdfViewer we can print the document with `Fit` option, which will enlarges or reduces each page to fit the printable area of the selected paper size. Please refer the below UG document and code snippet.
|
PdfDocumentView document = new PdfDocumentView();
document.Load("../../../HTTP Succinctly.pdf");
document.PrinterSettings.PageSize = PdfViewerPrintSize.Fit; |
Please let us know if the solution helps and if you need any further assistance.
Regards,
Vikas
MB
Manuel Bachmann
November 18, 2020 12:57 PM UTC
When I use your provided
document.PrinterSettings.PageSize = PdfViewerPrintSize.Fit;
printDialog.PrintDocument(document.PrintDocument.DocumentPaginator, "test doc");
it doesn't have any effect.
If I print it with
document.PrinterSettings.PageSize = PdfViewerPrintSize.Fit;
with the printdialog print function
printDialog.PrintDocument(document.PrintDocument.DocumentPaginator, "test doc");
it doesn't have any effect.
If I print it with
document.Print("Microsoft Print to PDF");
the output is stretched to the page, instead of keeping the aspect ratio.
Is it possible to instruct the printer to "fit to page" with the correct aspect ratio instead of stretching it?
VS
Vikas Sekar
Syncfusion Team
November 19, 2020 06:41 PM UTC
Hi Manuel,
Please find the below table.
|
Query |
Detail |
|
When I use your provided
document.PrinterSettings.PageSize = PdfViewerPrintSize.Fit;
with the printdialog print function
printDialog.PrintDocument(document.PrintDocument.DocumentPaginator, "test doc");
it doesn't have any effect. |
The suggested code snippet to set the Pagesize will reflect only in PdfDocumentView.Print() method and it will not reflect in the sample level PrintDialogue control print settings as it is its behavior. |
|
If I print it with
document.Print("Microsoft Print to PDF");
the output is stretched to the page, instead of keeping the aspect ratio.
Is it possible to instruct the printer to "fit to page" with the correct aspect ratio instead of stretching it?
|
We tried to reproduce the issue “The Printed output was stretched instead of maintain aspect ratio” and we could not reproduce the issue in our end, the printed document with different paper size has the same aspect ratio when we print with “fit” as PageSize.
We have attached the input PDF file and output printed document file for your reference in the below link: https://www.syncfusion.com/downloads/support/forum/159826/ze/PrintwithFit1315263692
Since we could not reproduce the issue, we suspect this might me document specific or due to Paper size related issue. So, we request you to provide the document in which you have faced the issue and also please provide the detail about Paper size which you are trying to print. This information will be helpful for us to analyze more from our side and provide you a better solution.
|
Regards,
Vikas
MB
Manuel Bachmann
November 20, 2020 12:45 PM UTC
I uploaded the PDF which behaves wrong when printed in landscape. (pdf_2738ae35.zip)
Attachment: pdf_2738ae35.zip
Attachment: pdf_2738ae35.zip
DD
Divya Dhayalan
Syncfusion Team
November 23, 2020 01:08 PM UTC
Hi Manuel,
Thanks for the update.
We tried to reproduce the issue “The Printed output was stretched instead of maintain aspect ratio” by using the attached PDF document and setting the Page Orientation as Landscape, but we could not reproduce the issue. We checked the same in adobe by setting the Landscape and fit properties as like in the below image and printed the provided Document for comparison, the printed output page as the same size of page which was printed using Syncfusion PdfViewer.
Please find the attached pdf files which are printed using Adobe and Syncfusion PdfViewer from the below link: https://www.syncfusion.com/downloads/support/forum/159826/ze/PrintedDoc-178158051
We also created sample for your reference, and you can download the sample from the below link:
If our observation is different to that of yours and please provide us some more details specific to the issue. You can use the sample in your end or modify the sample to reproduce the issue and provide us for further analysis. This information will be helpful for us to analyze more from our side and provide you a better solution.
Regards,
Divya
Marked as answer
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
- Marked answer
-
MB Manuel Bachmann
- Nov 17, 2020 09:43 PM UTC
- Nov 23, 2020 01:08 PM UTC