pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maruan Sahyoun <sahy...@fileaffairs.de>
Subject Re: XFDF support and errors
Date Wed, 05 Apr 2017 15:12:06 GMT
Hi,

> Am 05.04.2017 um 16:08 schrieb Stoll, Matthias <matthias.stoll@dxc.com>:
> 
> Hi Maruan,
> 
> I have uploaded a zip file here:
> http://www.stolli.de/downloads/xfdf/xfdf_test_package.zip 
> 
> It will be available there for the next 48 hours. Please download it from there and let
me know once done.
> 
> It contains:
> - XFDFStamper.java (the sample Java Class to "merge" XFDF and source PDF)
> - Annotation.xfdf (the sample XFDF file with the markups)
> - Source-Document-without-Annotation.pdf (the PDF file to be used to stamp the XFDF markups
onto)
> - Result-Document-with-Annotation-Adobe-OK.pdf (the merged PDF from Acrobat - works alright)
> - Result-Document-with-Annotation-PDFbox-NOTOK.pdf (the merged PDF from XFDFStamper via
PDFBox - does not work correctly in PDF.js)

I've taken a quick look and the reason is as I already suspected that there is no appearance
stream for the annotation. So the properties you are setting are fine but the visual representation
of the appearance is missing that's why you don't see anything in PDF.js as this is looking
for the appearance stream to render the annotation (which Adobe Acrobat  creates when you
load the XFDF/view the PDF). 

To create the appearance stream you'd need to look at the Root/Pages/Kids/[0]/Annots/[0]/AP/N
entry and resemble the content if you'd like to get the same result that Adobe Acrobat has.
Please be aware that the basiscs of an annotation are part of the PDF spec but the exact layout
definitions of how an annotation should look like (e.g. padding of text within a box etc.)
are not.

We started providing handlers for the various annotation types to create appearance streams
in the current trunk but FreeText is not yet among them. You might be willing to create a
patch for inclusion? Let me know if I can provide some further help.

BR
Maruan


> 
> Thanks in advance.
> 
> Herzliche Grüße / Best regards
> 
> Matthias Stoll
> Project Manager PMP®
> Application Business Services – Public Sector
> 
> T  +49 7031 450 5319
> M +49 151 1475 2248
> matthias.stoll@dxc.com  
> 
> EntServ Deutschland GmbH
> Schickardstr. 32
> 71034 Böblingen
> 
> dxc.technology / Twitter / Facebook / LinkedIn 
> 
> Geschäftsführer: Michael Eberhardt, Joachim Löffler
> Sitz der Gesellschaft: Böblingen, Amtsgericht Stuttgart HRB 757510
> VAT ID: DE307881136
> 
> -----Original Message-----
> From: Maruan Sahyoun [mailto:sahyoun@fileaffairs.de] 
> Sent: Mittwoch, 5. April 2017 15:36
> To: users@pdfbox.apache.org
> Subject: Re: XFDF support and errors
> 
> Hi,
> 
>> Am 05.04.2017 um 15:02 schrieb Stoll, Matthias <matthias.stoll@dxc.com>:
>> 
>> Hi Tilman,
>> 
>> This is a small follow-up to the case below.
>> My team and I have had much success in using PDFBox 2 with XFDF support. Thanks for
the fixes in late 2015.
>> 
>> Now recently we came across an issue we do not understand at all.
>> 
>> Again we do what the intention of the initial case was:
>> -        We have a PDF or PDF/A-1b document (source document)
>> -        We have a separate XFDF file for commenting which we “stamp” onto the
original PDF / PDF/A1-ab document to create a new PDF document 
>> -        This is done by a small Java class “XFDFStamper.java”
>> -        The XFDF sample is quite easy: basically a textbox with comment plus arrow.
>> -        This document shall be shown in the browsers
>> o    A) By using Internet Explorer with the Adobe Reade plugin
>> o    B) By using Chrome natively which in turn uses PDF.js
>> 
>> Strange thing now is:
>> -        IE with Adobe plugin renders the “stamped” PDF correctly
>> -        Chrome does not show the markups – it shows the text of the original document
– plus: when you hover the document with the mouse, at the location where the markup is,
a yellow comment box appears, like a big tooltip.
>> 
>> But: when you merge the 2 documents above via Adobe Acrobat, also Chrome displays
the markup correctly. So there must be a difference between what Adobe Acrobat does and what
PDFBox (or our code???) does.
>> 
>> I can provide the simple Java sample code plus the documents that show the difference
plus source document and respective XFDF.
>> 
>> We assume there must be something which is still wrong inside PDFBox or (same probability
J) we are doing wrong in our code. But we currently do not see the issue in our code.
> 
> 
> looks like you are not generating the appearance for the annotation.
> 
>> 
>> Can I provide that info to you for a small debugging? Where can I upload this (small
ZIP container)?
> 
> put it in a public location to take a look at.
> 
> BR
> Maruan
> 
>> 
>> Herzliche Grüße / Best regards
>> 
>> Matthias Stoll
>> Project Manager PMP®
>> Application Business Services – Public Sector
>> 
>> T  +49 7031 450 5319
>> M +49 151 1475 2248
>> matthias.stoll@dxc.com
>> 
>> EntServ Deutschland GmbH
>> Schickardstr. 32
>> 71034 Böblingen
>> 
>> dxc.technology / Twitter / Facebook / LinkedIn
>> 
>> Geschäftsführer: Michael Eberhardt, Joachim Löffler Sitz der 
>> Gesellschaft: Böblingen, Amtsgericht Stuttgart HRB 757510 VAT ID: 
>> DE307881136
>> 
>> From: Stoll, Matthias
>> Sent: Montag, 7. Dezember 2015 12:36
>> To: users@pdfbox.apache.org
>> Subject: XFDF support and errors
>> 
>> Dear All,
>> 
>> I am currently investigating in using PDFBox (my tests used PFDBox 2.0RC2) for a
small use case „stamping“ annotations from a given XFDF format (created by Qoppa’s jPDFEditor/jPDFNotes,
www.qoppa.com) into a given PDF/A-1b file.
>> 
>> This works with a surprisingly minimal set of Java code line J But: obviously not
all XFDF elements are supported and/or there are bugs in reading XFDF up to now. 
>> 
>> I just wanted to let you know about my experiences.
>> 
>> a)      Drawing lines painted by a pencil (element: “<gesture>”) do not
show up at all after stamping them. Why?
>> 
>> Sample data to test with:
>> <ink name="C2B070EBB736993EA25F4545350AD2C3" style="solid" width="4.0" 
>> flags="print" date="D:20151207122033+01&apos;00&apos;" color="#00ff00" 
>> opacity="1.0" page="0" subject="Bleistift" 
>> rect="62.4562,1378.1637,167.5599,1402.8388" 
>> title="matstoll"><inklist><gesture>68.4562,1385.1637;69.7534,1385.1637
>> ;73.6451,1385.1637;77.5368,1385.1637;82.7258,1387.7582;89.212,1389.055
>> 4;93.1037,1390.3525;96.9954,1390.3525;100.8871,1391.6498;104.7788,1392
>> .947;111.2649,1394.2443;116.4539,1394.2443;121.6428,1395.5415;125.5345
>> ,1395.5415;130.7235,1395.5415;134.6152,1395.5415;139.8041,1395.5415;14
>> 3.6958,1395.5415;148.8848,1395.5415;151.4792,1395.5415;155.3709,1396.8
>> 387;156.6682,1396.8387;157.9654,1396.8387;160.5599,1396.8387</gesture>
>> </inklist><contents>Pencil line</contents></ink>
>> 
>> b)     Polygons (at least when created with jPDFNotes) throw an exception when reading:
>> Exception in thread "main" java.lang.NumberFormatException: For input string: "1318.7075;1054.6517"
>>             at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
>>             at sun.misc.FloatingDecimal.parseFloat(Unknown Source)
>>             at java.lang.Float.parseFloat(Unknown Source)
>>             at org.apache.pdfbox.pdmodel.fdf.FDFAnnotationPolygon.initVertices(FDFAnnotationPolygon.java:101)
>>             at org.apache.pdfbox.pdmodel.fdf.FDFAnnotationPolygon.<init>(FDFAnnotationPolygon.java:78)
>>             at 
>> org.apache.pdfbox.pdmodel.fdf.FDFDictionary.<init>(FDFDictionary.java:
>> 196)
>> 
>> Sample data to test with:
>> <polygon name="534DC02A197B56578FFA6AE5F178100F" style="solid" 
>> width="9.0" flags="print" date="D:20151207121013+01&apos;00&apos;" 
>> color="#0000ff" opacity="1.0" page="0" subject="Polygon" 
>> rect="857.5527,1117.7167,1063.6517,1334.1936" title="matstoll"> 
>> <vertices>866.5527,1318.7075;1054.6517,1325.1936;1032.5987,1126.7167;8
>> 76.9306,1179.9034;866.5527,1318.7075;</vertices>
>> </polygon>
>> 
>> c)      A cloudy polygon cannot be read either – I assume a general issue reading
polygons.
>> 
>> Sample data to test with:
>> <polygon name="0276B0ECDCA680FDB0C0AE8377AE0FAA" style="cloudy" 
>> width="4.0" flags="print" date="D:20151207122247+01&apos;00&apos;" 
>> intensity="2" color="#ff5500" opacity="1.0" page="0" 
>> subject="Cloud/Wolke" rect="278.8037,1105.6361,563.5944,1216.9184" 
>> title="matstoll" 
>> IT="PolygonCloud"><vertices>310.0391,1147.4725;420.304,1205.8481;555.2
>> 164,1117.6361;342.4699,1117.6361;286.6888,1134.5002;310.0391,1147.4725
>> ;</vertices></polygon>
>> 
>> d)     A freetext (“<freetext>”) element will not show up correctly:
>> b1) Though “width=0.0” for the box, it PDFBox will render a box around 
>> the text
>> b2) Though font is set to “font: Courier 12pt; color:#000000” a wrong 
>> font will be rendered
>> b3) The color setting will be ignored: my tests setting a color of font and border
to red showed up a textbox with black border and black text.
>> 
>> e)      A freetext element with legend options does not show up correctly:
>> e1) Colors are wrong/ignored
>> e2) Font size not correct
>> e3) Legend arrow not drawn
>> 
>> Sample data to test with:
>> <freetext name="95DB90502D987FDE0DD5446ED48C098A" style="solid" 
>> width="3.0" justification="left" flags="print" 
>> date="D:20151207122813+01&apos;00&apos;" color="#4055ff" 
>> callout="356.7395,1471.7811,479.2464,1372.3664,494.2464,1327.1395" 
>> page="0" subject="Legend textfield" fringe="137.5069,-0.0,0.0,86.9147" 
>> rect="356.7395,1269.4126,704.3984,1471.7811" head="OpenArrow" 
>> title="matstoll" IT="FreeTextCallout"><contents>This is a legend with 
>> arrow</contents><defaultstyle>font: Courier 24pt; 
>> color:#BFAAFF</defaultstyle><defaultappearance>1.0 0.7490196078431373

>> 0.0 rg /Helv 12 Tf</defaultappearance></freetext>
>> 
>> There might be more of such issues – but I think this should be sufficient info
for now to check how to proceed.
>> 
>> Adobe Acrobat renders all these test cases correctly by the way, so I assume the
XFDF elements are all correct.
>> 
>> I can provide the sample code if needed – where shall I upload it – if needed?
>> 
>> As I do not find that much info about the support of XFDF in various PDF libraries
– what about the official support in PDFBox? Should all of the samples work? What are the
plans to do so?
>> 
>> Thanks a lot in advance.
>> 
>> Herzliche Grüße / Best regards
>> 
>> Matthias Stoll
>> Project Manager PMP®
>> Application Business Services – Public Sector
>> +49 7031 450 4509 Office
>> +49 151 1475 2248 Mobile
>> Herrenberger Strasse 140, 71034 Böblingen
>> 
>> matthias.stoll@hpe.com
>> 
>> 
>> 
>> Geschäftsführer: Heiko Meyer (Vorsitzender), Thomas Bässler, Volkhard 
>> Bregulla, Michael Eberhardt, Angelika Gifford, Ernst Reichart. 
>> Vorsitzender des Aufsichtsrats: Jörg Menno Harms Sitz der 
>> Gesellschaft: Böblingen, Amtsgericht Stuttgart HRB 244081 
>> WEEE-Reg.-Nr. DE 30409072
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message