OK, although I would NOT dispute that what I'm doing is still 
"dangerous", and am still open to alternative-suggestions, I found my 
issue for this particular test:

When using the tokeniser, PdfContentParser and PdfLiteral methods to 
parse the original stream (akin to the sample
OCGParser.java), the parenthesis were removed from around the text 
literal-string.  Until I flipped back and forth with RUPS to view the 
stream of the original and the "edited" version, I totally missed that 
the parenthesis were missing, so the PDF content was there, but the text 
was basically not.  I added the parenthesis back to the "Tj" operators' 
operand, and it all came back fine.

I still don't know how to remove metadata (versus add it with 
setMoreInfo), and I agree that this is not the best way to do this 
re-add of content.  I think adding it to the "over-content" is probably 
the best idea, but I have to figure out how to parse the font and 
location info for the text block, and am starting to peruse the PDF 
Reference Spec now.

Thanks again,
AJ

On 2/22/2012 9:12 AM, AJ Weber wrote:
>     I'm trying to append some content
> directly to the page's existing content-stream (it's already formatted
> with the correct operators&    operands, because I removed it previously).
>
>> What makes you think this will result in valid PDF syntax?
> Because I removed the exact block of PDF syntax from the stream in a
> previous step (and although it could be different, in this particular
> case, it was the last part of the Contents stream, so it's putting it
> back exactly where it was).
>
>>> Not only is the updated content not being written,
>> Maybe it is written, but not visible when you open the file in Adobe Reader.
> You are right here.  I checked the document with RUPS, and the stream
> has the additional block restored to the end of it, but it is not being
> displayed.  I'm unclear why that is, since, like I said, it's identical
> to what I originally removed, and in this case, it's in the exact same
> location of the stream.
>
>> What is ipText? Is it valid PDF syntax? Isn't it extremely dangerous
>> to append a snippet of PDF syntax like this? What are you trying to
>> achieve?
> It's the block of text extracted from the Contents stream in a previous
> step, exactly as it was in the Contents stream (it's a text block
> starting with BT and ending with ET).  I needed a temporary place to
> store it with the document; I considered creating an XObject and putting
> it there, but it would not be referenced in the temporary PDF file, and
> I was theorizing it could be stripped-out during an optimization, plus I
> didn't see a way to add the raw PDF syntax with the iText methods.
>
>> Aha, docinfo is a dictionary. More specifically: metadata.
>> You're using a method to add more metadata in an attempt to remove
>> metadata...
>> Also: you are adding some existing metadata to the content stream of a page.
> Is there a method to remove metadata from a document (instead of
> setMoreInfo? ).
> Yes, the metadata "value" is, as I mentioned, already valid PDF syntax,
> because I stored it there in a previous step.
>> I have no clue about what you're trying to achieve.
>> I only have an opinion: what you're doing is dangerous. I wouldn't do it.
> I appreciate your advice (very much).  My only other option would be to
> insert the text back on the document using getOverContent (I guess), but
> I would have to fully parse the text block (BT...ET) so I could
> understand setting the font, location, text, etc.  I thought extracting
> the block and re-inserting it exactly as it was would save me that trouble.
>
> ------------------------------------------------------------------------------
> Virtualization&  Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> iText(R) is a registered trademark of 1T3XT BVBA.
> Many questions posted to this list can (and will) be answered with a 
> reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples: 
> http://itextpdf.com/themes/keywords.php

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to