Sign In  Sign Up Live-Chat

HTML to PDF formatting

Last post 06-15-2008, 9:38 AM by abcweb. 11 replies.
Sort Posts: Previous Next
  •  07-11-2007, 10:49 AM 83627

    HTML to PDF formatting

    Hi, just trying out Aspose.Pdf to convert HTML to PDF and I have a question about formatting.

    Here is a simple piece of HTML with bold and underline formatting.  All of this would appear on one line on a web page, but when I convert to PDF this gets displayed on three lines, a new line for each new format.

    <html>
    <body>
    This text <b>is only <u>one</u> line</b> on a web page
    </body>
    </html>

    The HTML above is stored in a database so I read it into a string and use the following VB.Net code to convert it to PDF.

    Dim pdf As New Pdf

    Dim tr As TextReader = New StringReader(MyHTMLString)

    pdf.BindHTML(tr)

    pdf.Save("C:/test.pdf")

     

    Am I doing something wrong with my code to convert this to PDF?

     
  •  07-11-2007, 2:28 PM 83681 in reply to 83627

    Re: HTML to PDF formatting

    Hi,

    Thank you for considering Aspose.

    As you are saying that you are getting data and tags from Database, so I recommend you to use Inline HTML. Please refer to the following:

    http://www.aspose.com/wiki/default.aspx/Aspose.Pdf/TextContainingHtmlTags.html

    If you need more help, please do let us knew.

    Thanks.

    Adeel Ahmad
    Support Developer
    Aspose Changsha Team
    http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

     
  •  07-16-2007, 8:15 AM 84253 in reply to 83681

    Re: HTML to PDF formatting

    Thanks for your reply Adeel.  I have read the information about Inline HTML and it does allow multiple text formatting on one line.  So we're making progress.

    Using this Inline HTML technique, I am now trying to add a very simple table to the HTML but without much success.  When I convert to PDF, my table is appearing at the top of the PDF document, instead of after the other lines of text.

    Also the table doesn't seem to recognise the "align" attribute correctly.  I cannot get the text in my table to align in the center.

    Here is my HTML string.

    <font face=\"TimesNewRoman\" size=12>
    Here is some text.
    <b>This text is in bold.</b>
    <b><u>This text is bold underline</u></b>
    <table border=0 width=\"100%\"><tr><td align=\"center\">This is a table cell below other text, aligned center</td></tr></table>
    </font>

    And, here is my code to convert it to PDF.

    Dim pdf1 As New Pdf

    Dim sec1 As Section = pdf1.Sections.Add()

    Dim t1 As Text = New Text(MyHTMLString)

    t1.IsHtmlTagSupported = True

    sec1.Paragraphs.Add(t1)

    pdf1.Save("C:/test.pdf")

    Do I need to change my HTML or VB.Net code to make the table appear in the correct position on the page? And to use the align attribute correctly?

    Thanks.

     
  •  07-16-2007, 9:39 AM 84271 in reply to 84253

    Re: HTML to PDF formatting

    Hi,

    About your first problem (why Table is rendering first), I think it is a bug. For a workaround, please separate both string to two diffierent Text objects(one containing the text string and the other containing the Table) and then add them into Sections.

    Second problem, I think it is also a bug.

    I will discuss both issues with the developers and we will let you know as soon as solution is found.

    Thanks.

    Adeel Ahmad
    Support Developer
    Aspose Changsha Team
    http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html
     
  •  07-16-2007, 9:42 AM 84272 in reply to 84271

    Re: HTML to PDF formatting

    Thanks very much Adeel.  I will look forward to your response.
     
  •  07-19-2007, 7:06 AM 84749 in reply to 84272

    Re: HTML to PDF formatting

    Adeel,

    Another (possibly related?) bug I found is that the 'align' attribute also does not work for Paragraghs when using Inline HTML.

    <P align=center> or <P align=right> has no effect and the text in the PDF still appears aligned to the left.

    Can you give us an approximate timescale for these changes?  This will help us decide whether we will be able to use Aspose.Pdf in our application.

    Many thanks.

     
  •  07-19-2007, 8:47 AM 84767 in reply to 84749

    Re: HTML to PDF formatting

    Hi,

    Our developers will give you an ETA soon.

    Thanks.

    Adeel Ahmad
    Support Developer
    Aspose Changsha Team
    http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html
     
  •  07-19-2007, 8:15 PM 84864 in reply to 84767

    Re: HTML to PDF formatting

    Hi,

    After discussion with developers we hope that these will be fixed in about two weeks approximately.


    If you need more help, please do let us know.

    Thanks.

    Adeel Ahmad
    Support Developer
    Aspose Changsha Team
    http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

     
  •  07-28-2007, 8:20 PM 88368 in reply to 84864

    Re: HTML to PDF formatting

    1. Mixed text and table in inline HTML is still not supported. We need might need two weeks to support this feature.
    2. <table width="100%"> is still not supported because there is bug in AutoFitToWindow. We need about a week to support this feature.

     


    Tommy Wang
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  08-08-2007, 9:23 PM 89986 in reply to 88368

    Re: HTML to PDF formatting

    Attachment: Present (inaccessible)
    We have made this work better. Please try the attachment.

    Tommy Wang
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  08-23-2007, 7:15 AM 91993 in reply to 89986

    Re: HTML to PDF formatting

    We have fixed some bugs about the additional "-" and header processing. The attachment of the upper post has been replaced.

    Tommy Wang
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  06-15-2008, 9:38 AM 131342 in reply to 91993

    Re: HTML to PDF formatting

    xxx
     
View as RSS news feed in XML