c# - How to reduce the size of image in header of the pdf using itextsharp -


 public class itseventshandler : pdfpageeventhelper          {              pdftemplate total;              basefont helv;                public override void onendpage(pdfwriter writer, document document)              {  itextsharp.text.image jpg = itextsharp.text.image.getinstance("c:/users/public/pictures/sample pictures/penguins.jpg");              jpg.scalepercent(35f);              jpg.setabsoluteposition(130f, 240f);                itextsharp.text.image imgfoot = jpg;                  //header image                   itextsharp.text.image imghead = itextsharp.text.image.getinstance("c:/users/public/pictures/sample pictures/penguins.jpg");                   imgfoot.setabsoluteposition(0, 0);                  imghead.setabsoluteposition(0, 0);                  imgfoot.scaleabsolute(826, 1100);                  pdfcontentbyte cbhead = writer.directcontent;                  pdftemplate tp = cbhead.createtemplate(2480, 370); // units in pixels i'm not sure if thats correct units                  tp.addimage(imghead);                   pdfcontentbyte cbfoot = writer.directcontent;                  pdftemplate tpl = cbfoot.createtemplate(2480, 664);                  tpl.addimage(imgfoot);                  cbhead.addtemplate(tp, 0, 715);                   helv = basefont.createfont(basefont.helvetica, basefont.winansi, basefont.not_embedded);                   /*pdfcontentbyte cb = writer.directcontent;                  cbfoot.savestate();                  document.setmargins(35, 35, 100, 82);                  cb.restorestate();*/                   //document.newpage();                   base.onstartpage(writer, document);              }               public override void onopendocument(pdfwriter writer, document document)              {                  total = writer.directcontent.createtemplate(100, 100);                  total.boundingbox = new itextsharp.text.rectangle(-20, -20, 100, 100);                  helv = basefont.createfont(basefont.helvetica, basefont.winansi, basefont.not_embedded);              }          } 

code creating header images; images looks big.tried use imgfoot.scaleabsolute(826, 1100); dosent worked result image shows half.please me resolve. ...............................................................................................

assuming talking imghead, creating image width of 826 user units , height of 1100 user units. adding image @ position (0, 0) of form xobject width of 2480 user units (that's sufficient) , height of 370 user units (that's not sufficient height of image 1100 user units).

you image shows half. correct: have clipped image 33.6% of height (370 / 1100). change height value of form xobject tp image fits , you've solved problem.

also: user units aren't pixels! default 1 user unit corresponds 1 point.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -