【问题标题】:How to create multi table side by side with fpdf如何使用 fpdf 并排创建多表
【发布时间】:2014-11-21 04:16:38
【问题描述】:

谁能教我如何使用 fpdf 并排创建一个表格:

我正在尝试将多列与创建表教程相结合,但失败了。任何帮助,将不胜感激。谢谢。

【问题讨论】:

    标签: php pdf pdf-generation fpdf


    【解决方案1】:

    如果您对 fpdf 感到困惑,可以尝试使用 Debenu Quick PDF。 此 C# 代码返回图片上的确切结果。它是通过合并单元格完成的,但您也可以使用零边框宽度 - 这取决于您的需要。当然你可以改变边框的宽度和颜色。

    DPL.LoadFromFile("blank.pdf", "");
    DPL.SetOrigin(1); //the top left page corner will be used for the origin 
    DPL.SetMeasurementUnits(0); //the units are approximately the same as a "point"
    
    string content1, content2, content3;
    content1 = "1<br>2<br>3<br>4<br>5<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>20";
    content2 = "21<br>22<br>23<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>30";
    content3 = "31<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>40";
    
    int tableID1 = DPL.CreateTable(20, 3); //20 rows, 3 columns
    DPL.SetTableColumnWidth(tableID1, 1, 1, 20); //width of the first column
    DPL.SetTableColumnWidth(tableID1, 2, 3, 40); //width of the second and third column
    DPL.SetTableRowHeight(tableID1, 1, 20, 10); //height of all rows
    DPL.MergeTableCells(tableID1, 2, 1, 20, 1); //merge the cells from second row to 20. row and from 1. column to 1. column - merge the cells of the first column
    DPL.MergeTableCells(tableID1, 2, 2, 20, 2); //merge the cells of the second column
    DPL.MergeTableCells(tableID1, 2, 3, 20, 3); //merge the cells of the third column
    DPL.SetTableCellContent(tableID1, 2, 1, content1); //add the content
    DPL.DrawTableRows(tableID1, 50, 50, 700, 1, 0); //draw the table to the page
    
    int tableID2 = DPL.CreateTable(20, 3);  // second table
    DPL.SetTableColumnWidth(tableID2, 1, 1, 20);
    DPL.SetTableColumnWidth(tableID2, 2, 3, 40);
    DPL.SetTableRowHeight(tableID2, 1, 20, 10);
    DPL.MergeTableCells(tableID2, 2, 2, 20, 2);
    DPL.MergeTableCells(tableID2, 2, 3, 20, 3);
    DPL.MergeTableCells(tableID2, 2, 1, 20, 1);
    DPL.SetTableCellContent(tableID2, 2, 1, content2); 
    DPL.DrawTableRows(tableID2, 160, 50, 700, 1, 0);
    
    int tableID3 = DPL.CreateTable(20, 3);   //third table
    DPL.SetTableColumnWidth(tableID3, 1, 1, 20);
    DPL.SetTableColumnWidth(tableID3, 2, 3, 40);
    DPL.SetTableRowHeight(tableID3, 1, 20, 10);
    DPL.MergeTableCells(tableID3, 2, 2, 20, 2);
    DPL.MergeTableCells(tableID3, 2, 3, 20, 3);
    DPL.MergeTableCells(tableID3, 2, 1, 20, 1);
    DPL.SetTableCellContent(tableID3, 2, 1, content3); 
    DPL.DrawTableRows(tableID3, 270, 50, 700, 1, 0);            
    
    DPL.SaveToFile("tables.pdf");
    

    您可以在这个网站上找到功能说明:

    http://www.debenu.com/docs/pdf_library_reference/CreateTable.php

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-12
      • 1970-01-01
      • 2015-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多