c# - 如何使用 dbAutoTrack 使用 DrawTable

标签 c# pdf

我正在使用 dbAutoTrack 生成 PDF,因为我必须添加表格,但我得到了异常,比如对象引用未设置为对象的实例

下面是我的代码

  Table t=new Table();
  Row row=new Row(t);

  row.Cells.Add("ABC");
  t.Rows.Add(row);
  _pdfGraphics.DrawTable(100,200, t);

其中 _pdfGraphics 是 PDFGraphics 的对象。 提前致谢

最佳答案

您很可能收到类似这样的消息:“此行中的列不足,列跨度为 1。”你只需要添加它们。

可行的样本:

        //Initialize a new PDF Document
        Document _document = new Document();   

        _document.Title = "Аpitron Sample";
        _document.Author = "StanlyF";
        _document.Creator = "АPItron LTD.";

        Page page = null;
        PDFGraphics graphics = null;

        Table _table =  new Table();
        _table.Columns.Add(30);
        Row row = new Row(_table);
        row.Height = 25;
        row.Cells.Add("ABC");
        _table.Rows.Add(row);
        while (_table != null)
        {
            //Initialize new page with default PageSize A4
            page = new Page(PageSize.A4);

            //Add page to document
            _document.Pages.Add(page);
            //Get the PDFGraphics object for drawing to the page.
            graphics = page.Graphics;
            _table = graphics.DrawTable(100,200, _table); 

        }

        using(FileStream _fs = new FileStream("Table_Sample.pdf", System.IO.FileMode.Create, System.IO.FileAccess.Write))  
        {
            //Generate PDF to the stream
            _document.Generate(_fs);
            Process.Start("Table_Sample.pdf");
        }

关于c# - 如何使用 dbAutoTrack 使用 DrawTable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18356776/

相关文章:

c# - await Task.WhenAll(tasks) 异常处理,记录来自任务的所有异常

c# - 我怎样才能做一个有 5 秒暂停的无限循环

c# - LINQ 中的 LEFT JOIN 到实体?

c# - WPF 使用相对路径从程序集中的任何位置访问资源

c# - 将 JavaScript 正则表达式转换为 C#

javascript - 保存服务返回的 PDF

java - 如何使用 Java/FTP 在 Windows 上下载/打开 PDF 文件?

c++ - 使用 Qt WebEngineView 在特定页面打开 PDF

pdf - Crystal Reports 生成的 PDF 缺少字体

Django 更改 pdf 字体的 xhtml2pdf