Thanks a lot! 
I tried It but I think there is something I can't see!
Originally I have the PDF content:
......73 0 obj<</XFA[(preamble)5 0 R(config)6 0 R(template)7 0 R(datasets)8 0 
R(localeSet)9 0 R(PDFSecurity)10 0 R(xmpmeta)11 0 R(xfdf)12 0 R(postamble)13 0 
R]/Fields[2 0 R]/DA(/Helv 0 Tf 0 g )/DR<</Font<</Helv 1 0 R/MyriadPro-Regular 
87 0 R>>>>>>endobj...7 0 obj<</Length 
22490/Filter[/FlateDecode]/Type/EmbeddedFile>>stream...endstreamendobj...
There isn't in the PDF any other place that links "7 0" template object than in 
"73 0". Then I have the code A):   // xfa_element_ind --> "7 0"   
PdfReader.killIndirect(xfa_element_ind);   PdfStream xfa_stream = new 
PdfStream(form_field_property_value);   PdfIndirectReference ref = 
writer.addToBody(xfa_stream, false).getIndirectReference();   
writer.getExtraCatalog().put(PdfName.XFA, ref);
 
As a result I get that addresses have been recalculated, an I have the 
information duplicated (the new one at "1 0" the original one at "11 0"):...1 0 
obj <</Length 42104>>stream ....... endstream...75 0 obj<</XFA[(preamble) 9 0 
R(config) 10 0 R(template) 11 0 R(datasets) 12 0 R(localeSet) 13 0 
R(PDFSecurity) 14 0 R(xmpmeta) 15 0 R(xfdf) 16 0 R(postamble) 17 0 R]/Fields[4 
0 R]/DR<</Font<</MyriadPro-Regular 77 0 R/Helv 3 0 R>>>>/DA(/Helv 0 Tf 0 g 
)>>endobj...11 0 obj <</Filter[/FlateDecode]/Type/EmbeddedFile/Length 
22490>>stream...endstreamendobj...
With next code B):    // xfa_element_ind --> "7 0"    
PdfReader.killIndirect(xfa_element_ind);    PdfStream xfa_stream = new 
PdfStream(form_field_property_value);    PdfIndirectReference ref = 
writer.addToBody(xfa_stream, xfa_element_ind, false).getIndirectReference();    
writer.getExtraCatalog().put(PdfName.XFA, ref);
I get the resultant PDF content:...7 0 obj <</Length 42104>>stream ....... 
endstream...74 0 obj<</XFA[(preamble) 8 0 R(config) 9 0 R(template) 10 0 
R(datasets) 11 0 R(localeSet) 12 0 R(PDFSecurity) 13 0 R(xmpmeta) 14 0 R(xfdf) 
15 0 R(postamble) 16 0 R]/Fields[3 0 R]/DR<</Font<</MyriadPro-Regular 76 0 
R/Helv 2 0 R>>>>/DA(/Helv 0 Tf 0 g )>>endobj...10 0 obj 
<</Filter[/FlateDecode]/Type/EmbeddedFile/Length 
22490>>stream...endstreamendobj...
This code is the same as A:    // xfa_element_ind --> "7 0"    
PdfIndirectReference ref = writer.addToBody(xfa_stream, 
false).getIndirectReference();    PdfReader.killIndirect(xfa_element_ind);    
writer.getExtraCatalog().put(PdfName.XFA, ref);                         An this 
one is like B:    // xfa_element_ind --> "7 0"    PdfIndirectReference ref = 
writer.addToBody(xfa_stream, xfa_element_ind, false).getIndirectReference();    
PdfReader.killIndirect(xfa_element_ind);    
writer.getExtraCatalog().put(PdfName.XFA, ref);
 
It's possible to make a direct replacement of stream bytes without changing 
references?
Perhaps there is another object that references to "7 0" and 'killIndirect' 
takes it into account and makes the recalculation to update it and possible 
'xrefs'?
 
I'm sorry, It's possible that I still haven't understood PDF concepts!
 
Thanks a lot!
Isma
 
> Date: Tue, 6 Nov 2007 10:29:59 +0000> From: [EMAIL PROTECTED]> To: 
> [email protected]> Subject: Re: [iText-questions] 
> Replacing PDF stream content> > You'll have to delete the old object with 
> PdfReader.killIndirect(PRIndirectReference).> > Paulo > > > -----Original 
> Message-----> > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On > > 
> Behalf Of Ismael F> > Sent: Tuesday, November 06, 2007 9:58 AM> > To: 
> [email protected]> > Subject: [iText-questions] Replacing 
> PDF stream content> > > > Hello everybody,> > > > I need to change, replace a 
> whole stream of bytes 'object' > > from a PDF. In this case those bytes 
> corresponds to a XFA form.> > > > The original PDF content is like:> > 
> %PDF-1.6> > %âãÏÓ> > 1 0 obj <</Type/Metadata/...> > ...> > ...> > 10 0 obj 
> <</Filter[/FlateDecode]/Type/EmbeddedFile/Length > > 22459>>stream ... 
> endstream> > 11 0 obj .......> > ...> > > > So I use this piece of code:> > 
> PdfIndirectReference ref = writer.addToBody(new > > 
> PdfStream(form_field_property_value), xfa_element_ind, > > 
> false).getIndirectReference();> > writer.getExtraCatalog().put(PdfName.XFA, 
> ref);> > > > where "xfa_element_ind" is "10 0", and corresponds to the > > 
> bytes adress that I want to replace.> > > > As a result I get this PDF 
> content:> > %PDF-1.6> > %âãÏÓ> > 10 0 obj <</Length 42101>>stream ... 
> endstream> > 1 0 obj <</Type/Metadata/...> > ...> > ...> > ...> > 10 0 obj 
> <</Filter[/FlateDecode]/Type/EmbeddedFile/Length > > 22459>>stream ... 
> endstream> > 11 0 obj .......> > ...> > > > As one can see the content has 
> not changed/replaced, is > > duplicated and I don't achieve the desired 
> result.> > > > How can I make a direct substitution/replacement to the > > 
> stream without duplicating content?> > Is It possible?> > How?> > > > I tried 
> diferent things but I'm not able to get it!> > > > Thanks a lot!> > > Aviso 
> Legal:> Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
> informação confidencial ou legalmente protegida. A incorrecta transmissão 
> desta mensagem não significa a perca de confidencialidade. Se esta mensagem 
> for recebida por engano, por favor envie-a de volta para o remetente e 
> apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o 
> destinatário de usar, revelar ou distribuir qualquer parte desta mensagem. > 
> > Disclaimer:> This message is destined exclusively to the intended receiver. 
> It may contain confidential or legally protected information. The incorrect 
> transmission of this message does not mean the loss of its confidentiality. 
> If this message is received by mistake, please send it back to the sender and 
> delete it from your system immediately. It is forbidden to any person who is 
> not the intended receiver to use, distribute or copy any part of this 
> message.> > 
> -------------------------------------------------------------------------> 
> This SF.net email is sponsored by: Splunk Inc.> Still grepping through log 
> files to find problems? Stop.> Now Search log events and configuration files 
> using AJAX and a browser.> Download your FREE copy of Splunk now >> 
> http://get.splunk.com/> _______________________________________________> 
> iText-questions mailing list> [email protected]> 
> https://lists.sourceforge.net/lists/listinfo/itext-questions> Buy the iText 
> book: http://itext.ugent.be/itext-in-action/
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to