第1页上的itext7表SetFixedPosition失败 [英] itext7 table SetFixedPosition on Page 1 fails

查看:532
本文介绍了第1页上的itext7表SetFixedPosition失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不敢相信,我所看到的.... 我尝试在定义的页面上将带有itext7的表打印为PDF.创建表格是在完成PDF之前的最后一个声明.

I can´t believe, what I see.... I try to print a table with itext7 into a PDF on a defined page. The table-creation is made as last statement before finishing the PDF.

PDF(完成后)有5页.我可以将表格打印到除第一页之外的所有页面上.

The PDF has (after finishing) 5 pages. I can print the table to every page except the first page.

这是我的代码:

    If placeOnPage = 0 Then
        table.SetFixedPosition(200, 250, 100)
    Else
        table.SetFixedPosition(placeOnPage, 200, 250, 100)
    End If

如果placeOnPage = 0,则该表正确打印在最后一页上.如果将placeOnPage设置为2到5之间的值,则该表正确放置在第2、3、4或5页上.但是,如果将placeOnPage设置为1,则在该行出现错误

If placeOnPage = 0, then the table is printed correctly on the last page. If I set placeOnPage to values between 2 and 5, the table is correctly placed on page 2, 3, 4 or 5. But if I set placeOnPage to 1, I get an error at the line

doc.add(table)

错误提示:

System.NullReferenceException: "object reference not set to an instance of an object"

我不知道哪个对象为NULL.在我所有的尝试中,其他所有事物都完全相同....

I don´t know which object is NULL. Everythin else is exactly the same in all my tries....

有人可以给我一个提示吗?

Can anybody give me a hint?

此致

本尼

StackTrace:

StackTrace:

   bei KernelExtensions.Get[TKey,TValue](IDictionary´2 col, TKey key)
   bei iText.Kernel.Pdf.PdfDictionary.Get(PdfName key, Boolean asDirect)
   bei iText.Kernel.Pdf.PdfDictionary.Get(PdfName key)
   bei iText.Kernel.Pdf.PdfPage.GetContentStreamCount()
   bei iText.Kernel.Pdf.PdfPage.GetLastContentStream()
   bei iText.Kernel.Pdf.Canvas.PdfCanvas.GetPageStream(PdfPage page)
   bei iText.Kernel.Pdf.Canvas.PdfCanvas..ctor(PdfPage page, Boolean wrapOldContent)
   bei iText.Layout.Renderer.DocumentRenderer.FlushSingleRenderer(IRenderer resultRenderer)
   bei iText.Layout.Renderer.RootRenderer.AddChild(IRenderer renderer)
   bei iText.Layout.RootElement´1.CreateAndAddRendererSubTree(IElement element)
   bei iText.Layout.RootElement´1.Add(IBlockElement element)
   bei iText.Layout.Document.Add(IBlockElement element)
   bei iTextPDF.class_iTextPDF.TableEnd() in D:\Documents\15 - Visual Studio Projects\iTextPDF\iTextPDF\iTextPDF.vb:Zeile 1668.
   bei iTextPDF.class_iTextPDF.addTextFrame(String text, String posLowerLeftPointFromLeft, String posLowerLeftPointFromBottom, String width, String height, PdfFont font, Single fontSize, Color fontColor, Single strokeWidth, Color strokeColor, Color fillColor, TextAlignment alignment, String innerSpacing, Int32 placeOnPage) in D:\Documents\15 - Visual Studio Projects\iTextPDF\iTextPDF\iTextPDF.vb:Zeile 1360.
   bei iTextPDFTest.Form1.Button1_Click(Object sender, EventArgs e) in D:\Documents\15 - Visual Studio Projects\iTextPDFTest\iTextPDFTest\Form1.vb:Zeile 225.
   bei System.Windows.Forms.Control.OnClick(EventArgs e)
   bei System.Windows.Forms.Button.OnClick(EventArgs e)
   bei System.Windows.Forms.Button.PerformClick()
   bei iTextPDFTest.Form1.Form1_Load(Object sender, EventArgs e) in D:\Documents\15 - Visual Studio Projects\iTextPDFTest\iTextPDFTest\Form1.vb:Zeile 9.
   bei System.EventHandler.Invoke(Object sender, EventArgs e)
   bei System.Windows.Forms.Form.OnLoad(EventArgs e)
   bei System.Windows.Forms.Form.OnCreateControl()
   bei System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   bei System.Windows.Forms.Control.CreateControl()
   bei System.Windows.Forms.Control.WmShowWindow(Message& m)
   bei System.Windows.Forms.Control.WndProc(Message& m)
   bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   bei System.Windows.Forms.Form.WmShowWindow(Message& m)
   bei System.Windows.Forms.Form.WndProc(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

推荐答案

这是一个很好的提示.我在创建文档"时将"immediateFlush"设置为false.然后页面保持可编辑"状态,我无法将表格粘贴到第一页.

This was a good hint. I set "immediateFlush" at the creation of "Document" to false. Then the page remains "editable" and I cant paste the table to the first page.

这篇关于第1页上的itext7表SetFixedPosition失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆