We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Page.Rotate is always 0

Hi

We are currently have a usecase where the users can rotate pages in uploaded documents (incase its been fex scanned wrong). As such they must be able to rotate 90 180 270 etc.

I seem to recall having the following code working on an earlier version of your dll:
public void Rotate(int iDegrees)
{
var currentRotation = Page.RotationToInt(Page.Rotate);
Page.Rotate = Page.IntToRotation(currentRotation + iDegrees);
}

But now it seems that whenever i read in a pdf, the Page.Rotate is always 0. Event after having run rotation code above once, the saved page will return on read with Page.Rotate = 0.

Previously I could use a rotate right 90degrees or rotate left 90 degrees, but not it seems I will need 4 actions: Reset to 0 degrees, 90 degrees, 180 degrees and 270 degrees.

Is this now a bug?

Hi Bjornar,


Thanks for your inquiry. I have tested the scenario with a sample rotated PDF document and facing no issue to get page rotation value. We will appreciate it if you please share your sample document and code here, we will look into it and guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,

We are still having issues with this even after the latest release.

Should the Page.Rotate not be persisted?

Attaching a test document.

Hi Bjornar,


Thank you for contacting support. We have tested your source PDF document with the latest version 17.5 of Aspose.Pdf for .NET API. We can rotate the first page of your PDF document, and then retrieve the orientation of the page. Please try the following code example:

[.NET, C#]
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// load a PDF document<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
Document document = <span class=“kwrd” style=“color: rgb(0, 0, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>new<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”> Document(@“C:\Pdf\test84\Invoice+1.pdf”);<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// set orientation of the first page<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
document.Pages[1].Rotate = Rotation.on90;<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// save PDF in the stream object<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
MemoryStream OutPdf = <span class=“kwrd” style=“color: rgb(0, 0, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>new<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”> MemoryStream();<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
document.Save(OutPdf);<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// load output PDF<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
Document documentout = <span class=“kwrd” style=“color: rgb(0, 0, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>new<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”> Document(OutPdf);<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// retrieve orientation of the page<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
Console.WriteLine("Orientation of Page: " + documentout.Pages[1].Rotate.ToString());
<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>

Thanks for the quick reply.


Digging a bit deeper it seems that calling Page.GetPageFormat() resets the Rotate property. Is this correct and if so why?

// Set Page Format from first Page
if (_document.Pages.Count > 0)
{
_pageFormat = _document.Pages[1].GetPageFormat(); // This resets Rotate property
}

Hi Bjornar,


Thank you for the inquiry. There is no GetPageFormat method in the Page class when using the latest version 17.5 of Aspose.Pdf for .NET API. Kindly let us know which Aspose.Pdf for .NET API version you are using.