Click here to Skip to main content
15,889,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have a web projet which has to have the functionality to create PDF.
Im using (trying...) the itextsharp library.
The data source is an ajax control, htmleditor from the ajax control toolkit by codeplex. This control gives me a xhtml string, this is the string that I use in the itextsharp. The problem is that I don't get a PDF with all the effects used on the editor (like typography, background color, etc.) Also when I use a bigger size in the text, sometimes it overwrites on other sentence.
Thank you for your time and help.
My apologies, a long time without writing in english.

VB
Public Sub PDFCreation()
        Dim Document As Document = New Document()
        Dim ms As MemoryStream = New MemoryStream()
        Dim writer As PdfWriter = PdfWriter.GetInstance(Document, ms)
        Dim se As StringReader = New StringReader(Editor1.Content)
        Dim obj As HTMLWorker = New HTMLWorker(Document)
        Document.Open()
        obj.Parse(se)
        Document.Close()
        Response.Clear()
        Response.AddHeader("content-disposition","attachment; filename=report.pdf"
        Response.ContentType = "application/pdf"
        Response.Buffer = True
        Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length)
        Response.OutputStream.Flush()
        Response.End()
    End Sub
Posted

1 solution

Try here for help: iText[^]. There is an iTextSharp[^] project page and other help. I have used iTextSharp in a couple of projects and will be using it in my current one as well. It was fiddly to get going but well worth it.
 
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