PhilterPaper / Perl-PDF-Builder

Extended version of the popular PDF::API2 Perl-based PDF library for creating, reading, and modifying PDF documents
https://www.catskilltech.com/FreeSW/product/PDF%2DBuilder/title/PDF%3A%3ABuilder/freeSW_full
Other
6 stars 7 forks source link

PDF::API2 compatibility: Annotation borders #176

Closed sciurius closed 2 years ago

sciurius commented 2 years ago

PDF::Builder creates annotations with a border, PDF::API2 does not.

PDF/Builder/Annotations.pm line 31

$self->{'Border'} = PDFArray(PDFNum(0), PDFNum(0), PDFNum(1));

this should be

$self->{'Border'} = PDFArray(PDFNum(0), PDFNum(0), PDFNum(0));
PhilterPaper commented 2 years ago

Interesting. It appears that PDF::API2 has always set the Border default (in new()) to be [0 0 0], while in PDF::Builder 3.008 I changed it to [0 0 1], apparently to match the PDF spec for Border (Table 164 – Entries common to all annotation dictionaries in the PDF 32000-1:2008 document).

It sounds like if you don't have an explicit /Border [hr vr bw] entry in the annotation dictionary, it should treat it as /Border [0 0 1]. If PDF::API2 by default has chosen to suppress annotation borders by explicitly giving /Border [0 0 0] in most cases (which will appear in the PDF file), and that behavior is more desirable, I could revert to [0 0 0] (no border by default). Would that be good? As it stands now, it apparently doesn't match PDF::API2's default behavior.

sciurius commented 2 years ago

The default PDF behaviour is to add a border (0,0,1). This is also in the docs of PDF::API2::Annotation.

However, PDF::API2::Annotation has always explicitly supressed the border with (0,0,0) so I think we should stick to that that behaviour.

https://github.com/ssimms/pdfapi2/pull/38

PhilterPaper commented 2 years ago

Yes, it is confusing. PDF::API2 defaults Border to [0 0 0], yet in border() says the default is [0 0 1]. I'll go ahead and revert to [0 0 0] (no border), since people are used to that behavior. As for the default behavior of a PDF reader being [0 0 1], it's not a huge deal to have to give -border => [0, 0, 1] if you want one.

PhilterPaper commented 2 years ago

Annotation.pm updated (as well as some examples and t test). Hopefully that should do it.