PDF conversion significantly different than HTML

  •  07-12-2007, 11:57 PM

    PDF conversion significantly different than HTML

    I have big problems with HTML2PDF! Nice HTML structure becomes all wrong when converted to PDF.
     
    What am I doing wrong!?
     
    Here's the HTML display in CE:
     
     
     
     
     
     
    and here's the PDF Version! How can it be so different?
     
     
     
     
    1. It's got the wrong font.
    2. It doesn't have the correct top, bottom, right and left margins.
    3. It is inserting several spaces between paragraphs instead of just one...
    4. Further on in the document, I inserted a page break which isn't being recognized in the PDF output...
     
    Here is my code:
     

    Response.ClearContent()

    Response.ClearHeaders()

    Response.ContentType = "application/pdf"

    Response.AppendHeader("content-disposition", "attachment; filename=MyPDF.pdf")

    Dim sm As System.IO.MemoryStream = New System.IO.MemoryStream

    Dim html2pdf As CuteEditor.Convertor.PDF.HTML2PDF = New CuteEditor.Convertor.PDF.HTML2PDF(Editor1.Text)

    Try

    html2pdf.RenderSinglePageContent = False

    html2pdf.Render()

    html2pdf.Save(sm)

    sm.WriteTo(Response.OutputStream)

    sm.Close()

    Finally

    sm = Nothing

    End Try

    Response.End()

    Exit Sub

     
     
    And here's the HTML in CE:
     
    <html xmlns:st1="">
        <head>
        </head>
        <body style="font-size: 12px; font-family: Arial" bottommargin="75" leftmargin="100" topmargin="75" rightmargin="75">
            <div>July 2, 2007</div>
            <div>&nbsp;<strong><em><br />
            Confidential <br />
            Report to the Board of Directors</em></strong></div>
            <div><strong><em>MyCompany Inc.</em></strong></div>
            <div><strong><em>&nbsp;</em></strong></div>
            <div><strong><em>Prepared by: Hason Jason</em>
            <div></strong>&nbsp;</div>
            </div>
            <div>I would like to present our ideas with respect to both the short- and long-term needs of the company, considering its current financial, leadership and human resources&nbsp;state. </div>
            <div>&nbsp;</div>
            <div><strong>Overview</strong></div>
            <div>&nbsp;</div>
            <div>In recent years, the company has faced new challenges, ad infinitum and so one and one are often no longer two but rather become something entirely different.</div>
            <div>&nbsp;</div>
            <div>Some of those involve this, some involve that..</div>
            <div>&nbsp;</div>
            <div>Lot's of things are this and that. </div>
            <div>&nbsp;</div>
            <div>That mandate required the following tasks to be completed:</div>
            <ul>
                <li>Return to this
                <li>Establish that
                <li>Document stuff </li>
            </ul>
            <div><strong>Key executives</strong></div>
            <div>&nbsp;</div>
            <div>The company's executive staff:</div>
            <ul>
                <li>Joe Blow, CEO
                <li>Jane Doe, COO
                <li></li>
            </ul>
            <div><strong>Events</strong></div>
            <div>&nbsp;</div>
            <div>In June, 2007, Hason and Jason did this and that.<br />
            </div>
        </body>
    </html>
     
    I need to fix this right away. What should I do?
     
     
    Fredd
     
     
     
    Filed under:
View Complete Thread