On , [email protected] wrote:
On Fri, 27 Jul 2012 18:30:30 +0000, [email protected] wrote:
> Hello everyone.
>
> I use the iTextSharp to split in pages one pdf file. In some cases the
> pages on the original document contains certain information not
available
> in the pdf for the same page generated by the
> library.
> The following is the code I actually use.
And could you elaborate on WHY you're using that code? We really want to
know because this question has been asked AND answered over and over
again.
We would really like to find out how we can prevent those many people from
all making the same mistake.
I'm sure the lack of documentation isn't the problem. Everybody can
download http://www.manning.com/lowagie2/samplechapter6.pdf
Those who don't want to read the documentation, can skip to table 6.1
where it says "PdfWriter: Generates PDF documents from scratch. Can import
pages from other PDF documents. The major downside is that all interactive
features of the imported page (annotations, bookmarks, fields, and so
forth) are lost in the process."
You're experiencing "the major downside". Please use one of the other
classes that don't have this downside.
------------------------------------------------------------------------------
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
Thank you for your answer.
I personally found the previous code on Internet while searching for a
solution for my case, you're right, the book should be read when the things
are properly
documented.
But still I face the problem even trying to use the book's solution. The
following code generates one internal exception on the line
PdfImportedPage _PdfImportedPage = _PdfWriter.GetImportedPage(_PdfReader,
PageNumber);
After this line was executed the object _PdfImportedPage contains the
following internal error
"Content can not be added to a PdfImportedPage."
protected bool SplitPDFFile_ExtractOnePage(string SourcefilePath, string
DestinyPagePath, int PageNumber)
{
bool aResult = false;
try{
Document _document = new Document();
PdfWriter _PdfWriter = PdfWriter.GetInstance(_document, new
FileStream(DestinyPagePath, FileMode.Create));
_document.Open();
PdfPTable _PdfPTable = new PdfPTable(2);
PdfReader _PdfReader = new PdfReader(SourcefilePath);
PdfImportedPage _PdfImportedPage = _PdfWriter.GetImportedPage(_PdfReader,
PageNumber);
_PdfPTable.AddCell(Image.GetInstance(_PdfImportedPage));
_document.Add(_PdfPTable);
_document.Close();
aResult = true;
}
catch(Exception e){
}
return aResult;
}
I'm able to open with Adobe Reader the pdf file used on my test, no error
is shown during the process. The version of the file is 1.6
Thank you again for any recommendation.
------------------------------------------------------------------------------
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