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

Free Support Forum - aspose.com

Flatten Fails with long documents

In an attempt to work around the last issue, I have replaced graphs with polyline annotations to draw lines, then flattening the document so that they’re non-interactive. This works fine except that with documents over a certain length the Document.Flatten() call stops working.

            Aspose.Pdf.Document pdf = new Document("test.pdf");

        PdfContentEditor editor = new PdfContentEditor();

        LineInfo lineInfo = new LineInfo
            VerticeCoordinate = new[] { 20f, 50f, 200f, 600f },
            Visibility = true,
            LineColor = System.Drawing.Color.Black,
            LineWidth = 3
        editor.CreatePolyLine(lineInfo, 1, new System.Drawing.Rectangle(1, 1, 3, 1), "");


This will fail when the test document has more than 51 pages, but succeeds when it has 35 (I haven’t narrowed down to the exact page number that triggers it)

Test documents:
51 pages: test.pdf (201.2 KB)
35 pages: test2.pdf (191.5 KB)


Thank you for contacting support.

We have worked with the data shared by you but we have not been able to reproduce the issue with Aspose.PDF for .NET 18.6. We have attached generated files for your kind reference.

Please try using latest version of the API and then share your kind feedback with us.

Hi @Farhan.Raza,
The files you have posted demonstrate the issue. In the 51Pages_18.6.pdf file, the line is an interactive polyline annotation that the user can manipulate, while in 35Pages_18.6.pdf the line has been flattened and can’t be manipulated.


Thank you for elaborating it further.

We have been able to observe the issue. A ticket with ID PDFNET-45052 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

Until the ticket is investigated, you may add a line on a PDF page by using below code snippet to draw a line on a PDF page:

        //Load a document
        Document document = new Document("Test.pdf");

        //Specify starting and ending coordinates for a line
        Aspose.Pdf.Point start = new Aspose.Pdf.Point(100, 100);
        Aspose.Pdf.Point end = new Aspose.Pdf.Point(200, 200);

        // Create Line annotation object
        Aspose.Pdf.Annotations.LineAnnotation AsposeLineAnn = new Aspose.Pdf.Annotations.LineAnnotation(document, start, end);

        //Add the annotation

        //Set different properties
        AsposeLineAnn.Color = Aspose.Pdf.Color.Green;
        AsposeLineAnn.Border = new Aspose.Pdf.Annotations.Border(AsposeLineAnn) { Width = 2 };


        // Save PDF file

We are sorry for the inconvenience.

Thanks. I gave that a try, but it seems to have the same issue. Calling AsposeLineAnn.Flatten(); doesn’t work with either the short document or the long one, and calling document.Flatten() works with the short document but not the long.

output.pdf (191.9 KB)


Thank you for your kind feedback.

We have recorded the information under logged ticket. We will let you know as soon as some significant progress is made towards resolution of this ticket. We appreciate your patience in this regard.