Rotate page bug removing text and splitting tables across two pages

We are experiencing an intermittent issue when rotating pages within a PDF. We use Aspose to convert the source file to PDF then use document. Pages[index].Rotate to set the orientation. However, we are seeing instances where tables are split across two pages (creating an addition page) and the text on the rotated page (and new page) disappears. We have found previous support tickets referring to missing text on rotated pages going back to version ~17.* and this appears to have been addressed in subsequent releases. We have attached a source document and an example of an affected PDF.
example pdf for aspose.pdf (92.6 KB)

@HJR

Can you please share a bit more details to replicate the issue in our environment? Are you experiencing it with 24.10 version? Please share sample code and steps to reproduce the issue with the file you attached above so that we can test the scenario in our environment and address it accordingly.

Hi @asad.ali I have added more details below.
Our Function App uses:

  • Aspose.PDF.Drawing Version=24.4.0
  • Aspose.Cells Version=24.4.0
  • Aspose.Slides.NET Version=23.12.0
  • Aspose.Imaging Version=23.12.0
  • Aspose.Diagram Version=24.4.0
  • Aspose.Email Version=23.12.0
    Not all of those will be relevant but it’s what have included in our project.

The code:
public async Task ModifyDocument(Stream stream, ModifyDocumentDto modifications)
{
try
{
var inputStream = await stream.EnsureSeekableAsync();

    var pagesRemoved = modifications.DocumentModifications.Where(x => x.Operation == DocumentManipulationOperation.RemovePage).SelectMany(x => new[] { x.PageIndex }).ToArray();
    var pagesRotated = modifications.DocumentModifications.Where(x => x.Operation == DocumentManipulationOperation.RotatePage).SelectMany(x => new[] { x.PageIndex }).ToArray();

    var document = new Document(inputStream);

    foreach (var change in modifications.DocumentModifications.OrderByDescending(x => x.PageIndex))
    {
        switch (change.Operation)
        {
            case DocumentManipulationOperation.RemovePage:
                document.Pages.Delete(change.PageIndex);
                break;
            case DocumentManipulationOperation.RotatePage:
                document.Pages[change.PageIndex].Rotate = SetRotation(document.Pages[change.PageIndex].Rotate, change.Arg.ToString());
                break;
        }
    }

    var outputStream = new MemoryStream();
    await document.SaveAsync(outputStream, CancellationToken.None);
    outputStream.Position = 0;
    document.Dispose();

    return outputStream;
}
catch (Exception)
{
    throw;
}

}

The SetRotation method (not included but referred to above) returns an Aspose.Pdf.Rotation enum value e.g. Rotation.on90

@HJR

Below is the minimal code sample that we used to test the case while changing page rotation and we could not replicate the issue:

var d = new Document(dataDir + "example pdf for aspose.pdf");
foreach (var page in d.Pages)
{
    Console.WriteLine(page.Rotate);
    page.Rotate = Rotation.on90;
}
d.Save(dataDir + "rotationchanged.pdf");

Also, we used 24.10 version of the API. Please check the above code and highlight if we have missed some important detail that can help in reproducing the issue in our environment.
rotationchanged.pdf (91.0 KB)

Hi @asad.ali the code is correct. The issue is intermittent so it may be that it just has not come up in your testing yet? It is frustrating as we have not been able to reliably reproduce the issue yet.

@HJR

May be you can try using 24.10 and observe if it resolves the issue. We are afraid that we cannot investigate or determine the issue cause without replicating it in our environment. If there is any information that can help in reproducing it, please do share with us whenever you have it. We will proceed further accordingly.