Hi,
I'm using PdfViewControl to display a pdf document. Once the viewer is loaded, I set the ViewMode property to FitWidth in order to display the document in a full screen fashion.
Then, when the user clicks a button, I get the pages using GetPages method provided by PdfViewControl and add them to the PrintDocument using SetPreview method.
The problem is that the document does not occupies all the available space (see attachment) on the sheet of paper and the image is higly pixelated.
Here is the code I use to initialize the viewer:
var pdfBytes = await file.ToBytes();
var pdfDocument = new PdfLoadedDocument(bytes);
pdfViewer = new SfPdfViewerControl();
pdfViewer.Loaded += (sender, e) =>
{
var viewer = sender as SfPdfViewerControl;
viewer.ViewMode = PageViewMode.FitWidth;
};
pdfViewer.LoadDocument(pdfDocument);
contentGrid.Children.Add(pdfViewer);
And here is the code I use to print the document:
var pageCount = pdfViewer.PageCount;
var pages = pdfViewer.GetPages(0, pageCount, 100);
var otherPages = pdfViewer.GetPages(0, pageCount, 300);
_document.SetPreviewPageCount(pageCount + 1, PreviewPageCountType.Final);
var pdfDocument = pdfViewer.ItemsSource as PdfDocument;
for (int i = 0; i < pageCount + 1; i++)
{
_pages[i] = pages[i];
_document.SetPreviewPage(i + 1, pages[i]);
}
Any idea?
Regards,
Laurent
print_83385939.zip