Free Support Forum - aspose.com

Annotation.Flatten causes the annotation to lose shape

I am trying to add annotations to a pdf. The shape looks fine when I just add it:

NotFlattened.png (13.0 KB)

But as soon as i flatten it, it comes out all messed up:

Flattened.png (18.8 KB)

I don’t know if this is a bug, or if I’m doing something wrong, but the only difference is me calling .flatten() (on the document, or on the annotation itself)

Thanks

@benitoz

Can you please share the source PDF file and code so that we may try to reproduce the same on our end.

Is a .cs file okay?
PdfDraw.zip (1.7 KB)
5. Client Review.pdf (8.7 MB)

@benitoz

I have changed your code a bit and it is not reproducing the issue.

try
{
    // Create Polygon Annotation - not sure what the rectangle is used for but its required.
    PolygonAnnotation bayInterior = new PolygonAnnotation(pdfDocument,  forgeShapePoints)
    {
        // Pass in style JSON and parse out for these values
        Color = Color.Transparent,
        InteriorColor = Color.White,
        Opacity = 0.7
    };

    // Create Polygon Annotation - not sure what the rectangle is used for but its required.
    PolygonAnnotation bayPermiter = new PolygonAnnotation(pdfDocument, forgeShapePoints)
    {
        // Pass in style JSON and parse out for these values
        Color = Color.LimeGreen
    };
    bayPermiter.Border = new Border(bayInterior) { Width = 4 };


    // Create PolyLine Annotation
    PolylineAnnotation joistDirectionArrow = new 
    PolylineAnnotation(pdfDocument.Pages[3], new Rectangle(100, 300, 200, 400), joistDirectionArrowPoints)
    {
        Color = Color.Blue
    };
    joistDirectionArrow.Border = new Border(joistDirectionArrow) { Width = 2 };

    //pdfDocument.Flatten();
    pdfDocument.Pages[3].Annotations.Add(bayInterior);
    pdfDocument.Pages[3].Annotations.Add(bayPermiter);
    pdfDocument.Pages[3].Annotations.Add(joistDirectionArrow);

    foreach (var annotation in pdfDocument.Pages[3].Annotations)
    {
        annotation.Flatten();
    }

The Rectangle is required for PolylineAnnotation only and its value should lie within the page limit.

1 Like

It’s still happening. No change with the code you sent.

@benitoz

I request you to share a sample application that reproduces the issue so that we can investigate this further.

Literally using the .cs file above, and that pdf and hit run. The only difference was I used the code you sent back. That’s all of it.

Here’s an updated one. I added in some code to calculate the BBox for the rectangles passed in…
No matter what I do, when I flatten, the annotations lose all styling and the arrow is messed up.

All you need to change is the directory at the top and run.
(.Net 4.8)

PdfDrawTester.zip (1.7 KB)
5. Client Review.pdf (8.7 MB)

@benitoz

I have been able to reproduce the issue on our end. A ticket with ID PDFNET-50062 has been created in our issue tracking system to further investigate the issue on our end. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

@mudassir.fayyaz

Thanks so much. Is there any kind of timeline you can give me? This could greatly affect our beta rollout.
Any information is appreciated, thanks!

@benitoz

Please note that it was recently logged in free support model and will be investigated and resolved on a first come first serve basis. We will surely inform you as soon as we make some definite progress towards its resolution. Please be patient and spare us some time.

Okay, we won’t be able to purchase a license if this can’t be fixed in time.

@benitoz

We will share the ETA as soon as the issue is investigated and we will inform you once it is fixed.

Amazing thank you!