0
我正在使用aspose.pdf.dll版本3.9.0.0。现在我升级到更新的版本7.3.0.0Aspose.pdf.dll版本问题
但我面临问题 PDFCell.Paragraphs.Add(Row.RenderRowAsposePDF(0,PDFCell.FitWidth))。 其显示空白结果。它支持旧版本并与其完美配合。但不适用于较新的版本。 请参阅下面的示例代码。
私人小组cmdSamplePDF_Click(BYVAL发件人为对象,BYVALË作为System.EventArgs)把手cmdSamplePDF.Click
Dim pdf1 As Aspose.Pdf.Generator.Pdf = New Aspose.Pdf.Generator.Pdf()
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
Dim Table As Aspose.Pdf.Generator.Table = New Aspose.Pdf.Generator.Table()
sec1.Paragraphs.Add(Table)
Table.DefaultCellBorder = New Aspose.Pdf.Generator.BorderInfo(Aspose.Pdf.Generator.BorderSide.All, 0.1F)
Dim PDFRow As Aspose.Pdf.Generator.Row
Dim PDFCell As Aspose.Pdf.Generator.Cell
With sec1
.IsLandscape = True
.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.LetterWidth
.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.LetterHeight
End With
PDFRow = Table.Rows.Add
PDFRow.FixedRowHeight = 15
PDFRow.DefaultCellTextInfo.FontName = "Verdana"
PDFRow.DefaultCellTextInfo.FontSize = 7
PDFCell = PDFRow.Cells.Add("undefined")
PDFCell.FitWidth = 39.6
PDFCell.Border = New Aspose.Pdf.Generator.BorderInfo(Aspose.Pdf.Generator.BorderSide.Right, 5.0F, New Aspose.Pdf.Generator.Color("White"))
PDFCell = PDFRow.Cells.Add("3000")
PDFCell.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Right
PDFCell.FitWidth = 63.36
PDFCell = PDFRow.Cells.Add("")
PDFCell.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Right
PDFCell.FitWidth = 3.96
PDFCell = PDFRow.Cells.Add
PDFCell.FitWidth = 300
'Comment the below line and uncomment the second line
PDFCell.Paragraphs.Add(renderasposerow(0, PDFCell.FitWidth))
'sec1.Paragraphs.Add(renderasposerow(0, PDFCell.FitWidth))
For i As Int32 = 1 To 3
PDFRow = Table.Rows.Add
PDFCell = PDFRow.Cells.Add("")
PDFCell.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Right
PDFCell.FitWidth = 39.6
PDFCell = PDFRow.Cells.Add("")
PDFCell.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Right
PDFCell.FitWidth = 63.36
PDFCell = PDFRow.Cells.Add("")
PDFCell.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Right
PDFCell.FitWidth = 3.96
PDFCell = PDFRow.Cells.Add
PDFCell.FitWidth = 300
'Comment the below line and uncomment the second line
PDFCell.Paragraphs.Add(renderasposerow(i, PDFCell.FitWidth))
'sec1.Paragraphs.Add(renderasposerow(i, PDFCell.FitWidth))
Next
pdf1.Save("d:\pdftest\Exceldata_toPdf_table.pdf")
End Sub
Public Function renderasposerow(ByVal RowNumber As Int32, ByVal CellWidth As Single) As Aspose.Pdf.Generator.Table
Dim PDFTable As New Aspose.Pdf.Generator.Table
Dim myPDFRow() As Aspose.Pdf.Generator.Row
Dim mypdfcell() As Aspose.Pdf.Generator.Cell
Try
If myPDFRow Is Nothing OrElse RowNumber > myPDFRow.Length - 1 Then
ReDim Preserve myPDFRow(RowNumber)
End If
myPDFRow(RowNumber) = PDFTable.Rows.Add
myPDFRow(RowNumber).DefaultCellTextInfo.FontName = "Verdana"
myPDFRow(RowNumber).DefaultCellTextInfo.FontSize = 7
myPDFRow(RowNumber).FixedRowHeight = 15
For i As Int32 = 1 To 4
Try
Dim bFirstRow As Boolean = False
If mypdfcell Is Nothing OrElse RowNumber > mypdfcell.Length - 1 Then
ReDim Preserve mypdfcell(RowNumber)
bFirstRow = True
End If
Dim sCellText As String = "Commercial"
If sCellText = Nothing Then sCellText = ""
If bFirstRow Then sCellText = vbCrLf & sCellText
mypdfcell(RowNumber) = myPDFRow(RowNumber).Cells.Add(sCellText)
mypdfcell(RowNumber).BackgroundColor = New Aspose.Pdf.Generator.Color("Green")
mypdfcell(RowNumber).DefaultCellTextInfo.Color = New Aspose.Pdf.Generator.Color("White")
mypdfcell(RowNumber).FitWidth = 100
With mypdfcell(RowNumber)
.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center
.DefaultCellTextInfo.CharSpace = 0
.Border = New Aspose.Pdf.Generator.BorderInfo(Aspose.Pdf.Generator.BorderSide.Right, 0.1F, New Aspose.Pdf.Generator.Color("White"))
End With
Catch ex As Exception
Throw New Exception("Render PDF Cell" & vbCrLf & ex.Message)
End Try
i = i + 1
Next
Catch ex As Exception
Throw New Exception("Render PDF Rows" & vbCrLf & ex.Message)
End Try
Return PDFTable
End Function