pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From A...@swmc.com
Subject Re: need help for stream part in a PDF file
Date Wed, 25 Aug 2010 16:41:32 GMT
Mathieu,

Okay, now I understand your issue, and I think it's just related to 
streams (as opposed to AcroForms).  Unfortunately I don't know the answer, 
however I can give you a little insight as to how the objects work.  Maybe 
someone who's dealt with streams can add some more concise suggestions.

Streams must be preceded by a dictionary describing the length of the 
stream, optionally the filter, and so on (see section 7.3.8.1 of the PDF 
spec).  Then there's the actual stream data, which contains some kind of 
data, which could even be additional objects (see section 7.5.7 of the PDF 
spec).  In your case, it doesn't contain more objects as the /Type is not 
"ObjStm".  If I had to guess, I'd say it's an image that you have there.

The getDictionaryObject method is only going to give you the metadata, not 
your actual stream data.  As I said, I've never worked with AcroForms, so 
I'm not very familiar with the PDField class, but looking over the API[1] 
I'd say getCOSObject() may be of interest as well as getKids() and maybe 
getWidget().  I also see that there is a setValue() and setKids() methods 
which may help.

My suggestion would be to debug and looking through the structures in 
memory until you find the data you're looking for.  Once you find it, just 
look for methods that sound like they'll get you what you're looking for 
(and it's easy to see if it's in the object returned by a method when 
you're debugging).  That's how I figured most of the things I've done with 
PDFBox... a debugger and the Javadocs.  It's a fast way to learn just 
enough about the code to get the job done.

[1] 
http://www.pdfbox.org/javadoc/org/pdfbox/pdmodel/interactive/form/PDField.html

---- 
Thanks,
Adam





From:
mathieu fabre <mathieufab@gmail.com>
To:
users@pdfbox.apache.org
Cc:
Adam@swmc.com
Date:
08/25/2010 03:27
Subject:
Re: need help for stream part in a PDF file



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
> >     Hfield = (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



?  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.   
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message