Wow. Bummer. And here I thought iText could auto-magically do everything! To be 
honest, I had my doubts, but I wanted to be sure. I had the same disappointment 
with Apache PDFBox. It's great but doesn't quite do what I need it to do.

It sounds like a bit too much work. Unfortunately I don't have Acrobat and 
anyway, adding a Form to all of my ballots would be quite time-consuming; we 
have hundreds, and each one can have hundreds of Ovals.

It seems like it will be easier to just carry on doing it as before: 

1. convert the PDF to text using PDFReader and PDFStamper
2. look for the Ovals (at least now I have a better idea of how to identify 
Ovals!)
3. add '0 g' where I want to mark an Oval
4. save, open, read and write to a new non-corrupt PDF.

Incidentally, would you happen to know why PDFStamper sometimes doesn't convert 
all Streams to plain-text? Many times after converting a PDF I am left with 
blocks of streams, repersented in a text editor by binary characters. When I 
parse the file with a BufferedRead in Java it chokes. What I usually do is 
identify where the Streams are and when I come upon one, stop reading, and 
later just concatenate the Stream, which I have previously saved in a separate 
file, using a FileOutputStream.

But it's a kludge. Is there any way to convert the PDF to 100% text with no 
Stream/binary stuff?



>________________________________
> From: iText Info <[email protected]>
>To: Post all your questions about iText here 
><[email protected]> 
>Sent: Thursday, August 2, 2012 5:29 PM
>Subject: Re: [iText-questions] How to mark ovals in a pdf
> 
>
>Op 2/08/2012 17:04, Robert Bowen schreef:
>
>Is there any way to get all the 'Oval blocks' - the 6 lines, from '116.28 
>662.58 m' to 'b*' ? From the Dictionary? Catalog?
>I'm not saying it's impossible, but it's close to impossible.
>You'd have to write a custom content stream parser to detect
    specific sequences (moveTo, curveTo, curveTo,...).
>You'd have to keep track of the coordinates to:
>1. see if they are really ovals (and not some other curved shape
    with a different meaning),
>2. find out the right order of the ovals on the page.
>That's very difficult. An example of a custom content parser can be
    found here:
>http://itext.svn.sourceforge.net/viewvc/itext/trunk/xtra/src/main/java/com/itextpdf/text/pdf/ocg/
>It looks for Optional Content Groups with a specific name and then
    removes all the objects that belong to that group.
>
>You'd have to parse the content more than once:
>1. to identify the ovals and their order,
>2. to change the fill color of a specific oval.
>
>That's a huge work. If you don't have to many forms, I'd suggest you
    take Acrobat and add fields over the ovals, then fill out the
    fields. That's much easier (and the better solution).
>
>------------------------------------------------------------------------------
>Live Security Virtual Conference
>Exclusive live event will cover all the ways today's security and 
>threat landscape has changed and how IT managers can respond. Discussions 
>will include endpoint security, mobile security and the latest in malware 
>threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>_______________________________________________
>iText-questions mailing list
>[email protected]
>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
>
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
[email protected]
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