[iText-questions] Appending docs with OCGs/Layers

2012-08-02 Thread Clive Webster
Tried subscribing but couldn't (some https error) - different story.

Environment: iText Version 5.3.1 for Java running on Win7 (64 bit)

 

The Challenge: to take several (could be 100's) of PDFs produced by InDesign
Server and stitch them together into a single PDF. The PDFs have layers/OCGs
for different language version of text but common layers like images and
prints marks.

 

The problem: 

1.   The 'easy' classes based on PdfCopy (tried all of them) don't
recognise OCGs and strip them out. Even if I add them manually by creating a
new PdfLayer. This is because they override the PdfWriter.close() method
which otherwise would write them out. The result is you get the objects for
each OCG/Layer in the output but the /Catalog doesn't list them so they
aren't used.

2.   Tried using 'PdfStamper' on the first PDF and then had to hack a
way to get it to append the pages from the remaining docs (getImportedPage).
This does keep the OCGs from the first document, it does append the
streams/dictionaries from the other documents - but it doesn't update the
/Pages dictionary to make the extra pages visible.

 

I haven't included examples - but just use a single PDF with layers and try
to create an output PDF that includes it a number of times. It's impossible.

 

Any help appreciated!

--
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
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

[iText-questions] Tiifwriter solution.

2012-08-02 Thread Pravin Wagh
Hi,

How could i write Pdf into Tiff and Png in itext.

it is possible in itext to write TIFF and Png images using classes in itext.

Please suggest some solution to do this .


Thanks
Pravin

--
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
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


Re: [iText-questions] Tiifwriter solution.

2012-08-02 Thread Alexis Pigeon
Hi Pravin,

On 2 August 2012 09:34, Pravin Wagh pravin.w...@capsilon.com wrote:

 Hi,

 How could i write Pdf into Tiff and Png in itext.

 it is possible in itext to write TIFF and Png images using classes in
 itext.

 Please suggest some solution to do this .


iText is a library for PDF creation and manipulation. Its purpose is not to
convert PDF to other formats.
See :
 http://support.itextpdf.com/node/21 
 http://itextpdf.com/itext.php  (last paragraph, Readins PDFs)

Cheers,
alexis
--
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
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

Re: [iText-questions] Tiifwriter solution.

2012-08-02 Thread TvT
You can not do this with iText but have a look at
http://www.jpedal.org/
http://www.jpedal.org/open_source_pdf_viewer_download.php

They have a commercial and a LGPL license available...

Regards,
ToM



2012/8/2 Pravin Wagh pravin.w...@capsilon.com

 Hi,

 How could i write Pdf into Tiff and Png in itext.

 it is possible in itext to write TIFF and Png images using classes in
 itext.

 Please suggest some solution to do this .


 Thanks
 Pravin


 --
 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
 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

--
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
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

Re: [iText-questions] How to read Tagged PDF in iText

2012-08-02 Thread Alexis Pigeon
Hi Raja Narayanan,

On 2 August 2012 12:04, Raja Narayanan rajanarayanan@gmail.com wrote:


 Hi,

I have one doubt in iText. In my web application(asp.net) i have
 uploaded the PDF file .If the PDF file have the Table now how to

   read the table in PDF.I have  attached my tagged PDF.Please kindly
 take it and help me.


That's the 3rd time you post the very same question on the mailing-list.
Please refrain from doing so. If you want to provide follow-up information,
reply to the answers that were sent to your original question, so that it
is all kept in the same thread.

Cheers,
alexis
--
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
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

Re: [iText-questions] How to read Tagged PDF in iText

2012-08-02 Thread iText Info

Op 2/08/2012 12:04, Raja Narayanan schreef:


Hi,

   I have one doubt in iText. In my web application(asp.net 
http://asp.net) i have uploaded the PDF file .If the PDF file have 
the Table now how to


  read the table in PDF.I have  attached my tagged PDF.Please 
kindly take it and help me.




Now that's indeed a Tagged PDF. When I parse it using iText, this is 
what I get:


TableTRTDFirst Name /TD
TDLast Name /TD
TDAge /TD
/TR
TRTDNarayanaan /TD
TDRaja /TD
TD24 /TD
/TR
TRTDRam /TD
TDSankar /TD
TD26 /TD
/TR
TRTDPrem /TD
TDKanth /TD
TD30 /TD
/TR
TRTDRaj /TD
TDYamah /TD
TD32 /TD
/TR
TRTDRani /TD
TDUma /TD
TD29 /TD
/TR
/Table

How to do it? Well... that's documented isn't it? http://1t3xt.be/?15e
You can save yourself plenty of time by reading the documentation. A 
nice side-effect is that it also saves us time not having to answer 
questions of which the answer is fully documented. If you save us time, 
we can write more documentation and more functionality. One could argue 
that by not reading the documentation, you steal time from us, and as 
such you steal functionality from your colleagues. That's bad for your 
Karma.
--
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
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

[iText-questions] How to mark ovals in a pdf

2012-08-02 Thread Robert Bowen
I have a ballot with a bunch of different contests (President, Vice-president, 
etc.) each with its candidates. Next to each candidate is an oval. I'd like to 
use iText to check a given oval for each contest.

The ovals are not within an AcroForm, and they are not checkboxes. I opened my 
pdf with Acrobat and selected a random oval and they seem to be just normal 
objects ... perhaps graphic objects, I'm not sure, I couldn't tell.

I used a combination of PDFReader, PDFStamper and Document to uncompress the 
PDF, to be able to edit it in a normal text editor, and it seems that each oval 
looks something like this:

01 g
89.04 650.52 41.22 24 re
f
1 J 1 j 0.2 w 10 M 
1 i 
116.28 662.58 m
116.28 664.56 112.44 666.12 107.7 666.12 c
102.96 666.12 99.12 664.56 99.12 662.58 c
99.12 660.6 102.96 658.98 107.7 658.98 c
112.44 658.98 116.28 660.6 116.28 662.58 c
b*


and if I manually add a '0 g' between '1 i' and '116.28 662.58 m', it marks the 
oval. But if I write a program in Java to do this, to add '0 g' for each oval, 
the resulting PDF is corrupt, because ... well, you can't just edit a PDF like 
that, you have to update the stream, the dictionary, etc.

Is there a way to do this with iText?

Cheers.--
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
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

Re: [iText-questions] How to mark ovals in a pdf

2012-08-02 Thread iText Info

Op 2/08/2012 12:17, Robert Bowen schreef:
I have a ballot with a bunch of different contests (President, 
Vice-president, etc.) each with its candidates. Next to each candidate 
is an oval. I'd like to use iText to check a given oval for each contest.


The ovals are not within an AcroForm, and they are not checkboxes. I 
opened my pdf with Acrobat and selected a random oval and they seem to 
be just normal objects ... perhaps graphic objects, I'm not sure, I 
couldn't tell.


I used a combination of PDFReader, PDFStamper and Document to 
uncompress the PDF, to be able to edit it in a normal text editor, and 
it seems that each oval looks something like this:


01 g
89.04 650.52 41.22 24 re
f
1 J 1 j 0.2 w 10 M
1 i
116.28 662.58 m
116.28 664.56 112.44 666.12 107.7 666.12 c
102.96 666.12 99.12 664.56 99.12 662.58 c
99.12 660.6 102.96 658.98 107.7 658.98 c
112.44 658.98 116.28 660.6 116.28 662.58 c
b*


and if I manually add a '0 g' between '1 i' and '116.28 662.58 m', it 
marks the oval. But if I write a program in Java to do this, to add '0 
g' for each oval, the resulting PDF is corrupt, because ... well, you 
can't just edit a PDF like that, you have to update the stream, the 
dictionary, etc.


The path of the oval is defined using one moveTo (m) and four curveTo 
(c) operators.

The path is drawn using a closePathEoFillStroke command (b*).
Close path means: add a path between start and end point if the curves 
don't form a closed shape
Eo means: use the Even-Odd algorithm to find out which areas need to be 
filled.

Fill means: fill the shape using the fill color
Stroke means: draw the borders using the stroke color

The fill color is defined with the g operator: 01 is the gray fill value 
(0 is black, 1 is white).
The line width is 0.2 user units (w), but I don't see any operator 
defining the stroke color (maybe it's just the default: black).


If you manually add 0 g after 2 i, then the fill color will be 
black, but you need to be very careful when doing so.
If you're sure about the PDF syntax, then this is a code sample I used 
to change the content of a form XObject.

I'm sure you can adapt it to change the content stream of the page:

// read file my.pdf
PdfReader r = new PdfReader(my.pdf);
// get page dictionary of page 1
PdfDictionary p = r.getPageN(1);
// get the resources
PdfDictionary ps = p.getAsDict(PdfName.RESOURCES);
// get the XObjects
PdfDictionary xo = ps.getAsDict(PdfName.XOBJECT);
// get the content stream of a specific XObject identified by key
PRStream stream = (PRStream)xo.getAsStream(key);
// change its content (in this case: empty the content)
stream.setData(new byte[]{});
// create a new (altered) PDF
PdfStamper stamper = new PdfStamper(r, new FileOutputStream(new.pdf));
stamper.close();

With this code, the structure of your PDF will not be corrupted.
However: if you use the wrong bytes, you can corrupt the content of a page.
Reading the syntax snippet however, I have the impression you know what 
you're doing.
--
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
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

Re: [iText-questions] PHP port in the works

2012-08-02 Thread wouter adem
Hi Bruno,

it's been a while since I wrote my original post. 

As I understood you and Dries have had a talk about possible future plans
concerning Drupal and iText. I'm really interested in what has been said in
that talk. If possible and ready, could you share some of the ideas?

Regards,
Wouter



--
View this message in context: 
http://itext-general.2136553.n4.nabble.com/PHP-port-in-the-works-tp2154422p4655775.html
Sent from the iText - General mailing list archive at Nabble.com.

--
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
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


Re: [iText-questions] PHP port in the works

2012-08-02 Thread Bruno Lowagie
Op 2/08/2012 14:01, wouter adem schreef:
 Hi Bruno,

 it's been a while since I wrote my original post.

 As I understood you and Dries have had a talk about possible future plans
 concerning Drupal and iText. I'm really interested in what has been said in
 that talk. If possible and ready, could you share some of the ideas?

We've discussed this, and we agreed that it didn't make sense to invest 
time in a PHP port. It makes much more sense investing in Cloud services 
offering PDF functionality served on either a Java or a Windows platform.

Services are becoming more and more languages agnostic, and that's the 
way to go. There used to be a time when setting up a Java server was a 
huge hurdle versus setting up a PHP server, but that was a problem of 
the previous century.

Moreover while PHP is fine for Drupal, it isn't an ideal language to 
write a component that produces PDF. Sure, you could write something 
that creates simple PDFs or that fills out forms, but you'll have a hard 
time writing a PHP library that is able to deal with the more complex stuff.

Bottom line: we dismissed the idea of investing in a PHP port in favor 
of connecting to a PDF service (hosted on a Java server) from Drupal.

By the way: I like writing PHP, but I've never considered writing a PHP 
port. Other people have offered to write a PHP port of iText, but AFAIK 
not one of them succeeded.

best regards,
Bruno

--
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
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


Re: [iText-questions] How to mark ovals in a pdf

2012-08-02 Thread Robert Bowen
Hello and thank you for the helpful response, and the great explanation of that 
each of those commands do. I've read the PDF Reference but it's HUGE and a lot 
of it is over my head, and most of it isn't applicable to what I need to do.

I've been trying to modify your code ... I get the general idea. However, there 
are some basic problems with your approach with regards to what I need to do.

First, I don't think I can work at the Stream level, since the Ovals are 
scattered all over the place, in different streams. Plus, I don't have a 'key' 
to look for. What I need to do (I think) is to be able to get all Ovals and 
then programmatically mark the 1st one ... the 5th one ... the 99th one, etc.

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?

How would I add a new 'g operator' to the 'block' ?

I know what I am doing when working with the PDF as text but I would prefer NOT 
to work that way (which is why I am trying to use iText) since 1) in order to 
even begin working with a PDF as text I have to use PDFReader and PDFStamper to 
turn it into text, and even doing that sometimes some streams aren't converted, 
and 2) if I add anything it corrupts the document, forcing me to take the 
corrupt document and use iText to read it and then write it to a new, 
non-corrupt document.

Any help much obliged ...




 From: iText Info i...@1t3xt.info
To: itext-questions@lists.sourceforge.net 
Sent: Thursday, August 2, 2012 12:38 PM
Subject: Re: [iText-questions] How to mark ovals in a pdf
 

Op 2/08/2012 12:17, Robert Bowen schreef:

I have a ballot with a bunch of different contests (President, Vice-president, 
etc.) each with its candidates. Next to each candidate is an oval. I'd like to 
use iText to check a given oval for each contest.


The ovals are not within an AcroForm, and they are not checkboxes. I opened 
my pdf with Acrobat and selected a random oval and they seem to be just 
normal objects ... perhaps graphic objects, I'm not sure, I couldn't tell.


I used a combination of PDFReader, PDFStamper and Document to uncompress the 
PDF, to be able to edit it in a normal text editor, and it seems that each 
oval looks something like this:


01 g
89.04 650.52 41.22 24 re
f
1 J 1 j 0.2 w 10 M 
1 i 
116.28 662.58 m
116.28 664.56 112.44 666.12 107.7 666.12 c
102.96 666.12 99.12 664.56 99.12 662.58 c
99.12 660.6 102.96 658.98 107.7 658.98 c
112.44 658.98 116.28 660.6 116.28 662.58 c
b*


and if I manually add a '0 g' between '1 i' and '116.28 662.58 m', it marks 
the oval. But if I write a program in Java to do this, to add '0 g' for each 
oval, the resulting PDF is corrupt, because ... well, you can't just edit a 
PDF like that, you have to update the stream, the dictionary, etc.

The path of the oval is defined using one moveTo (m) and four
curveTo (c) operators.
The path is drawn using a closePathEoFillStroke command (b*).
Close path means: add a path between start and end point if the
curves don't form a closed shape
Eo means: use the Even-Odd algorithm to find out which areas need to
be filled.
Fill means: fill the shape using the fill color
Stroke means: draw the borders using the stroke color

The fill color is defined with the g operator: 01 is the gray fill
value (0 is black, 1 is white).
The line width is 0.2 user units (w), but I don't see any operator
defining the stroke color (maybe it's just the default: black).

If you manually add 0 g after 2 i, then the fill color will be
black, but you need to be very careful when doing so.
If you're sure about the PDF syntax, then this is a code sample I
used to change the content of a form XObject.
I'm sure you can adapt it to change the content stream of the page:

// read file my.pdf
PdfReader r = new PdfReader(my.pdf);
// get page dictionary of page 1
PdfDictionary p = r.getPageN(1);
// get the resources
PdfDictionary ps = p.getAsDict(PdfName.RESOURCES);
// get the XObjects 
PdfDictionary xo = ps.getAsDict(PdfName.XOBJECT);
// get the content stream of a specific XObject identified by key
PRStream stream = (PRStream)xo.getAsStream(key);
// change its content (in this case: empty the content)
stream.setData(new byte[]{});
// create a new (altered) PDF
PdfStamper stamper = new PdfStamper(r, new
FileOutputStream(new.pdf));
stamper.close();

With this code, the structure of your PDF will not be corrupted.
However: if you use the wrong bytes, you can corrupt the content of
a page.
Reading the syntax snippet however, I have the impression you know
what you're doing.

--
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. 

Re: [iText-questions] How to mark ovals in a pdf

2012-08-02 Thread iText Info

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
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

Re: [iText-questions] How to mark ovals in a pdf

2012-08-02 Thread Robert Bowen
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 i...@1t3xt.info
To: Post all your questions about iText here 
itext-questions@lists.sourceforge.net 
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
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

--
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
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

Re: [iText-questions] How to mark ovals in a pdf

2012-08-02 Thread 1T3XT BVBA
On 2/08/2012 18:01, Robert Bowen wrote:
 Incidentally, would you happen to know why PDFStamper sometimes 
 doesn't convert all Streams to plain-text?
It depends on how you try to convert the streams to plain text.
Maybe you're omitting the Form XObjects; maybe you're talking about 
image streams (raster images that is).
Not everything inside a PDF is expressed in PDF syntax.

--
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
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


Re: [iText-questions] PHP port in the works

2012-08-02 Thread wizonesolutions
The guys at SetaSign maintain PHP libraries of their own design, for what
it's worth.

I run the PDF service potentially alluded to. Check the Fill PDF module
in Drupal.

Looks like I have to hone my Java skills. Darn.
On Aug 2, 2012 5:55 AM, blowagie [via iText - General] 
ml-node+s2136553n4655776...@n4.nabble.com wrote:

 Op 2/08/2012 14:01, wouter adem schreef:
  Hi Bruno,
 
  it's been a while since I wrote my original post.
 
  As I understood you and Dries have had a talk about possible future
 plans
  concerning Drupal and iText. I'm really interested in what has been said
 in
  that talk. If possible and ready, could you share some of the ideas?

 We've discussed this, and we agreed that it didn't make sense to invest
 time in a PHP port. It makes much more sense investing in Cloud services
 offering PDF functionality served on either a Java or a Windows platform.

 Services are becoming more and more languages agnostic, and that's the
 way to go. There used to be a time when setting up a Java server was a
 huge hurdle versus setting up a PHP server, but that was a problem of
 the previous century.

 Moreover while PHP is fine for Drupal, it isn't an ideal language to
 write a component that produces PDF. Sure, you could write something
 that creates simple PDFs or that fills out forms, but you'll have a hard
 time writing a PHP library that is able to deal with the more complex
 stuff.

 Bottom line: we dismissed the idea of investing in a PHP port in favor
 of connecting to a PDF service (hosted on a Java server) from Drupal.

 By the way: I like writing PHP, but I've never considered writing a PHP
 port. Other people have offered to write a PHP port of iText, but AFAIK
 not one of them succeeded.

 best regards,
 Bruno

 --

 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
 [hidden email] http://user/SendEmail.jtp?type=nodenode=4655776i=0
 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


 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://itext-general.2136553.n4.nabble.com/PHP-port-in-the-works-tp2154422p4655776.html
  To unsubscribe from PHP port in the works, click 
 herehttp://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=2154422code=dnJAd2l6b25lc29sdXRpb25zLmNvbXwyMTU0NDIyfDE0NzA5MjUyMzM=
 .
 NAMLhttp://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml





--
View this message in context: 
http://itext-general.2136553.n4.nabble.com/PHP-port-in-the-works-tp2154422p4655781.html
Sent from the iText - General mailing list archive at Nabble.com.--
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
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

[iText-questions] Write out appearance streams for annotations?

2012-08-02 Thread Suneet Shah
Hello,

I'm using iTextSharp to write out PDF annotations-- however I noticed that
the following code doesn't actually write out an appearance stream for the
annotation.

A lot of the PDF viewers don't display annotations if they don't have an
appearance stream.

How can we write out a proper appearance stream for annotations from Itext?
Given the example below, how would you do it?

Do they have to be constructed manually (e.g. at a low level) or is there
an easy way to do it?

Highlight annotation:
---

//Create a new file from our test file with highlighting
string highLightFile = Highlighted.pdf;

//Bind a reader and stamper to our test PDF
PdfReader reader = new PdfReader(outputFile);

using (FileStream fs = new FileStream(highLightFile,
FileMode.Create, FileAccess.Write, FileShare.None))
{
using (PdfStamper stamper = new PdfStamper(reader, fs))
{
//Create a rectangle for the highlight. NOTE:
Technically this isn't used but it helps with the quadpoint calculation
iTextSharp.text.Rectangle rect = new
iTextSharp.text.Rectangle(60.6755f, 749.172f, 94.0195f, 735.3f);
//Create an array of quad points based on that
rectangle. NOTE: The order below doesn't appear to match the actual spec
but is what Acrobat produces
float[] quad = { rect.Left, rect.Bottom, rect.Right,
rect.Bottom, rect.Left, rect.Top, rect.Right, rect.Top };

//Create our hightlight
PdfAnnotation highlight =
PdfAnnotation.CreateMarkup(stamper.Writer, rect, null,
PdfAnnotation.MARKUP_HIGHLIGHT, quad);

//Set the color
highlight.Color = BaseColor.YELLOW;

//Add the annotation
stamper.AddAnnotation(highlight, 1);
}
}


Thanks,
--
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
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

Re: [iText-questions] losting tags when copying with PdfImportedPage/Pdf(Smart)Copy

2012-08-02 Thread Walter Cybis
On 01/08/2012 02:33, 1T3XT BVBA wrote:
 Hi,
 
   Is there a way to preserve the tags in an original taggedPDF when we
   copy it using Pdf(Smart)Copy, PdfImportedPage and PageStamp objects ?
 The tags are kept in the content stream, but the StructTreeRoot and the
 MarkInfo is lost. It's your responsibility to adapt the StructTreeRoot
 correctly and add it along with the MarkInfo if you use PdfCopy.


The tags are lost if I copy the old file's StructTreeRoot to the new 
file's catalog.
As you've said I have to adapt the StructTreeRoot correctely.
Could you give some advise on how to adapt an old StructTreeRoot to a 
new file?


Thanks again,

Walter


--
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
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


Re: [iText-questions] losting tags when copying with PdfImportedPage/Pdf(Smart)Copy

2012-08-02 Thread Leonard Rosenthol
Read the relevant chapters on Tagging and Structure in ISO 32000-1:2008.

There is no shortcut on this one :(.   I'd give yourself at least 2-4 weeks, 
minimum.

-Original Message-
From: Walter Cybis [mailto:walter.cy...@polymtl.ca] 
Sent: Thursday, August 02, 2012 7:52 PM
To: itext-questions@lists.sourceforge.net
Subject: Re: [iText-questions] losting tags when copying with 
PdfImportedPage/Pdf(Smart)Copy

On 01/08/2012 02:33, 1T3XT BVBA wrote:
 Hi,
 
   Is there a way to preserve the tags in an original taggedPDF when 
  we  copy it using Pdf(Smart)Copy, PdfImportedPage and PageStamp objects ?
 The tags are kept in the content stream, but the StructTreeRoot and 
 the MarkInfo is lost. It's your responsibility to adapt the 
 StructTreeRoot correctly and add it along with the MarkInfo if you use 
 PdfCopy.


The tags are lost if I copy the old file's StructTreeRoot to the new file's 
catalog.
As you've said I have to adapt the StructTreeRoot correctely.
Could you give some advise on how to adapt an old StructTreeRoot to a new file?


Thanks again,

Walter


--
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
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

--
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
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