I have receipt page where user can print and save as PDF. while saving to PDF arabic text is missing. Can any one help on this please.
It is working fine with english but arabic text is missig, Below is my code for generating PDF on button click event
Dim bfTimes As BaseFont = BaseFont.CreateFont("C:\Windows\Fonts\Tahoma.ttf", BaseFont.IDENTITY_H, False)
Dim font20 As iTextSharp.text.Font = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA, 20, Font.BOLD)
Dim font18 As iTextSharp.text.Font = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA, 18, Font.BOLD, New Color(255, 255, 255))
Dim font12 As iTextSharp.text.Font = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA, 12, New Color(255, 255, 255))
Dim logo As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Request.MapPath("~/images/logowhite.jpg"))
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
pnlPerson.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 100.0F, 35.0F)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
Dim footer As New Paragraph("My Footer", font12)
Dim pdffooter As New HeaderFooter(New Phrase(footer), True)
pdffooter.Alignment = Element.ALIGN_CENTER
pdffooter.Border = iTextSharp.text.Rectangle.NO_BORDER
pdffooter.BackgroundColor = New Color(200, 8, 190)
Dim Header As New Paragraph("My Header", font18)
Dim pdfheader As New HeaderFooter(New Phrase(Header), True)
pdfheader.Alignment = Element.ALIGN_CENTER
pdfheader.Border = iTextSharp.text.Rectangle.NO_BORDER
pdfheader.BackgroundColor = New Color(200, 8, 190)
sree1248
Member
4 Points
33 Posts
Html To PDF Arabic Text Not Displaying
Feb 24, 2013 08:01 AM|LINK
Hie All,
I have receipt page where user can print and save as PDF. while saving to PDF arabic text is missing. Can any one help on this please.
It is working fine with english but arabic text is missig, Below is my code for generating PDF on button click event
Dim bfTimes As BaseFont = BaseFont.CreateFont("C:\Windows\Fonts\Tahoma.ttf", BaseFont.IDENTITY_H, False)
Dim font20 As iTextSharp.text.Font = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA, 20, Font.BOLD)
Dim font18 As iTextSharp.text.Font = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA, 18, Font.BOLD, New Color(255, 255, 255))
Dim font12 As iTextSharp.text.Font = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA, 12, New Color(255, 255, 255))
Dim logo As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Request.MapPath("~/images/logowhite.jpg"))
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=sample.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
pnlPerson.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 100.0F, 35.0F)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
Dim footer As New Paragraph("My Footer", font12)
Dim pdffooter As New HeaderFooter(New Phrase(footer), True)
pdffooter.Alignment = Element.ALIGN_CENTER
pdffooter.Border = iTextSharp.text.Rectangle.NO_BORDER
pdffooter.BackgroundColor = New Color(200, 8, 190)
logo.ScalePercent(50.0F)
logo.SetAbsolutePosition(500, 770)
Dim Header As New Paragraph("My Header", font18)
Dim pdfheader As New HeaderFooter(New Phrase(Header), True)
pdfheader.Alignment = Element.ALIGN_CENTER
pdfheader.Border = iTextSharp.text.Rectangle.NO_BORDER
pdfheader.BackgroundColor = New Color(200, 8, 190)
pdfDoc.Header = pdfheader
pdfDoc.Footer = pdffooter
pdfDoc.Open()
pdfDoc.Add(logo)
htmlparser.Parse(sr)
pdfDoc.Close()
Response.Write(pdfDoc)
Response.[End]()