Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, October 18, 2019 1:59:47 PM(UTC)
Matthew Bresson

Groups: Registered, Tech Support, Administrators
Posts: 105

Was thanked: 3 time(s) in 3 post(s)

When working with the Document Viewer there are a few options to achieve document page rotation.

You can use Page and View Commands to rotate the document page(s) in the viewer, however these fields rotate the page(s) either clockwise or counter clockwise by 90 degrees:
https://www.leadtools.com/help/l...ent-viewer-commands.html

In this post we are going to focus on how to rotate the document page in the viewer by any degrees from 0 to 360 using the RotateCommand.
http://https://www.leadtools.co...ssing-rotatecommand.html
To run image pre-processing commands on documents in the Document Viewer you will need to use the GetImage() and SetImage() methods.
https://www.leadtools.com/help/l...mentpage-getimage().html
https://www.leadtools.com/help/l...cumentpage-setimage.html
This example is using the DocumentFactory to create a new LEADDocument "virtual document". Then loading in a document into the Document Viewer using LoadFromFile() and SetDocument().
https://www.leadtools.com/help/l...actory-loadfromfile.html
https://www.leadtools.com/help/l...tviewer-setdocument.html

Code:

private void RotatePage(int angle)
{
            documentViewer.BeginUpdate();
            var selectedPage = virtualDocument.Pages[documentViewer.CurrentPageNumber - 1];
            var rasterImage = selectedPage.GetImage();

            RotateCommand command = new RotateCommand();
            command.Angle = angle;
            command.FillColor = new RasterColor(255, 255, 255);
            command.Flags = RotateCommandFlags.Resize;
            command.Run(rasterImage);

            selectedPage.SetImage(rasterImage);
            virtualDocument.Pages.Add(selectedPage);
            documentViewer.SetDocument(virtualDocument);
            documentViewer.EndUpdate();
}


Attached is a sample project containing the snippet above. After you supply the document you want to use for the viewer, it will load the document. You can then select which page you want to rotate. After you do the rotation you can then save the document out to "C:\Temp\RotatedPage.pdf" and see that not only was the page rotated in the viewer but the page is now rotated in the exported file also.
File Attachment(s):
RotateDocumentWinforms.zip (271kb) downloaded 30 time(s).
Matt Bresson
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.043 seconds.