Click here to Skip to main content
15,914,416 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All i am creating pdf from html text with following way

VB
Dim cliid As String = Request("fromaccid")
       Dim doc As New Document()
       ' Dim document As Document = New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 10.0F, 10.0F, 100.0F, 0.0F)
       ' Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
       ' Dim Document As PdfDocument = New PdfDocument(pdf.DocumentFont.Letter_8_5x11)
       Dim UrlDirectory As [String] = Request.Url.GetLeftPart(UriPartial.Path)
       UrlDirectory = UrlDirectory.Substring(0, UrlDirectory.LastIndexOf("/") + 1)
       Response.Write(UrlDirectory)
       ' Dim Currdt As String
       Dim getcurrtime As String() = Split(DateTime.Now.TimeOfDay.ToString, ".")
       ' Currdt = Replace(Request("fromaccid") & "" & getcurrtime(0), ":", "_")
       Dim dt As String = ClsDate.GetFormatedDate(ClsApplvl.Getserverdt(), "DD/MM/YYYY")

       PdfWriter.GetInstance(doc, New FileStream(Server.MapPath("../TRANSACTIONPDF/" & cliid & " " & dt & ".pdf"), FileMode.Create))
       ' PdfWriter.GetInstance(doc, New FileStream(Server.MapPath(".") + "mayur.pdf", FileMode.Create))

       doc.Open()
       ' Dim textFont As Font = FontFactory.GetFont("Helvetica", 1, 1, font.NORMAL, BaseColor.BLACK)
       Dim htmlText As [String] = strhtml
       Dim htmlarraylist As List(Of IElement) = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(New StringReader(htmlText), Nothing)
       Dim font As iTextSharp.text.Font = FontFactory.GetFont("Times-Roman", 10, 1, iTextSharp.text.BaseColor.GRAY)

       For k As Integer = 0 To htmlarraylist.Count - 1
           Dim x As IElement = DirectCast(htmlarraylist(k), IElement)
           Response.Write(x.Type.ToString() + "#<br>")
       Next
       Dim mypara = New Paragraph()
       mypara.InsertRange(0, htmlarraylist)
       mypara.Font = font
       doc.Add(mypara)
       doc.Close()



But how can i give background color and borders using same code...
Posted

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900