請看下圖,依序插入 ABCDE 的字串陣列時,在跨頁儲存格次頁面的段落會發生陣列順序顛倒的問題。
PicQ3.png (9.6 KB)
Public Sub Gen_PDF_Q3()
' 向原廠反應的問題
AsposeFunc.AsposeLicense_20240906()
Dim sB As New StringBuilder
sB.AppendLine("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE")
sB.AppendLine("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE")
Dim lstWords As List(Of String) = sB.ToString.Split(" ").ToList
Dim pDoc As New Aspose.Pdf.Document()
Dim pPage As Aspose.Pdf.Page = pDoc.Pages.Add()
pPage.SetPageSize(Aspose.Pdf.PageSize.A4.Width, Aspose.Pdf.PageSize.A4.Height)
Dim pTable As New Aspose.Pdf.Table With {
.ColumnWidths = "10% 50% 40%",
.DefaultCellBorder = New Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1.0F)
}
pPage.Paragraphs.Add(pTable)
Dim pRows As Aspose.Pdf.Rows = pTable.Rows
Dim R1 As Aspose.Pdf.Row = pRows.Add()
Dim R1C1 As Aspose.Pdf.Cell = R1.Cells.Add("SN")
Dim R1C2 As Aspose.Pdf.Cell = R1.Cells.Add("Word")
Dim R1C3 As Aspose.Pdf.Cell = R1.Cells.Add("Text")
#Region "問題3"
For i As Integer = 0 To 3
Dim TxtFrag As New Aspose.Pdf.Text.TextFragment
For iWord As Integer = 0 To lstWords.Count - 1
Dim TxtSegColl As Aspose.Pdf.Text.TextSegmentCollection = TxtFrag.Segments
Dim TxtSeg As New Aspose.Pdf.Text.TextSegment With {.Text = lstWords(iWord)}
TxtSeg.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("PMingLiU")
TxtSeg.TextState.FontSize = 12
TxtSegColl.Add(TxtSeg)
Next
Dim Q3Row As Aspose.Pdf.Row = pRows.Add()
Q3Row.IsRowBroken = True
Dim R3C1 As Aspose.Pdf.Cell = Q3Row.Cells.Add(1 + i)
Dim R3C2 As Aspose.Pdf.Cell = Q3Row.Cells.Add("")
Dim R3C3 As Aspose.Pdf.Cell = Q3Row.Cells.Add()
Dim CellParag As New Aspose.Pdf.Paragraphs From {TxtFrag}
R3C3.Paragraphs = CellParag
Next
#End Region
pDoc.Save("X:\Coding\PDF_Q3.pdf")
End Sub