Hi Kai, so you have an approach you can follow. If there are further issues let us know.
caption-style is likely using rich text settings which PDFBox doesn't support. Maybe you can submit a snippet of the XFDF containing that attribute so that we can take a look if time permits. BR Maruan Am Mittwoch, dem 02.08.2023 um 09:54 +0000 schrieb Kai Keggenhoff: > Hi Maruan, > > the process was mentioned in the original mail and is as follows: > > XFDF is parsed to DOM > DOM is used to create a FDFDocument > FDFAnnotation(s) are read from > FDFDocument.getCatalog().getFDF().getAnnotations() > For each FDFAnnotation, a PDAnnotation is created from the > FDFAnnotation's.getCOSObject() > Then the PDAnnotation is added to the list of annotations on the page > - PDPage.getAnnotations().add(...) > > But I just found that if I remove the "caption-style" attribute from > the original XFDF and replace it with caption="no" like in the XFDF > created by Foxit, there are suddenly no more popups about "expected a > name object" in Adobe Reader. > > I think this might be due to the Adobe Reader versions our customers > use. > In the original, complete XFDF from Adobe Reader, which was produced > by multiple people with different Adobe Readers, there are "freetext" > annotation stating > > xfa:APIVersion="Acrobat:10.1.5" > > I think that version is like ten years old. > The freetext annotation isn't a problem at all, I just used that as > an indicator to the Reader version. > > I guess I will start to look for this "caption-style" attribute and > replace it as a workaround. > > Thank you for all the pointers ! > > Kai > > -----Ursprüngliche Nachricht----- > Von: sahy...@fileaffairs.de <sahy...@fileaffairs.de> > Gesendet: Mittwoch, 2. August 2023 11:34 > An: users@pdfbox.apache.org > Betreff: Re: Adding annotations to PDFs - "expected a name object" > > CAUTION - External Sender > > > Hello Kai, > > Am Mittwoch, dem 02.08.2023 um 09:24 +0000 schrieb Kai Keggenhoff: > > Hi Maruan, > > > > we let Adobe Reader submit a form with flags set for XFDF, include > > annotations and "ExclNonUserAnnots" (table 237 in the PDF 32000- > > 1:2008 spec) > > The XFDF is sent to a server address specific for the document and > > then processed. > > > > how does the annottaion created by adobe Reader look in PDF Debugger? > > You also mentioned that it doesn't work for merged PDFs - does it > work > for the original PDF wo merging? How is the merging done? > > BR > Maruan > > > > Usually, when sent by Adobe Reader, the full XFDF contains > > additional > > "f", "fields" and "id" nodes which I omitted for brevity. > > Here, I also reformatted it to make it easier to read. > > As we only read the children of "annots" when we process the XFDF > > to > > create annotation objects to add to the PDPage, I don't think these > > elements are relevant. > > > > For some time now, we also offer our users the option to use Foxit > > Web SDK to annotate PDFs and upload them to our system. > > A line annotation exported from Foxit looks like this > > > > <?xml version="1.0" encoding="UTF-8"?> > > <xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve"> > > <annots> > > <line page="0" color="#58D3D3" > > date="D:20230802111256+02'00'" flags="print" > > name="af1a7071-8b53-4219-953b-9ed2fe3e32d4" > > rect="125.326691,718.888428,206.180573,803.442627" > > title="PKM ServicePoint (conclude GmbH)" > > creationdate="D:20230802111256+02'00'" > > opacity="1" subject="Linie" style="solid" > > width="2.000000" > > head="None" tail="None" > > start="129.076691,799.692627" end="202.430573,722.638428" > > caption="no"> > > <popup page="0" color="#58D3D3" > > date="D:20230802111256+02'00'" flags="print" > > name="7133e39c-0ade-4a9e-aabf- > > b4a0e1bcce06" rect="129.076691,722.638428,202.430573,799.692627" > > open="no"/> > > </line> > > </annots> > > <ids original="88E08BC8B4D62452C697BC93996CC7CE" > > modified="A3D15A58D538804D652927671920C3A1"/> > > </xfdf> > > > > Strangely, when this is imported into the same PDF as the XFDF from > > Adobe Reader (it's a different line of course), the resulting PDF > > is > > fine. > > I think I need to compare these two in detail. > > > > Meanwhile, here's how the imported annotation from Adobe Reader > > looks > > in PDFDebugger > > https://cde-dev.conclude.com/img/line-annot.png > > > > Thank you very much for the input, > > > > Kai > > > > -----Ursprüngliche Nachricht----- > > Von: sahy...@fileaffairs.de <sahy...@fileaffairs.de> > > Gesendet: Mittwoch, 2. August 2023 10:22 > > An: users@pdfbox.apache.org > > Betreff: Re: Adding annotations to PDFs - "expected a name object" > > > > CAUTION - External Sender > > > > > > Hello Kai, > > > > Am Mittwoch, dem 02.08.2023 um 07:56 +0000 schrieb Kai Keggenhoff: > > > > > > > > > > > > Hi Tilman, > > > > > > thank you for the suggestion. Turns out, it's "Line" annotations. > > > When I import > > > > > > <?xml version="1.0" encoding="UTF-8"?> > > > <xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve"> > > > <annots> > > > <line width="3" color="#FF0000" > > > caption-style="Inline" > > > > > > creationdate="D:20230526112815+02'00'" flags="print" > > > > > > start="1770.007568,1614.721436" end="1791.373535,1658.575195" > > > > > > date="D:20230526112815+ > > > 02'00'" page="0" > > > > > > rect="1764.007568,1608.721436,1797.373535,1664.575195" > > > subject="Linie" > > > title="John Doe"> > > > <popup > > > flags="print,nozoom,norotate" open="no" > > > > > > page="0" rect="1780.690552,-92.000000,1964.690552,0.000000"/> > > > </line> > > > </annots> > > > </xfdf> > > > > > > > how was the xfdf generated. Can you compare to an xfdf generated > > when > > exporting using Adobe Acrobat? > > > > BR > > Maruan > > > > > > > > > > into either its original source or just a fresh, DIN A4 PDF with > > > a > > > single line of text created with PDFBox, Adobe Reader will > > > complain. > > > At this point, I switched from 2.0.29 to 3.0.0beta1 and the > > > result > > > was the same. > > > > > > In the resulting PDF, PDFDebugger shows what is in the attachment > > > - > > > an empty "NM" entry. > > > I then tried to set either "Name" or "NM" (and ultimately both) > > > in > > > dictionary of the PDAnnotation to "Line" with > > > > > > PDAnnotation a = > > > PDAnnotation.createAnnotation(xfdfAnnotation.getCOSObject()); > > > a.getCOSObject().setItem(COSName.NM, new COSString("Line")); > > > a.getCOSObject().setItem(COSName.NAME, new COSString("Line")); > > > > > > but while these values show up fine in PDFDebugger, > > > Adobe Reader will still complain. > > > > > > Would you happen to have more suggestions how I could work around > > > this please ? > > > > > > Thanks in advance, > > > > > > Kai > > > > > > -----Ursprüngliche Nachricht----- > > > Von: Tilman Hausherr <thaush...@t-online.de> > > > Gesendet: Dienstag, 1. August 2023 19:41 > > > An: users@pdfbox.apache.org > > > Betreff: Re: Adding annotations to PDFs - "expected a name > > > object" > > > > > > CAUTION - External Sender > > > > > > > > > Try to edit the xfdf file so that it has less annotations until > > > you > > > know > > > which one is the culprit. Then tell what names were in the xfdf > > > file. > > > Or > > > make a screenshot in PDFDebugger of that annotation, without the > > > text > > > content. > > > > > > Tilman > > > > > > On 01.08.2023 10:15, Kai Keggenhoff wrote: > > > > > > > > Hello everyone, > > > > > > > > we're using PDFBox to import annotations from XFDF files and > > > > add > > > > them > > > > to existing PDF files. > > > > > > > > First we create a FDFDocument from the XFDF, then we fetch the > > > > list > > > > of > > > > FDFAnnotations from it via > > > > > > > > < FDFDocument>.getCatalog().getFDF().getAnnotations() > > > > > > > > Then we iterate over this list, create PDAnnotations from the > > > > COS > > > > objects of the FDFAnnotation with > > > > PDAnnotation.createAnnotation() > > > > > > > > and add the PDAnnotation to the list of page annotations we got > > > > from > > > > PDPage.getAnnotations() > > > > > > > > For most PDFs and most XFDF files, this works without any > > > > issues. > > > > > > > > However, some PDF files with merged annotations, when opened in > > > > Adobe > > > > Reader, produce a huge number of popups with the message > > > > > > > > "Expected a name object" / "Namensobjekt wurde erwartet" > > > > > > > > before the PDF is fully rendered, while the original file does > > > > not > > > > show such a behaviour. > > > > > > > > When such PDF files are opened in Foxit PDF Reader or > > > > PDFDebugger, > > > > they are rendered just fine without errors. > > > > > > > > We saw this happen every now and then over the years, with all > > > > PDFBox > > > > V2 versions, including 2.0.29, > > > > > > > > but it appears to have become more frequent recently, so user > > > > complaints are becoming more frequent too. > > > > > > > > As I'm unable to share sample PDFs/XFDFs due to compliance > > > > reasons, > > > > I > > > > just have the question if anyone happens to have some hints > > > > > > > > what I could look for in an affected PDF (preferably using > > > > PDFDebugger) to find out what Adobe Reader doesn't like ? > > > > > > > > Ideally, I then can try to compare it with the original and > > > > find > > > > the > > > > part of the process which "breaks" the result. > > > > > > > > Thanks in advance, > > > > > > > > Kai > > > > > > > > < > > > > https://th/ > > > > inkproject.com%2Fde%2F&data=05%7C01%7CKai.Keggenhoff%40thinkpro > > > > je > > > > ct > > > > .com%7Cc2c7a48b704a43b51b5108db92b67c7e%7C066d0cfbe2e648f093a41 > > > > 5c > > > > 5c > > > > 8979a86%7C0%7C0%7C638265084694491778%7CUnknown%7CTWFpbGZsb3d8ey > > > > JW > > > > Ij > > > > oiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C > > > > 30 > > > > 00 > > > > %7C%7C%7C&sdata=F%2FQ4yYRr1Rv%2BwLcEM5cmp%2FW0uhVDtG8c9Xez%2FbX > > > > bB > > > > mo > > > > %3D&reserved=0> > > > > > > > > *Kai Keggenhoff* / Senior Software Developer > > > > > > > > *thinkproject.com*** > > > > < > > > > https://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2F > > > > thinkproject.com%2Fde&data=05%7C01%7CKai.Keggenhoff%40thinkproj > > > > ec > > > > t. > > > > com%7Cc2c7a48b704a43b51b5108db92b67c7e%7C066d0cfbe2e648f093a415 > > > > c5 > > > > c8 > > > > 979a86%7C0%7C0%7C638265084694491778%7CUnknown%7CTWFpbGZsb3d8eyJ > > > > WI > > > > jo > > > > iMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3 > > > > 00 > > > > 0% > > > > 7C%7C%7C&sdata=S%2BJ3yc8r9jXgFmH0tJ5zdielpbhIBkWXoL25FeyKhhU%3D > > > > &r > > > > es > > > > erved=0> > > > > > > > > < > > > > https://www.linkedin.com/company/thinkproject-dach/posts/?feedVie > > > > w%3Dall&data=05%7C01%7CKai.Keggenhoff%40thinkproject.com%7Cc2c7 > > > > a4 > > > > 8b > > > > 704a43b51b5108db92b67c7e%7C066d0cfbe2e648f093a415c5c8979a86%7C0 > > > > %7 > > > > C0 > > > > %7C638265084694649022%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM > > > > DA > > > > iL > > > > CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&s > > > > da > > > > ta > > > > =x%2F1HZ%2BHA4n9ftlBokoUWzEa5ubanynP%2B1CLSd4MlDUU%3D&reserved= > > > > 0> > > > > <h > > > > ttps://eur06.safelinks.protection.outlook.com/?url=https%3A%2F% > > > > 2F > > > > tw > > > > itter.com%2Fthinkproject_&data=05%7C01%7CKai.Keggenhoff%40think > > > > pr > > > > oj > > > > ect.com%7Cc2c7a48b704a43b51b5108db92b67c7e%7C066d0cfbe2e648f093 > > > > a4 > > > > 15 > > > > c5c8979a86%7C0%7C0%7C638265084694649022%7CUnknown%7CTWFpbGZsb3d > > > > 8e > > > > yJ > > > > WIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D > > > > %7 > > > > C3 > > > > 000%7C%7C%7C&sdata=w%2B4rE4F0udUxARyFQUa4EKbbjv7g%2F%2BK4IAubAm > > > > cB > > > > Qz > > > > k%3D&reserved=0> > > > > > > > > Read our legal information (imprint) here > > > > < > > > > https://th/ > > > > inkproject.com%2Fde%2Fimpressum%2F&data=05%7C01%7CKai.Keggenhof > > > > f% > > > > 40 > > > > thinkproject.com%7Cc2c7a48b704a43b51b5108db92b67c7e%7C066d0cfbe > > > > 2e > > > > 64 > > > > 8f093a415c5c8979a86%7C0%7C0%7C638265084694649022%7CUnknown%7CTW > > > > Fp > > > > bG > > > > Zsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXV > > > > CI > > > > 6M > > > > n0%3D%7C3000%7C%7C%7C&sdata=ZkWeKQuBmYmR1pRBcPIpdc5bo%2B8NWU9u8 > > > > Ul > > > > BW > > > > O26nao%3D&reserved=0>. > > > > > > > > > > ----------------------------------------------------------------- > > > -- > > > -- > > > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > > > For additional commands, e-mail: users-h...@pdfbox.apache.org > > > > > > ------------------------------------------------------------------- > > -- > > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > > For additional commands, e-mail: users-h...@pdfbox.apache.org > > > > > > ------------------------------------------------------------------- > > -- > > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > > For additional commands, e-mail: users-h...@pdfbox.apache.org > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > For additional commands, e-mail: users-h...@pdfbox.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > For additional commands, e-mail: users-h...@pdfbox.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org