Whatever it was it works correctly in iTextSharp 5.04.

Paulo
  ----- Original Message ----- 
  From: Long Botond 
  To: [email protected] 
  Sent: Saturday, October 23, 2010 2:51 PM
  Subject: [iText-questions] Problem splitting existing PDF files


  Hi!

  I bought the book and read chapter 6 about handling existing PDF files.

  After it I wrote the following code:

  String outFile = "";
  String myInputPdfFile =
  @"c:\Excel97-2007BinaryFileFormat(xls)Specification.pdf";
  String myOutputPdfFile = @"c:\";

  Document document = null;
  PdfCopy copy;
  PdfReader pdfReader = null;

  pdfReader = new PdfReader(myInputPdfFile);
  int pdfPages = pdfReader.NumberOfPages;
  for (int i = 1; i < pdfPages + 1; i++)
  {
  outFile = Path.Combine(myOutputPdfFile,
  String.Format("{0}_{1}.pdf",
  Path.GetFileNameWithoutExtension(myInputPdfFile), i));

  using (FileStream fs = new FileStream(outFile, FileMode.Create,
  FileAccess.Write))
  {
  document = new Document();
  copy = new PdfCopy(document, fs);
  document.Open();
  copy.AddPage(copy.GetImportedPage(pdfReader, i));
  document.Close();
  Application.DoEvents();
  }
  }

  It runs through the first 9 pages then I get the following error
  message on the 10th page: Unable to cast object of type
  'iTextSharp.text.pdf.PdfArray' to type
  'iTextSharp.text.pdf.PRIndirectReference'.

  The first 9 pages are valid but the 10th page is unreadable by my PDF
  reader. What can be the problem?

  I tried with several PDF files, but all of them failed on some pages.
  I checked these pages, there is nothing special about them.

  Here is the file I tried in the example:
  http://www.gigasize.com/get.php?d=3kgwhxdl89d
  Btw I'm using iTextSharp 5.0.1.1, so it's not so old.

  Thanks
  Botond

  ------------------------------------------------------------------------------
  Nokia and AT&T present the 2010 Calling All Innovators-North America contest
  Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
  $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
  Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
  http://p.sf.net/sfu/nokia-dev2dev
  _______________________________________________
  iText-questions mailing list
  [email protected]
  https://lists.sourceforge.net/lists/listinfo/itext-questions

  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
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

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