highkite / pdfAnnotate

Javascript library for creating annotations in PDF documents
MIT License
556 stars 90 forks source link

Freetext annotations with default `ApperanceStream`s always have bg-color fills #75

Closed binury closed 4 months ago

binury commented 1 year ago

Background colors for freetext appearance streams were added in this commit: https://github.com/highkite/pdfAnnotate/commit/44c897b89dd52d408efc2e2f2888c5b5da5a550d#diff-99b71d49cca1b89ae537b182ba0eadeed3fd7de3f90327fb110be965ab7ef7b1R247-R248 It seems like, with the changes on these two lines, it is no longer possible to add freetext annotations without a background/border. I.e. just text. Was this change made out of necessity for visibility?

Since fill colors in PDFs are RGB, there is no way to specify a transparent color with 0 alpha in order to prevent the black default from overriding.

Removing these lines did not seem to have any adverse effect, removed the undesired bg-color fill of the rect, and the annotation was still visible on all of the readers we tested, FWIW… (But of course only provides a workaround and prevents any fill)

  const annotFactory = new AnnotationFactory(pdf);
  const annot = annotFactory.createFreeTextAnnotation({
    page: 0,
    rect: [100, 100, 200, 200],
    contents: 'Hello World',
  });
  annot.createDefaultAppearanceStream();
  annotFactory.save('annotated.pdf');
awolfson87 commented 1 year ago

@binury Did you ever find a solution for this?

binury commented 1 year ago

Forked the project and removed the default fill On Aug 20, 2023 at 08:43 -0400, awolfson87 @.***>, wrote:

@binury Did you ever find a solutions for this? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>