PDF conversion significantly different than HTML

Last post 08-07-2012, 1:37 AM by niushaH. 4 replies.
Sort Posts: Previous Next
  •  07-12-2007, 11:57 PM 31517

    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:
  •  07-14-2007, 4:42 PM 31539 in reply to 31517

    Re: PDF conversion significantly different than HTML

    Hi Fredd,
     
    I've not used the PDF function before, however I can see that you haven't given the PDF document a CSS Stylesheet. This is what is applied when you view the HTML in CE.
     
    Applying your CSS file should solve your issues (1-3). Page break I beleive is used when printing the page from the browser, I'm not sure if it is used for the PDF converter.
     
    The forums indicate that CuteSoft are currently writing an improved converter for PDF and RTF, etc.
     
    Ady
  •  07-14-2007, 5:55 PM 31540 in reply to 31539

    Re: PDF conversion significantly different than HTML

    Thanks Ady,
     
    But I don't think that's the problem. First, I can't give the PDF document a style sheet. I'm using CE's built-in PDF converter and all it does is read the editor's text.
     
    Second, and more importantly, when I use other company's .NET converters (Sautin), they work fine against the same content.
     
    BTW - I still never received an answer from him about scroll positioning... However, a modified version of yours works well - thanks very much
     
    Fredd
     
     
     
     
  •  08-07-2012, 1:36 AM 74350 in reply to 31517

    Re: PDF conversion significantly different than HTML

    Is there any update on this? I am having the similar problem. 
     
     
    fredd:
    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
     
     
     
  •  08-07-2012, 1:37 AM 74351 in reply to 74350

    Re: PDF conversion significantly different than HTML

    Is there any update on this? I am having the same problem.
     
View as RSS news feed in XML