Creation of PDF

I would like to create an PDF for my report in vb.net The report returns and HTML table that contain the data ... how can I create a PDF using HtmlTable

Hi,

Thanks for using our products.

Aspose.Pdf is a component which is used to generate PDF documents from scratch. You can use its API, convert Image file into PDF, transform XML/XSL-FO files, convert Text files into PDF and it also provides the capability to generate PDF document using HTML. Please visit the following link for more information on HTML to PDF using InLineHTML

In case you face any problem or you have any further query, please feel free to contact.

Hi,

thank you for the examples, using one example as shown on HTML tp PDF using InLineHTML I'm getting follwoing error.

But it gives me error as - An exception has occurred.
Your request did not complete, and any changes you made have not been posted. Please try your request again.

Exception Messages:
Input string was not in a correct format.
For a detailed stack trace, click here.

I'm having the HTML code that is written to an file test.html and then I am reading the contents of HTML file into StreamReader object and passing it to PDF section.

Here is the HTML code of the file test.html -







































































Stacking Plan
Pacific View Center prop addr1 (acom6401)
Floor Area Tenant
F1 1,000.00




Vacant






Z1(1,000.00)






Commercial






Undefined 254,285.00

















Vacant - [1]

Vacant - [2]

Vacant - [3]

Vacant - [4]

Vacant

Vacant - [5]

Vacant - [6]

Vacant - [7]

Vacant - [8]

Vacant - [9]

Vacant - [10]

Vacant - [11]

Vacant - [12]

Vacant - [13]



















6401(14,500.00)

6402(12,000.00)

6403(24,500.00)

6404(20,000.00)

6405(78,000.00)

6406(34,500.00)

6407(0.00)

6408(43,200.00)

6409(13,455.00)

6410(4,500.00)

6411(5,750.00)

6412(3,880.00)

6414(0.00)

ANCHOR(0.00)



















Association

Commercial

Commercial

Commercial

Commercial

Commercial

Commercial

Commercial

Commercial

Commercial

Commercial

Commercial

Commercial

Commercial




























































































Vacant M to M 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 > 2020
Area Expiring 255,285.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
% Expiring 100.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

























































































Legend for Small Segments
Segment Tenant Area Lease Exp
1 Vacant - 6401 14,500.00 --
2 Vacant - 6402 12,000.00 --
3 Vacant - 6403 24,500.00 --
4 Vacant - 6404 20,000.00 --
5 Vacant - 6406 34,500.00 --
6 Vacant - 6407 0.00 --
7 Vacant - 6408 43,200.00 --
8 Vacant - 6409 13,455.00 --
9 Vacant - 6410 4,500.00 --
10 Vacant - 6411 5,750.00 --
11 Vacant - 6412 3,880.00 --
12 Vacant - 6414 0.00 --
13 Vacant - ANCHOR 0.00 --


Here is my code -

' Instantiate an object PDF class

Dim pdf As pdf = New pdf

' add the section to PDF document sections collection

Dim section As Aspose.Pdf.Section = pdf.Sections.Add()

Call YsiButtonSubmit_Click(sender, e)

' Cteate a text object with sample text

Dim sw As StringWriter = New StringWriter

Dim w As HtmlTextWriter = New HtmlTextWriter(sw)

Div1.RenderControl(w) /*Adding DIV tag code*/

Dim s As String

s = "" + sw.GetStringBuilder().ToString() + ""

Dim ht As New System.IO.StreamWriter("D:\Reports\test.html", False)

If System.IO.File.Exists("D:\Reports\test.html") Then

ht.WriteLine(s)

ht.Close()

End If

'Read the contents of HTML file into StreamReader object

Dim r As StreamReader = File.OpenText("D:\Reports\Index.html")

'Create text paragraphs containing HTML text

Dim text1 As Aspose.Pdf.Text = New Aspose.Pdf.Text(section, r.ReadToEnd())

r.Close()

'enable the property to display HTML contents within their own formatting

text1.IsHtmlTagSupported = True

section.Paragraphs.Add(text1)

'' Save the pdf document

Dim param As String

param = New Guid().NewGuid.ToString

'pdf.HtmlInfo.ImgUrl = myPdfTempFile

'Save the pdf document

pdf.Save(param + ".pdf", SaveType.OpenInBrowser, Response)

Please help, I'll be looking forward to your reply.

Please any one can provide me solution on my above issue?

thanks,

prashant.

Hello Prashant,

Sorry for replying you late

I have been testing this scenario but I am afraid everytime I have executed the code, I am getting a blank PDF document. I am still working over this query and trying to figure out the reasons of this problem and will get back to you soon. We apologize for the delay and inconvenience.

Hi Nayyer,

Thanks a lot for the reply, Just want to give you additional information. In the above HTML code there are

tags with in the tag, I removed the
tag and some of the data was exported to PDF but with on formatting.

I'm using .net framework 1.1.

Please help me, and also let me know whihc aspose dll should I used that support HTML formatting and

tag.

Thanks,

Prashant.

Hello Prashant,

Thanks for your patience.

I have tested the scenario using Aspose.Pdf for .NET 5.3.0 and I am unable to notice any exception. The PDF document is being generated but I am afraid there are some formatting issues. For the sake of correction, I have logged it as PDFNET-28032 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

[VB.NET]

' Instantiate an object PDF class
Dim pdf As Pdf = New Pdf
' add the section to PDF document sections collection
Dim section As Aspose.Pdf.Section = pdf.Sections.Add()
' set the page orientation as Landscape
section.IsLandscape = True

'Read the contents of HTML file into StreamReader object
Dim r As StreamReader = File.OpenText("D:\pdftest\Sample.html")
'Create text paragraphs containing HTML text
Dim text1 As Aspose.Pdf.Text = New Aspose.Pdf.Text(section, r.ReadToEnd())
'enable the property to display HTML contents within their own formatting
text1.IsHtmlTagSupported = True
section.Paragraphs.Add(text1)
'Save the pdf document
pdf.Save("HTML-to-PDF.pdf", SaveType.OpenInAcrobat, Response)

Hello Nayyer,

Thank you for your help, can I have tentative date for this fix.

Please let me know.

Thanks,

prashant.

Hello Prashant,

Thanks for your patience.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I am sorry to inform you that the issue reported earlier is not yet resolved. However, I have requested the development team to share the ETA regarding its resolution. As soon as the information becomes available, I would be more than happy to share it with you.

Once again, my humble request is to be little more patient and spare us little time. We are really sorry for this delay and inconvenience.

Hello Shahbaz,

I hope you are doing good, I request you to update me on following issue, also please can you test the following HTML to create a PDF out of it.

Please see the attached file HTML.zip for the HTML.

I'll be looking forward to your reply,

Thanks,

Prashant.

Hello Prashant,

Thanks for your patience.

I am pleased to inform you that the issue reported earlier PDFNET-28032 has been fixed. We expect to include its HotFix in upcoming release version. However while converting the attached HTML file with Aspose.Pdf for .NET 6.0.0, the formatting seems to be correct. Please take a look over attached resultant PDF that I have generated. In case you still encounter any problem or you have any further query, please feel free to contact.

Thank you Shahbaz,

Thanks a lot for the update, can you please do me a favour, I have attached complete HTML file can you please produce an PDF out of the attached html file and send it to me.

The file attached is HTML.zip

Thanks Again,

Prashant.

Hello Prashant,

Thanks for sharing the source file.

I have tried converting the attached HTML file into PDF format using Aspose.Pdf for .NET 6.0.0 and I am afraid I am getting an encountering an exception during the conversion process. For the sake of correction, I have logged it as PDFNEWNET-29441 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction.

Please be patient and spare us little time. We are really sorry for this inconvenience.

The issues you have found earlier (filed as 29441 ) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hello Nayyer,

Thanks for the update, but still I'm not able to generate the PDF using latest updated DLL. Please can you try creating PDF at your end. Attached is the source HTML code.

Thanks,prashant.