Posts

Showing posts from April, 2017

how to stop pdf editing using itextsharp

Editable pdf file textbox, checkbox, etc. doesn't write after creating pdf file from itextsharp this file should not be editable code below: pdfStamper.FormFlattening =  true ;

Add Image through base64 on PDF in itextsharp

If you have base64 code image or image path, easily can add image in PDF from iTextSharp. Code below: PdfReader pdfReader =  new  PdfReader( "C:\\file.pdf" ); PdfStamper pdfStamper =  new  PdfStamper(pdfReader,  new  FileStream( "target save path" , FileMode.Create)); string  imagepath =  "base64 image code" ; Byte[] bytes = Convert.FromBase64String(Regex.Replace(imagepath, @ "^data:image\/[a-zA-Z]+;base64," ,  string .Empty)); var  pdfContentByte = pdfStamper.GetOverContent(1);  // page number iTextSharp.text.Image image1 = iTextSharp.text.Image.GetInstance(bytes); image1.SetAbsolutePosition(140, 70); image1.ScalePercent(20f); pdfContentByte.AddImage(image1); pdfStamper.Close();

How to find text in dropdownlist in asp.net

Finding item in dropdownlist from a string. ddlStudent.Items.Contains( new  ListItem("Dawood"))

Remove first and last special characters from string in c#

Sometimes we need to remove special character from staring and ending of a string. private   static   string  RemoveFirstAndLastSpecialCharacter( string  input) {      if  (input !=  string .Empty)     {          string  firstRemovableStr =  string .Empty;          string  lastRemovableStr =  string .Empty;          bool  IsLetter =  false ;          for  ( int  i = 0; i < input.Length; i++)         {              if  (! char .IsLetter(input[i]) && !IsLetter)             ...