pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mathieu fabre <mathieu...@gmail.com>
Subject Re: need help for stream part in a PDF file
Date Wed, 25 Aug 2010 10:25:27 GMT
Adam, thanks for your answer.

First, in my JAVA code, at the end of the method, I have put the doc.save()
and doc.close() methods.
So the document is correctly saved/updated and closed.
My problem is not really an exception issue, because I don't have any
exception.

In fact, I just don't know how to have access to the STREAM part of the
COSObject/COSDictionnary.
I don't know the way to change the stream content. I suppose that I can have
access to the stream content
when I have access to its container object, but i don't know how...

I try to have a look at the Javadoc API but I didin't find the solution :(.

In my JAVA code, with the line :

COSDictionary iField = (COSDictionary)mkField.getDictionaryObject(cosName2);

iField is supposed to be my COSObject/COSDictionnary that I want to modify
the stream part.
I checked it was the good object by printing it.
But there is not method such as iField.setStream()

Regars,


2010/8/24 <Adam@swmc.com>

> The code you posted doesn't call any of the doc.save() methods.  It also
> never sets anything in the acroform.  What version of PDFBox are you
> using?  When you say it doesn't work, do you mean it throws an exception?
> Is this only an issue with AcroForm, or with the entire PDF (i.e. Can you
> make other changes to the PDF and save them properly)?  Can you provide
> all your code and put the PDF online somewhere and send us a link so we
> can try to duplicate the issue?
>
> I haven't dealt with AcroForms at all, so I'm not sure I can help you, but
> I can tell you that we'll at least need the code which updates & saves the
> data before we can help with why it won't update & save.
>
> ----
> Thanks,
> Adam
>
>
> From:
> mathieu fabre <mathieufab@gmail.com>
> To:
> users@pdfbox.apache.org
> Date:
> 08/24/2010 14:09
> Subject:
> Re: need help for stream part in a PDF file
>
>
>
> No one can help me for this problem ...?
>
> 2010/8/13 mathieu fabre <mathieufab@gmail.com>
>
> > Hi,
> >
> > I recently use the PDFBox librairy and I would like to change the stream
> > part of an object which is an AcroForm Object (a stream in PDF Form
> object).
> >
> > in the PDF, for example we have this:
> > *
> > 83 0 obj<</Subtype/Form
> > /Length 637
> > /Filter[/FlateDecode]
> > /Name/FRM
> > /Matrix[1.0 0.0 0.0 1.0 -9.21249 -82.235]
> > /Resources 214 0 R
> > /Type/XObject
> > /BBox[0.0 0.0599976 18.425 164.41]
> > /FormType 1>>
> > stream
> >
> > some stream unreadable... that i want to change with other stream
> >
> > endstream
> > endobj*
> >
> >
> > In the JAVA code, i am able to go to the object with the code :
> >
> > // Create the PDF Document
> > PDDocument doc = PDDocument.load(myFile);
> >
> > // Extract the catalog
> > PDDocumentCatalog catalog = doc.getDocumentCatalog();
> >
> > // Retrieve the AcroForm
> > PDAcroForm acroForm = catalog.getAcroForm();
> >
> > // Retrieve all fields that should be change
> > List listField = acroForm.getFields();
> > Iterator<PDField> it = listField.iterator();
> >
> > // Loop on each field
> > while(it.hasNext())
> > {
> >     // Cast to PDField
> >     PDField field = (PDField)it.next();
> >
> >     // Retrive the COSObject containing the stream part
> >     COSDictionary dicoField = (COSDictionary)field.getCOSObject();
> >     COSDictionary mkField =
> > (COSDictionary)dicoField.getDictionaryObject(cosName1);
> >     COSDictionary iField =
> > (COSDictionary)mkField.getDictionaryObject(cosName2);
> >
> >     // Here, i am on the good object (83 0) and if I print the iField, I
> > obtain same information as in the PDF file
> >     // But I am not able to have acces to the STREAM part of the
> > COSObject/COSDictionary
> > }
> >
> > Could you help please ? I don't know how to change the stream part. I
> > thought the COSOject could give me this possibility... :|
> >
> > Thanks, in advance
> >
> > --
> > Mat
> >
>
>
>
> --
> Mat
>
>
>
> ?  Click here to submit conditions
>
> This email and any content within or attached hereto from  Sun West
> Mortgage Company, Inc.  is confidential and/or legally privileged. The
> information is intended only for the use of the individual or entity named
> on this email. If you are not the intended recipient, you are hereby
> notified that any disclosure, copying, distribution or the taking of any
> action in reliance on the contents of this email information is strictly
> prohibited, and that the documents should be returned to this office
> immediately by email. Receipt by anyone other than the intended recipient is
> not a waiver of any privilege. Please do not include your social security
> number, account number, or any other personal or financial information in
> the content of the email. Should you have any questions, please call  (800)
> 453 7884.




-- 
Mat

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message