oleole wrote:
I know pdfbox is the right solution but it would
require using two more libraries since I'm using .net.
The application I'm doing is only temporary so I don't
mind a little "bricolage" with iText in order to get
the result.
Since you apparently don't deny I can do that in iText
would you just give me an hint on which class(es) to
use ?
I'll give you a snippet from chapter 18 from the upcoming book:
PdfReader reader = new PdfReader("HelloWorld.pdf");
PdfDictionary page = reader.getPageN(1); // content of page 1
PRIndirectReference objectReference = (PRIndirectReference)
page.get(PdfName.CONTENTS);
PRStream stream = (PRStream) PdfReader.getPdfObject(objectReference);
byte[] streamBytes = PdfReader.getStreamBytes(stream);
PRTokeniser tokenizer = new PRTokeniser(streamBytes);
while (tokenizer.nextToken()) {
if (tokenizer.getTokenType() == PRTokeniser.TK_STRING) {
System.out.println(tokenizer.getStringValue());
}
}
It won't work on all your PDFs, but if your PDF is generated
with iText in a sequence of document.add statements using a
'normal' font, it will give you a more or less good result.
If the PDFs are generated with another tool, you can get very
odd results. You'll have to wait for the book for the complete
explanation ;-)
br,
Bruno
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions