Articles in this section
Category / Section

How to rotate the PDF Document when it is viewed in PDF Viewer Control?

3 mins read

We do not support document rotation when it is viewed in PDF Viewer Control. However as a workaround we can achieve this by assigning the rotation value in document settings for rotation in PDF document using PdfPageRotateAngle.

Code Snippet:

PdfDocument doc = new PdfDocument();

if (doc.PageSettings.Rotate == PdfPageRotateAngle.RotateAngle0)

doc.PageSettings.Rotate = PdfPageRotateAngle.RotateAngle90;

else if (doc.PageSettings.Rotate == PdfPageRotateAngle.RotateAngle90)

doc.PageSettings.Rotate = PdfPageRotateAngle.RotateAngle180;

else if (doc.PageSettings.Rotate == PdfPageRotateAngle.RotateAngle180)

doc.PageSettings.Rotate = PdfPageRotateAngle.RotateAngle270;

else if (doc.PageSettings.Rotate == PdfPageRotateAngle.RotateAngle270)

doc.PageSettings.Rotate = PdfPageRotateAngle.RotateAngle0;

rotation = doc.PageSettings.Rotate;

MemoryStream ms = new MemoryStream();

 

doc.Save(ms);

byte[] buffer = new byte[ms.Length];

ms.Read(buffer, 0, buffer.Length);

PdfLoadedDocument ldocument = new PdfLoadedDocument(ms);

pdfViewer.LoadDocument(ldocument);

ldocument.Close(true);

ms.Dispose();

doc.Close(true);

Please find the sample attached in the below link:

https://www.syncfusion.com/downloads/support/forum/119414/ze/RotationWinRT-574447116

 

 

Note:

Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.

 

Conclusion:

I hope you enjoyed learning about how to rotate the PDF Document when it is viewed in PDF Viewer Control.

 

You can refer to our Flutter PDF feature tour page to learn about its other groundbreaking features and documentation, and how to quickly get started with configuration specifications. You can also explore our Flutter PDF Flutter PDF examples to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to explore our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied