Trying to create pdf from html from gridview. It just bunches it all together.
Dim MyDocument As ceTe.DynamicPDF.Document = New ceTe.DynamicPDF.Document()
MyDocument.Creator = "Table.aspx"
MyDocument.Author = "Your Name"
MyDocument.Title = "Table Example"
Dim grid As System.Web.UI.WebControls.GridView = New System.Web.UI.WebControls.GridView
Dim sw As System.IO.StringWriter = New System.IO.StringWriter
Dim hw As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(sw)
Dim body As String = ""
' Populate the DataGrid
grid.DataSource = dataAdmin.get_bit_task_pending_staffid(ddlStaff.SelectedValue)
grid.DataBind()
' Render DataGrid output as Html
grid.RenderControl(hw)
' Add grid output to html body
body += sw.ToString()
' Avoid leaving streams open
sw.Close()
hw.Close()
renderHTML(body)
Private Sub renderHTML(ByVal bodyVal As String)
' Create a PDF Document
Dim MyDocument As ceTe.DynamicPDF.Document = New ceTe.DynamicPDF.Document
' Create a Page and add it to the document
Dim MyPage As ceTe.DynamicPDF.Page = New ceTe.DynamicPDF.Page
MyDocument.Pages.Add(MyPage)
' Create an HTML style
Dim style As HtmlTextAreaStyle = New HtmlTextAreaStyle(ceTe.DynamicPDF.FontFamily.Helvetica, 12, False)
Dim MyHtmlTextArea As HtmlTextArea = New HtmlTextArea(bodyVal, 0, 0, 256, 400, style)
' Add the HTML text area to the page
MyPage.Elements.Add(MyHtmlTextArea)
' Save the PDF
' MyDocument.Draw("C:\MyDocument.pdf")
MyDocument.DrawToWeb(Me, "SimpleReport.pdf")
End Sub
Generate html
Re: Generate html
Support · Jan 8, 2007Hello,
We do not offer any products that convert HTML files or HTML content directly to PDF.
The reason we do not offer this conversion is because HTML and PDF are very different in nature and there is no perfect way of converting between them. For instance, HTML is flow able data that is designed specifically for viewing. It can shrink and reformat according to screen size. On the other hand there’s PDF, which is a very concrete and completely fixed document, designed specifically for quality printing. So when tying to convert from HTML to PDF formatting becomes a severe issue.
There are products out there that can “convert” HTML to PDF, but the fact of the matter is that these products usually produce unsatisfactory results. In some cases, you will have to change your HTML in order to improve the look of your resulting PDF. Mostly, the products that claim to do this conversion are basically taking a snapshot of how the HTML would print and then converting that to PDF. And you know how unpredictable a printed HTML page can be.
Our products are designed for high quality PDF formatting and output. Using them, you can take your data and produce runtime, dynamic PDFs with the ability to control the exact placement of every element on the page. Therefore you will know the look or structure of your PDF before creation time.
If your HTML pages are based off of information from a database then you could easily create a PDF that will resemble your original HTML document, but there is no one line conversion. Our Generator for .NET would allow you to create PDFs based off of the same data used to create your HTML file.
Another option would be to create a PDF template (or multiple templates) of your different reports, then using our Merger for .NET product, you could simply add your data on top of the template you have created.
Thanks,
ceTe Software Support Team
Re: Generate html
Forum member · Jan 8, 2007What is this I found in the help file??
' Create a PDF Document
Dim MyDocument As Document = New Document
' Create a Page and add it to the document
Dim MyPage As Page = New Page
MyDocument.Pages.Add(MyPage)
' Create an HTML style
Dim style As HtmlTextAreaStyle = New HtmlTextAreaStyle(FontFamily.Helvetica, 12, False)
' Create the text and the HTML text area
Dim htmlText As String = "<p>HTML text area provide rich formatting support for " + _
"text that appears in the document. You have complete control over 8 paragraph " + _
"properties: spacing before, spacing after, first line indentation, left indentation," + _
" right indentation, alignment, allowing orphan lines, and white space preservation; " + _
"6 font properties: <font face='Times'>font face, </font><font " + _
"pointSize='6'>font size, </font><font color='FF0000'>color, " + _
"</font><b>bold, </b><i>italic and </i><u>" + _
"underline</u>; and 2 line properties: leading, and leading type. Text can " + _
"also be rotated.</p>"
Dim MyHtmlTextArea As HtmlTextArea = New HtmlTextArea(htmlText, 0, 0, 256, 400, style)
' Add the HTML text area to the page
MyPage.Elements.Add(MyHtmlTextArea)
' Save the PDF
MyDocument.Draw("C:\MyDocument.pdf")
Re: Generate html
Support · Jan 8, 2007Hello,
The example shows how to format text using the HtmlTextArea page element.
Please refer to the Help Documentation
for the list of HTML tags supported by HtmlTextArea page element.
Thanks,
ceTe Software Support Team