Hi,

I'm trying to split a pdf file according to an array of offsets and
fragment's lengths. I have found the following solution, but I am not sure
if it is the right way to do it.

PdfReader reader = new PdfReader("myfile.pdf");
 
for (int i = 0; i < beginIndexArray.length; i++) {
 
 FileOutputStream foStream = new FileOutputStream("myfragment"+i+".pdf");
 PRStream prStream = new PRStream(reader, beginIndexArray[i] );
 prStream.setLength(fragmentLengthArray[i] );
 Document pdfFragmentDoc = new Document();
 PdfWriter pdfFragmentWriter = PdfWriter.getInstance(pdfFragmentDoc , 
foStream);
 prStream.toPdf(pdfFragmentWriter, foStream);
}

The javadoc API is not very clear about the use of toPdf() method. At the
end, I have fragments of the pdf file, they are readable by Acrobat 8, but
opening it with PDF-Analyzer
(http://www.softpedia.com/get/Office-tools/PDF/PDFAnalyzer.shtml) leads to
an error message. 
Any help would be greatly appreciated. Thanks!

Amir
-- 
View this message in context: 
http://www.nabble.com/Split-a-PDF-file-according-to-offset-and-length-tp15980301p15980301.html
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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