You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Kai Keggenhoff <Ka...@thinkproject.com> on 2025/11/24 14:22:43 UTC

Question about FDFAnnotation(Element element), possible bug

Hi everyone.

We are importing annotations in XFDF format via PDFBox into PDF documents.
We observed a discrepancy for text annotations exported from Foxit and imported into a PDF when viewed with Adobe Reader regarding the border of such annotations.

When I look at the code of the FDFAnnotation(Element element) constructor, the "width" attribute is parsed and its value set in the newly created PDBorderStyleDictionary object. (lines 258-262 in 2.0.35, lines 254-258 in 3.0.6).

A sample annotation in XFDF starts like this

<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
      <annots>
            <freetext
                        width="0.00"
                        justification="left"
...

In this case, the parsed value for "width" is "0" and set in the border style object.
Next, this value is read and compared to ">0" to update border style, effect, dashes and so forth.
However, the border style is only updated in the annotation object when the border width is ">0".

So I'm taking a guess here, but I think the line

setBorderStyle(borderStyle);

should be outside of the ">0" block so that the border is always set and the width doesn't default to "1" when that FDFAnnotation is used to produce a PDAnnotation.

Please let me know if I should raise an issue in JIRA for this.

Thanks in advance,

Kai


[cid:e711b064-fcee-42c9-92f3-1f71318ea43f]<https://thinkproject.com/de/>

Kai Keggenhoff / Senior Software Developer

 thinkproject.com<https://thinkproject.com/de> <https://thinkproject.com/de>

[cid:3a4f4faa-78fe-45cd-bc88-a863ad18ec71]<https://www.linkedin.com/company/thinkproject-dach/posts/?feedView=all>[cid:c236dd11-42bf-49f1-ab40-627290925372]<https://twitter.com/thinkproject_>

Read our legal information (imprint) here<https://thinkproject.com/de/impressum/>.



Re: Question about FDFAnnotation(Element element), possible bug

Posted by Kai Keggenhoff <Ka...@thinkproject.com>.
Hi Tilman,

Thank you for the quick fix.
I've downloaded the latest snapshot of 2.0.36 (pdfbox-2.0.36-20251125.095157-69).
Now the proper width is passed through to the PDAnnotation we create from the FDFAnnotation and the resulting appearance in the document is correct, namely, "no border".
I thereby conclude the FDFAnnotation is initialized correctly.

Thank you very much,

Kai


________________________________
From: Tilman Hausherr <TH...@t-online.de>
Sent: Monday, November 24, 2025 15:49
To: users@pdfbox.apache.org <us...@pdfbox.apache.org>
Subject: Re: Question about FDFAnnotation(Element element), possible bug

Hi, Yes you're right, please create a ticket. If possible, add test files. Tilman Am 24.11.2025 um 15:22 schrieb Kai Keg͏​​‌͏
[Graymail]<https://summary.eu1.defend.egress.com/v3/summary?ref=email&crId=692470af5716863af664f14e&lang=en>
Graymail<https://summary.eu1.defend.egress.com/v3/summary?ref=email&crId=692470af5716863af664f14e&lang=en>
[Graymail]<https://summary.eu1.defend.egress.com/v3/summary?ref=email&crId=692470af5716863af664f14e&lang=en>
[External email]<https://summary.eu1.defend.egress.com/v3/summary?ref=email&crId=692470af5716863af664f14e&lang=en>
External email<https://summary.eu1.defend.egress.com/v3/summary?ref=email&crId=692470af5716863af664f14e&lang=en>
[External email]<https://summary.eu1.defend.egress.com/v3/summary?ref=email&crId=692470af5716863af664f14e&lang=en>


Hi,

Yes you're right, please create a ticket. If possible, add test files.

Tilman

Am 24.11.2025 um 15:22 schrieb Kai Keggenhoff:
> Hi everyone.
>
> We are importing annotations in XFDF format via PDFBox into PDF documents.
> We observed a discrepancy for text annotations exported from Foxit and imported into a PDF when viewed with Adobe Reader regarding the border of such annotations.
>
> When I look at the code of the FDFAnnotation(Element element) constructor, the "width" attribute is parsed and its value set in the newly created PDBorderStyleDictionary object. (lines 258-262 in 2.0.35, lines 254-258 in 3.0.6).
>
> A sample annotation in XFDF starts like this
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
>       <annots>
>             <freetext
>                         width="0.00"
>                         justification="left"
> ...
>
> In this case, the parsed value for "width" is "0" and set in the border style object.
> Next, this value is read and compared to ">0" to update border style, effect, dashes and so forth.
> However, the border style is only updated in the annotation object when the border width is ">0".
>
> So I'm taking a guess here, but I think the line
>
> setBorderStyle(borderStyle);
>
> should be outside of the ">0" block so that the border is always set and the width doesn't default to "1" when that FDFAnnotation is used to produce a PDAnnotation.
>
> Please let me know if I should raise an issue in JIRA for this.
>
> Thanks in advance,
>
> Kai
>
> <https://thinkproject.com/de/>
>
> *Kai Keggenhoff* / Senior Software Developer
>
> *thinkproject.com <https://thinkproject.com/de>**<https://thinkproject.com/de>*
>
> <https://www.linkedin.com/company/thinkproject-dach/posts/?feedView=all><https://twitter.com/thinkproject_>
>
> Read our legal information (imprint) here <https://thinkproject.com/de/impressum/>.
>


Re: Question about FDFAnnotation(Element element), possible bug

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

Yes you're right, please create a ticket. If possible, add test files.

Tilman

Am 24.11.2025 um 15:22 schrieb Kai Keggenhoff:
> Hi everyone.
>
> We are importing annotations in XFDF format via PDFBox into PDF documents.
> We observed a discrepancy for text annotations exported from Foxit and 
> imported into a PDF when viewed with Adobe Reader regarding the border 
> of such annotations.
>
> When I look at the code of the FDFAnnotation(Element element) 
> constructor, the "width" attribute is parsed and its value set in the 
> newly created PDBorderStyleDictionary object. (lines 258-262 in 
> 2.0.35, lines 254-258 in 3.0.6).
>
> A sample annotation in XFDF starts like this
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
>       <annots>
>             <freetext
>                         width="0.00"
>                         justification="left"
> ...
>
> In this case, the parsed value for "width" is "0" and set in the 
> border style object.
> Next, this value is read and compared to ">0" to update border style, 
> effect, dashes and so forth.
> However, the border style is only updated in the annotation object 
> when the border width is ">0".
>
> So I'm taking a guess here, but I think the line
>
> setBorderStyle(borderStyle);
>
> should be outside of the ">0" block so that the border is always set 
> and the width doesn't default to "1" when that FDFAnnotation is used 
> to produce a PDAnnotation.
>
> Please let me know if I should raise an issue in JIRA for this.
>
> Thanks in advance,
>
> Kai
>
> <https://thinkproject.com/de/>
>
> *Kai Keggenhoff* / Senior Software Developer
>
> *thinkproject.com 
> <https://thinkproject.com/de>**<https://thinkproject.com/de>*
>
> <https://www.linkedin.com/company/thinkproject-dach/posts/?feedView=all><https://twitter.com/thinkproject_> 
>
>
> Read our legal information (imprint) here 
> <https://thinkproject.com/de/impressum/>.
>