I have to crop a PDF document using itext but the resultant output pdf is not that for which i have provided the cordinates of rectangle to crop the same. I have uploaded the sample file on this path.
https://onedrive.live.com/redir?resid=445455D417418FDD%21123
onedrive.live.com/redir?resid=445455D417418FDD%21124
onedrive.live.com/redir?resid=445455D417418FDD%21125
onedrive.live.com/redir?resid=445455D417418FDD%21126
and i am using this code.
PdfReader reader = new PdfReader(docpath);
iTextSharp.text.Rectangle size = new iTextSharp.text.Rectangle(24, 144, 270, 348);
iTextSharp.text.Document document = new iTextSharp.text.Document(size);
string tempdocpath = docpath.Replace(".pdf", "_.pdf");
tempdocpath = tempdocpath.Replace(".PDF", "_.PDF");
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(tempdocpath, FileMode.Create, FileAccess.Write));
document.Open();
PdfContentByte cb = writer.DirectContent;
document.NewPage();
PdfImportedPage page = writer.GetImportedPage(reader, pageNumber);
cb.AddTemplate(page, 0, 0);
document.Close();
writer.Close();