0

I have an aspx webpage that is getting parameters as querystring and i wanted to open that page and read it the lines and export it as a pdf, i am using the following code but it does not seems to work

 Dim strpath As String = Server.MapPath("pagename.aspx?id=0000")
        Dim sr As StreamReader = New StreamReader(strpath, False)
        Dim line As String
        line = sr.ReadToEnd
        sr.Close()

        ' Code to convert to pdf
        'Dim doc As New Document(PageSize.LETTER, 80, 50, 30, 65)
        Dim fsNew As New StringReader(line)
        Dim doc As New Document(PageSize.A4, 80, 50, 30, 65)
        Dim Styles As New StyleSheet()
        'stryle.LoadTagStyle("ol", "16,0")
        Using fs As New FileStream("newpdf.pdf", FileMode.Create)
            PdfWriter.GetInstance(doc, fs)
            Using stringReader As New StringReader(line)
                Dim parsedList = HTMLWorker.ParseToList(stringReader, Styles)
                doc.Open()
                ' parse each html object and add it to the pdf document
                For Each item As Object In parsedList
                    doc.Add(DirectCast(item, IElement))
                Next

                doc.Close()

            End Using

        End Using
Master Page
  • 823
  • 1
  • 6
  • 9
  • 1
    What happens when you run it? Any output to the pdf? – anu start May 10 '18 at 20:44
  • 1
    It's an `HTMLWorker` question! Read https://stackoverflow.com/questions/47895935/converting-html-to-pdf-using-itext/47896272#47896272 to find out why your code doesn't work. STOP USING the deprecated `HTMLWorker` class; UPGRADE to iText 7 and the pdfHTML add-on! – Bruno Lowagie May 10 '18 at 21:08
  • Since i have to pay for the iText 7 that was not an option for me and the workaround i did was to try to write this differently but then i need to read the aspx file path. however; i am getting (Illegal characters in path.) since the page is expecting a parameter as a query string – Master Page May 11 '18 at 14:03

0 Answers0