This question was answered on StackOverflow:
http://stackoverflow.com/questions/23256944/itextsharp-when-extracting-a-page-it-fails-to-carry-over-adobe-rectangle-highl
You're probably throwing away an annotation (and you shouldn't copy/paste from bad examples).

On 4/24/2014 1:04 AM, Stephen LeCompte wrote:

To Whom It May Concern:

Question: *How come Adobe rectangle does not get extracted with iTextSharp?*

Version:  itextsharp-all-5.5.0

I have an Adobe PDF that has a rectangle highlighting some data on the 2nd page (provided as an attachment) and yet when I do an ExtractPages using the following code -- the rectangle is not transferred to the new document.

The highlight of the rectangle is important to differentiate a different item.

Otherwise, great job -- thank you sincerely for the .dll!

If the following code does not show- I was pulling ExtractPages function from the following websites:

http://forums.asp.net/t/1630140.aspx?extracting+pdf+pages+using+itextsharp

Thanks again,

Stephen

privatestaticvoidExtractPages(stringinputFile, stringoutputFile, intstart, intend)

{

// get input document

PdfReaderinputPdf = newPdfReader(inputFile);

// retrieve the total number of pages

intpageCount = inputPdf.NumberOfPages;

if(end < start || end > pageCount)

{

end = pageCount;

}

// load the input document

DocumentinputDoc =

newDocument(inputPdf.GetPageSizeWithRotation(1));

// create the filestream

using(FileStreamfs = newFileStream(outputFile, FileMode.Create))

{

// create the output writer

PdfWriteroutputWriter = PdfWriter.GetInstance(inputDoc, fs);

inputDoc.Open();

PdfContentBytecb1 = outputWriter.DirectContent;

// copy pages from input to output document

for(inti = start; i <= end; i++)

{

inputDoc.SetPageSize(inputPdf.GetPageSizeWithRotation(i));

inputDoc.NewPage();

PdfImportedPagepage =

outputWriter.GetImportedPage(inputPdf, i);

introtation = inputPdf.GetPageRotation(i);

if(rotation == 90 || rotation == 270)

{

cb1.AddTemplate(page, 0, -1f, 1f, 0, 0,

inputPdf.GetPageSizeWithRotation(i).Height);

}

else

{

cb1.AddTemplate(page, 1f, 0, 0, 1f, 0, 0);

}

}

inputDoc.Close();

}

inputPdf.Close();

}

Kind Regards,

Stephen

*Stephen LeCompte*

*Application Developer*

**

*Shen Milsom & Wilke LLC *

712 Main Street Suite 730, Houston, TX 77002

*Main*713.278.8228  | *Fax* 713.278.5330 | *Mobile *832.607.8659

*slecom...@smwllc.com <mailto:slecom...@smwllc.com>*| *www.smwllc.com* <http://www.smwllc.com>**

Acoustics | Audiovisual | Information Technology | Security | Medical Equipment Planning

Description: Description: SM&W_logo_fin_1

Description: cid:image002.jpg@01CEF73C.FE6B33E0 <https://twitter.com/ShenMilsomWilke>Description: cid:image003.jpg@01CEF73C.FE6B33E0 <https://www.facebook.com/shen.milsom.wilke.llc>Description: cid:image004.png@01CEF73C.FE6B33E0 <http://www.linkedin.com/company/shen-milsom-&-wilke?trk=company_name>

www.smwllc.com/DISCLOSURE-NOTICE.htm <http://www.smwllc.com/DISCLOSURE-NOTICE.htm>



------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform


_______________________________________________
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

------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
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

Reply via email to