pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maruan Sahyoun <sahy...@fileaffairs.de>
Subject Re: Adding annotations from XFDF file to PDF document
Date Fri, 17 Apr 2015 09:43:45 GMT
Hi,

> Am 16.04.2015 um 14:29 schrieb Johanneke Lamberink <johanneke.lamberink@onior.com>:
> 
> Hi
> 
> Thank you. In the meantime, I have some code that would probably be
> helpful. What would be the best way to get my code in the API?
> 

still looking for your code :-)

with the latest changes to the current trunk you can now do 

        PDDocument doc = PDDocument.load(new File("example-pdf.pdf"));
        FDFDocument fdf = FDFDocument.loadXFDF(new File("example-xfdf.xml"));
        
        List<FDFAnnotation> fdfAnnots = fdf.getCatalog().getFDF().getAnnotations();

        for (FDFAnnotation fdfAnnot : fdfAnnots)
        {
            PDPage page = doc.getPage(fdfAnnot.getPage());
            List<PDAnnotation> pageAnnots = page.getAnnotations();
            pageAnnots.add(PDAnnotation.createAnnotation(fdfAnnot.getCOSDictionary()));
        }
        

So that gives you at least some basic support.

BR
Maruan


> Kind regards,
> 
> Johanneke Lamberink
> 
> 
> 
> Op 16/4/15 14:15 schreef Maruan Sahyoun <sahyoun@fileaffairs.de>:
> 
>> Hi,
>> 
>> I've created https://issues.apache.org/jira/browse/PDFBOX-2758 for that
>> 
>> BR
>> Maruan
>> 
>> 
>>> Am 15.04.2015 um 17:37 schrieb Johanneke Lamberink
>>> <johanneke.lamberink@onior.com>:
>>> 
>>> Hi,
>>> 
>>> 
>>> Op 15/4/15 11:45 schreef Maruan Sahyoun <sahyoun@fileaffairs.de>:
>>> 
>>>> Hi,
>>>> 
>>>>> Am 15.04.2015 um 10:44 schrieb Johanneke Lamberink
>>>>> <johanneke.lamberink@onior.com>:
>>>>> 
>>>>> Hi, 
>>>>> 
>>>>> 
>>>>> Thank you for replying.
>>>>> 
>>>>> I did try using ImportXFDF. Unfortunately, this will only load the
>>>>> ³text²
>>>>> annotation and throws an IOException when any other annotation is
>>>>> encountered. 
>>>>> 
>>>> 
>>>> could you upload a sample pdf and xfdf to a public location to take a
>>>> look?
>>> 
>>> I’ve made a .zip with 4 files, which you can download here:
>>> 
>>> https://onior-my.sharepoint.com/personal/johanneke_lamberink_onior_com/_l
>>> ay
>>> 
>>> outs/15/guestaccess.aspx?guestaccesstoken=9nNR9UdnjlmoU%2fHn9qhqXbT%2b2uW
>>> MR
>>> 5ar4CkFZjTb%2bbk%3d&docid=0f88504e606374b2fa948af871a8fb107
>>> 
>>> The files are a PDF file (example-pdf.pdf), an XFDF file
>>> (example-xfdf.xml), a screenshot of the annotations that I made
>>> (example.jpg) and a screenshot of the code used and the resulting output
>>> (example-output.png).
>>> 
>>> Please let me know if you need more information :)
>>> 
>>> Kind regards,
>>> 
>>> Johanneke Lamberink
>>> 
>>>> 
>>>> BR
>>>> Maruan
>>>> 
>>>>> 
>>>>> Having had a look at the current trunk, I¹m not sure what the
>>>>> improvements
>>>>> should be. In the code regarding FDF/XFDF I don¹t see any significant
>>>>> changes.
>>>>> 
>>>>> 
>>>>> Kind regards,
>>>>> 
>>>>> Johanneke Lamberink
>>>>> 
>>>>> Op 14/4/15 18:15 schreef Andreas Lehmkuehler <andreas@lehmi.de>:
>>>>> 
>>>>>> Hi,
>>>>>> 
>>>>>> Am 14.04.2015 um 15:06 schrieb Johanneke Lamberink:
>>>>>>> Hi,
>>>>>>> 
>>>>>>> As part of a bigger application, I am trying to use PDFBox to
>>>>>>> combine
>>>>>>> a
>>>>>>> separate XFDF file containing annotations with a PDF document.
The
>>>>>>> result should be a PDF document with annotations.
>>>>>>> 
>>>>>>> Unless I'm mistaken, PDFBox has no support for parsing XFDF
>>>>>>> annotations
>>>>>>> at this time. Are there any plans to implement this?
>>>>>>> In an attempt to implement it myself, I have been parsing the
XFDF
>>>>>>> file
>>>>>>> to create FDFAnnotation objects and then using those FDFAnnotation
>>>>>>> objects to create PDAnnotation objects. So far so good. However,
the
>>>>>>> FDFAnnotation class and it's various subclasses for different
>>>>>>> annotations do not support the attributes that are required for
>>>>>>> specific
>>>>>>> annotations.
>>>>>>> A result of this is that I have to parse String input to PDFont
and
>>>>>>> PDColorspace objects (for example), and I can't discover how
to do
>>>>>>> this.
>>>>>>> 
>>>>>>> For now, I have 3 questions:
>>>>>>> 
>>>>>>> *   how do I create a PDFont object from (for example) "/Helvetica
>>>>>>> 18 Tf"
>>>>>>> *   how do I create a PDColorSpace object from (for example)
"0.000
>>>>>>> 0.000 0.000 rg"
>>>>>>> *   What are your suggestions for continuing with my project.
>>>>>>> Continue working on my own solution, or implement support for
XFDF
>>>>>>> annotations in PDFBox? Is anyone already working on this?
>>>>>>> 
>>>>>>> Any help is greatly appreciated :)
>>>>>> I'm not a XFDF expert, but did you ever give
>>>>>> org.apache.pdfbox.tools.ImportXFDF
>>>>>> a try? Maybe that's the missing piece you are looking for ...
>>>>>> 
>>>>>> P.S.: You should use the current trunk due to some recent
>>>>>> improvements
>>>>>> trageting 
>>>>>> that specific area.
>>>>>> 
>>>>>>> Johanneke Lamberink
>>>>>> 
>>>>>> 
>>>>>> BR
>>>>>> Andreas Lehmkühler
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> ---------------------------------------------------------------------
>>>>>> 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
>>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message