TPPDF:在Table()的同一单元格中添加具有文本内容的多个图像

我正在使用PDF Builder应用程序,并通过了this教程。

是否可以在具有多个图像的单元格中添加一些文本。我尝试了不同的方法,但是导致PDF错误。

我已经尝试过:

      let table = PDFTable()

            let str = String(format: "Lorem Ipsum is simply dummy text of the printing and typesetting industry.")
            let str1 = String(format: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. \nLorem Ipsum has been the industry's standard dummy text ever since the 1500s,when an unknown printer took a galley of type and scrambled it to make a type specimen book. \n\nIt has survived not only five centuries,but also the leap into electronic typesetting,remaining essentially unchanged. ")

            do {
                try table.generateCells(
                    data:[
                        ["Name","Image","Description"],[project.name + "\n" +  project.address1,UIImage(named: "demo")!,str],str1]
                        ],alignments: [
                    [.topLeft,.top,.top],[.topLeft,.top]
                        ])
                } catch PDFError.tableContentInvalid(let value) {
                    // In case invalid input is provided,this error will be thrown.

                    print("This type of object is not supported as table content: " + String(describing: (type(of: value))))
                } catch {
                    // General error handling in case something goes wrong.

                    print("Error while creating table: " + error.localizedDescription)
                }

    table.widths = [
               0.23,0.30,0.47
           ]

        let style = PDFTableStyleDefaults.simple
    table.style = style

    do {
        // Style each cell individually
        try table.setCellStyle(row: 1,column: 0,style: PDFTableCellStyle(colors: (fill: UIColor.lightGray,text: UIColor.black)))
        try table.setCellStyle(row: 1,column: 1,column: 2,text: UIColor.black)))
        try table.setCellStyle(row: 2,text: UIColor.black)))
    } catch PDFError.tableIndexOutOfBounds(let index,let length){
        // In case the index is out of bounds

        print("Requested cell is out of bounds! \(index) / \(length)")
    } catch {
        // General error handling in case something goes wrong.

        print("Error while setting cell style: " + error.localizedDescription)
    }
    table.padding = 1.0
    table.margin = 2.0

    table.showHeadersOnEveryPage = true

    document.add(table: table)

请帮助我找到解决方法。谢谢。

q178455231 回答:TPPDF:在Table()的同一单元格中添加具有文本内容的多个图像

对不起,您没有及早答复(以某种方式未收到通知)。

  1. 尝试在表格单元格中使用组。
  2. 尝试使用新的表api和逻辑(仍在开发中,请参见分支develop),如果仍然不能解决问题,请打开新问题。请为我提供一个代码示例项目,以重现您的用例。
本文链接:https://www.f2er.com/3057881.html

大家都在问