Aspose.PDF is not retaining the page rotation changes while Opening in thew new Window

Hello Aspose Team,

I have written C# code with Aspose.pdf Library to rotate the pages in pdf document to 90,180, 270 degree with c# code. While selecting the page and performing the rotation working as expected. While previewing the document in a new window the rotation changes are not getting retained.
Please advise?

Thanks,
Dharma

@dharma.agadia

What to check / try

  1. Apply rotation before savingPage.Rotate (or Page.PageInfo.Rotate) must be set, then pdfDocument.Save(...) is called. If the document is opened in a new window from the same stream, ensure the stream is rewound (stream.Position = 0) after Save.

  2. Confirm the saved file – open the saved PDF directly (e.g., in Adobe Reader) to verify the rotation is present. If it appears correctly there, the issue is in the preview logic rather than Aspose.PDF.

  3. Preview code – if you are sending the PDF to the browser with something like:

    using (MemoryStream ms = new MemoryStream())
    {
        pdfDocument.Save(ms);
        ms.Position = 0;               // <-- important
        Response.ContentType = "application/pdf";
        Response.BinaryWrite(ms.ToArray());
    }
    

    make sure ms.Position is reset before writing the response. Otherwise the browser receives an empty or partially‑written stream and may fall back to the original file.


Minimal reproducible snippet

// load source PDF
Document pdf = new Document("input.pdf");

// rotate page 1 by 90°
pdf.Pages[1].Rotate = RotationAngle.Rotate90;   // or pdf.Pages[1].PageInfo.Rotate = 90;

// save to a MemoryStream (or file)
using (MemoryStream ms = new MemoryStream())
{
    pdf.Save(ms);
    ms.Position = 0; // reset before sending to client

    // preview in new window (ASP.NET example)
    Response.Clear();
    Response.ContentType = "application/pdf";
    Response.AddHeader("Content-Disposition", "inline; filename=rotated.pdf");
    Response.BinaryWrite(ms.ToArray());
    Response.End();
}

Next steps

  • Verify the Aspose.PDF for .NET version you are using (latest version is recommended).
  • Share the exact code you use to open the “new window” preview (e.g., ASP.NET response, JavaScript window.open, etc.).
  • If the rotation is visible when opening the saved file directly but not in the preview, the problem is in the preview handling; otherwise, provide a small PDF that reproduces the issue so we can log a defect.