Hi admin,
I want to rotate individual pages. Not radpdfviewer of rotation. I found individual page logic but exactly not correct . please see attach file.
Thanks
Moe
2 Answers, 1 is accepted
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. To accomplish the same goal, I can suggest you using PdfProcessing for the modifications. This approach involves rotating the chosen page (or pages) and then exporting and re-importing the document in order for the viewer to show the modified version. There is a post in the forums with some sample code that you can find helpful. Please, note that the forum topic concerns the PdfViewer control from the UI for WPF suite, but it should be pretty (if not absolutely) similar.
I hope this information helps.
Vladislav
Progress Telerik
Hi Vladislav,
I am using winform form and vb.net.
Please can you provide to me for example code with vb using winform?
Thanks
Moe
Hi Moe,
The idea of the procedure is the following:
- Load the PDF file
- Rotate the page(s) you want like this:
- Export the document to a temporary stream
- Import the document from the stream
document.Pages(PageNumber).Rotation = Rotation.Rotate90
The code for the WinForms control shouldn't be different. I have prepared a sample project fro your reference.
Please do not hesitate to ask if any additional questions arise.
Regards,
Progress Telerik
I try to rotate page but page is rotate but not updating ,when i click zoom in and fittowidth buton then update page and showing rotated page. if any solution for this not updating page automatcally. (using winform)
int pageIndex =Convert.ToInt32(PdfViewerNavigator.CurrentPageTextBox.Text);
DocumentViewer.Document.Pages[pageIndex -1].Rotation = Telerik.Windows.Documents.Fixed.Model.Data.Rotation.Rotate90;
Hello,
You are probably missing the reloading of the document. What you need to do is call these two lines right after the rotation:
PdfFormatProvider provider = new PdfFormatProvider();
DocumentViewer.LoadDocument(new MemoryStream(provider.Export(DocumentViewer.Document)));
Furthermore, if you want to retain the current scroll position you will need to do it like this:
currentScrollOffset = DocumentViewer.PdfViewerElement.GetScrollOffset();
PdfFormatProvider provider = new PdfFormatProvider();
DocumentViewer.LoadDocument(new MemoryStream(provider.Export(DocumentViewer.Document)));
DocumentViewer.DocumentLoaded += DocumentViewer_DocumentLoaded;
And inside the DocumentViewer_DocumentLoaded event handler you will have this:
private void DocumentViewer_DocumentLoaded(object sender, EventArgs e)
{
DocumentViewer.PdfViewerElement.ScrollTo(currentScrollOffset.X, currentScrollOffset.Y);
DocumentViewer.DocumentLoaded -= DocumentViewer_DocumentLoaded;
}
I hope this helps.