i want to add image icon before the text ....
Please explain in more details with example or screenshot.
{ Document ds = new Document(PageSize.A4,50f,50f, 10f, 10f); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(ds, memoryStream); Phrase phrase = null; PdfPCell cell = null; PdfPTable table = null; if (fuImg.HasFile) { fuImg.SaveAs(Server.MapPath("Images//" + fuImg.FileName)); } ds.Open(); table = new PdfPTable(2); table.HorizontalAlignment = 0; table.SetWidths(new float[] { 0.30f, 0.80f }); table.TotalWidth = 500f; table.LockedWidth = true; table.SpacingBefore = 20f; cell = image("~/Images/" + fuImg.FileName + "", 35f, PdfPCell.LEFT_BORDER); table.AddCell(cell); phrase = new Phrase(); phrase.Add(new Chunk(txtName.Text.ToString() + "\n\n",FontFactory.GetFont("Arial",19, Font.BOLD,BaseColor.MAGENTA))); phrase.Add(new Chunk( txtDesc.Text.ToString() +"\n\n", FontFactory.GetFont("Arial", 11, Font.NORMAL))); phrase.Add(new Chunk(txtObj.Text.ToString(),FontFactory.GetFont("Arial",8,Font.ITALIC))); cell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT); cell.VerticalAlignment = PdfPCell.ALIGN_LEFT; //cell.PaddingBottom = 10f; table.AddCell(cell); ds.Add(table); table = new PdfPTable(4); //table.SetWidths(new float[] { 1f, 4f }); table.TotalWidth = 500f; table.LockedWidth = true; table.SpacingBefore = 20f; table.HorizontalAlignment = Element.ALIGN_LEFT; phrase = new Phrase(); table.AddCell(PhraseCell(new Phrase("MobileNumber:" + txtPhnum.Text + "", FontFactory.GetFont("Arial", 8, Font.BOLD)), PdfPCell.ALIGN_LEFT)); table.AddCell(PhraseCell(new Phrase("MailID:" + txtMid.Text + "", FontFactory.GetFont("Arial", 8, Font.BOLD)), PdfPCell.ALIGN_LEFT)); table.AddCell(PhraseCell(new Phrase("SkypeID:" + txtSkyid.Text + "", FontFactory.GetFont("Arial", 8, Font.BOLD)), PdfPCell.ALIGN_LEFT)); table.AddCell(PhraseCell(new Phrase("City:" + txtCity.Text + "", FontFactory.GetFont("Arial", 8, Font.BOLD)), PdfPCell.ALIGN_LEFT)); table.AddCell(PhraseCell(phrase, PdfPCell.ALIGN_LEFT)); cell = PhraseCell(new Phrase(), PdfPCell.ALIGN_LEFT); cell.PaddingBottom = 30f; table.AddCell(cell); ds.Add(table); table = new PdfPTable(2); table.TotalWidth = 500f; table.LockedWidth = true; phrase = new Phrase(); table.AddCell(PhraseCell(new Phrase("Work Experience:"+"\n", FontFactory.GetFont("Arial", 10, Font.BOLD)), PdfPCell.ALIGN_LEFT)); phrase = new Phrase(new Chunk(txtDesc.Text + "\n", FontFactory.GetFont("Arial", 8, Font.NORMAL))); table.AddCell(PhraseCell(phrase, PdfPCell.ALIGN_LEFT)); cell = PhraseCell(new Phrase(), PdfPCell.ALIGN_LEFT); ds.Add(table); ds.Close(); byte[] bytes = memoryStream.ToArray(); memoryStream.Close(); Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", "attachment; filename=Employee.pdf"); Response.ContentType = "application/pdf"; Response.Buffer = true; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(bytes); Response.End(); Response.Close(); }
Hi rhino000,
You can't add the icon before the text. For this bootstrap is used. To achieve this create a page with the content from database and print only the content. For this refer the below article.
Else you have to generate the pdf by adding the images to the project and allign the content with pdftable and cell as you have added the image with the text in the header in the previous question.
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.