iText7 PdfPolyGeomAnnotation not rendering in browser PDF viewers
03:15 07 Mar 2025

I'm using iText7 in C# to create a Polyline Annotation in a PDF document. The annotation renders correctly in Adobe Acrobat but doesn't show in browser PDF viewers like Chrome. I did not encounter any issue when rendering other type of annotations such as Ink, Highlight or Circle, but only Polyline so far.

Here's the code snippet I am using:

List vertices = new List();

// Create Polyline Annotation
PdfPolyGeomAnnotation polyline = PdfPolyGeomAnnotation.CreatePolyLine(rect, points.ToArray());

polyline.SetColor(Colour.GetColorValue());

// Set Line Width
polyline.SetBorder(new PdfAnnotationBorder(0, 0, CommentData.strokewidth));
polyline.SetFlags(PdfAnnotation.PRINT | PdfAnnotation.LOCKED | PdfAnnotation.READ_ONLY);

// Set Opacity
if (CommentData.opacity > 0 && CommentData.opacity <= 1)
{
    polyline.SetOpacity(new PdfNumber(CommentData.opacity));
}

// Add Annotation to Page
page.AddAnnotation(polyline);

Sample inputs:

  • Rect: { x: 23.12, y: 5.94, width: 38.25, height: 15.75 }
  • Points (Vertices): [23.12, 5.94, 56.87, 21.68, 61.37, 13.43]
  • Stroke Width: 2
  • Opacity: 0.5

What am I missing to make the polyline annotation visible in browser PDF viewers? Thanks.

c# itext itext7 pdf-annotations