Image iTextSharp在PDF中的段落顺序错误
我正在尝试使用iTextSharp生成PDF。Image iTextSharp在PDF中的段落顺序错误,image,pdf,itextsharp,Image,Pdf,Itextsharp,我正在尝试使用iTextSharp生成PDF。 它将由许多图像组成,每个图像前面都有一个标题。但是当我生成PDF时,元素的顺序并没有被保留——多个标题被分组在一起等等 我将标题和图像包装在一个段落中,如下所示: ' Create paragraph and heading Dim paragraph As New iTextSharp.text.Paragraph() Dim heading As New iTextSharp.text.Chunk("Image title" & vbN
它将由许多图像组成,每个图像前面都有一个标题。但是当我生成PDF时,元素的顺序并没有被保留——多个标题被分组在一起等等 我将标题和图像包装在一个段落中,如下所示:
' Create paragraph and heading
Dim paragraph As New iTextSharp.text.Paragraph()
Dim heading As New iTextSharp.text.Chunk("Image title" & vbNewLine, pdfHeadingFont)
' Create image from Chart
Dim image = GetPdfImage(Me.chtMain)
Dim width = iTextSharp.text.PageSize.A4.Width - pdfDocument.LeftMargin - pdfDocument.RightMargin
Dim height = iTextSharp.text.PageSize.A4.Height - pdfDocument.TopMargin - pdfDocument.BottomMargin
image.Alignment = image.ALIGN_CENTER Or image.TEXTWRAP
image.ScaleToFit(width, height)
' Add heading and image to paragraph
paragraph.Add(heading)
paragraph.Add(image)
' Add paragraph to document
pdfDocument.Add(paragraph)
为什么图像和标题在PDF中没有放在一起?我可以用其他方式来做吗
谢谢,
多亏了我,马丁把它弄明白了
显然,设置PdfWriter.StrictImageSequence=true可以解决此问题。
iTextSharp通过在每一页上尽可能多的段落来“优化”您的文档,而不考虑顺序
马丁