This is a migrated thread and some comments may be shown as answers.

Exporting current page from viewer as image

3 Answers 443 Views
PdfViewer and PdfViewerNavigator
This is a migrated thread and some comments may be shown as answers.
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Toby asked on 15 Jan 2021, 03:55 PM

Hi,

I've been struggling to work out how to export the current pdf page as shown in the pdfViewer after it has been rotated using controls in the pdfViewerNavigator. I'm trying to save the image in png format but it seems to export the page in the original orientation ignoring the applied rotation.  

 

Also whilst searching the forum for a solution, I came across the code

this.radPdfViewer1.PdfViewerElement.CurrentPage.PageNo

 

but  it appears that PageNo no longer exists in 2020.3.1020.

Currently i'm using

pdfViewer.ExportPage ( 0, _tempImageFileName, 1.0, true, ImageFormat.Png );

 

which exports the first page as a png, which works, I just need to save the currently selected page that may or may not have been rotated.

Is this possible, if so how ?

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Jan 2021, 07:21 AM

Hello, Toby,

PageNo is marked as obsolete with the following message: "Use RadFixedDocument.Pages.IndexOf(RadFixedPage) method instead".

RadPdfViewer is intended for visualizing the documents and does not respect changes in its content, including the rotation of the pages, after importing the document. What is allowed to be edited are only the interactive forms inside the document.

Please refer to the following forum post which points to using RadPdfProcessing if you want to change the orientation of a document and preserve these changes: https://www.telerik.com/forums/how-to-rotate-individual-pages#OeIdvbcGW0O0QPgmDRCfJw 

Then, using the API that RadPdfViewer offers you can load the exported pdf document and generate the images for each page in the pdf: https://docs.telerik.com/devtools/winforms/controls/pdfviewer/export-to-image   

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Toby
Top achievements
Rank 3
Iron
Iron
Iron
answered on 21 Jan 2021, 11:46 AM

All sorted now, I think it was the fact that pdfViewer.LoadDocument is asynchronous and returns before the document has actually loaded, hence having to use DpdfViewer.DocumentLoaded event twice

 

The first time to rotate the pages by given amount (noting that Pdf Viewer RotationAngle is 0..3 and RadFixedDocument uses 0, 90, 180 and 270)., and then a second time to export the chosen page after it has been reloaded from the providers memory stream.

 

Regards

Toby

0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Jan 2021, 02:03 PM

Hello, Toby,

Indeed, RadPdfViewer loads the document asynchronously. It is possible to set the PdfViewerElement.AsyncRender property to false and this will disable the async rendering of pages.

However, the DocumentLoaded event is expected to be fired when the worker is completed with the document loading. Then, you can execute the desired action with the exact document.

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
PdfViewer and PdfViewerNavigator
Asked by
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Share this question
or