Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.
Thu May 08, 2014 6:14 am
I encountered a new error which occur at saving the document in a stream, after i have inserted some html code. Hier is my code where this error occurs, can you please have a look?
- Code: Select all
Dim header As String() = {"ArticleNr", "Product", "Availability", "Price1", "Price2"}
Dim rowData As String() = {"123456",
"<span style='font-size:14px;'>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span>",
"Available soon",
"<span style='font-size:14px;'></span>",
"<span style='font-size:14px;'>1 € per month</span>"}
Dim doc As New Document()
Dim s As Section = doc.AddSection()
Dim t As Spire.Doc.Table = s.AddTable(True)
t.TableFormat.IsBreakAcrossPages = False
t.TableFormat.LayoutType = LayoutType.AutoFit
Dim r As Spire.Doc.TableRow = t.AddRow()
For Each value As String In header
Dim c As Spire.Doc.TableCell = r.AddCell()
c.AddParagraph().AppendHTML(value)
Next
Dim r1 As Spire.Doc.TableRow = t.AddRow()
For Each value As String In rowData
Dim c As Spire.Doc.TableCell = r1.AddCell()
c.AddParagraph().AppendHTML(value)
Next
Dim stream As New MemoryStream()
doc.SaveToStream(stream, FileFormat.PDF)
doc.Close()
-
catalin
-
- Posts: 48
- Joined: Wed Mar 14, 2012 12:56 pm
Thu May 08, 2014 8:29 am
Hello,
Thanks for your inquiry.
Please try the below code.
- Code: Select all
Dim header As String() = {
"ArticleNr",
"Product",
"Availability",
"Price1",
"Price2"
}
Dim rowData As String() = {
"123456",
"<span style='font-size:14px;'>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span>",
"Available soon",
"<span style='font-size:14px;'></span>",
"<span style='font-size:14px;'>1 € per month</span>"
}
Dim doc As New Document()
Dim s As Section = doc.AddSection()
Dim t As Spire.Doc.Table = s.AddTable(True)
t.TableFormat.IsBreakAcrossPages = False
t.TableFormat.LayoutType = LayoutType.AutoFit
Dim r1 As Spire.Doc.TableRow = t.AddRow()
For Each value1 As String In header
Dim c1 As TableCell = r1.AddCell()
c1.AddParagraph().AppendHTML(value1)
Next
Dim r2 As Spire.Doc.TableRow = t.AddRow()
For i As Integer = 0 To r1.Cells.Count - 1
r2.Cells(i).AddParagraph().AppendHTML(rowData(i))
Next
Using stream As New MemoryStream()
doc.SaveToStream(stream, FileFormat.Docx)
doc.LoadFromStream(stream, FileFormat.Docx)
Using pdf As New MemoryStream()
doc.SaveToStream(pdf, FileFormat.PDF)
End Using
End Using
doc.Close()
Best wishes,
Amy
E-iceblue support team
-
amy.zhao
-
- Posts: 2766
- Joined: Wed Jun 27, 2012 8:50 am
Thu May 08, 2014 10:18 am
Well ... it seems it works like this, but is this a good practice?
Am i supposed to save everytime in a docx format before i export the document as PDF? Or at least in every case a HTML Code is appended to the document?
-
catalin
-
- Posts: 48
- Joined: Wed Mar 14, 2012 12:56 pm
Fri May 09, 2014 2:30 am
Hello,
"Am i supposed to save everytime in a docx format before i export the document as PDF"
Sorry that it is a bug. It doesn't need to save in a docx format before you export the document as PDF.
Our dev team has resolved it now. We will inform you when there is a new version is released.
Best wishes,
Amy
-
amy.zhao
-
- Posts: 2766
- Joined: Wed Jun 27, 2012 8:50 am