Skip to content

Error with generateCells, setCellStyle and PDFGenerator.generate #269

@pura-agency

Description

@pura-agency

ℹ Please fill out this template when filing an issue.
All lines beginning with an ℹ symbol instruct you with what info we expect. You can delete those lines once you've filled in the info.

Per our *COMMUNICATION guidelines, we use GitHub for
bugs and feature requests, not general support. Other issues should be opened on Stack Overflow with the tag TPPDF.

What did you do?

ℹ I updated the library to the last version, same error with CocoaPods or SwiftPackage.

What did you expect to happen?

ℹ Using the methods like the previous versions.

What happened instead?

ℹ Error with those methods and I can't find them in the new version of the library code, for example in the old version I can find .generateCells in "PDFTable.swift line 54", .setCellStyle in "PDFTable.swift line 75", PDFGenerator.generate in "PDFGenerator+Generation.swift line 84" (Bundle version string (short) 1.5.4 - found in TPPDF-Info.plist).
I see in your documentation that you suggest these methods even in the new version: https://github.com/techprimate/TPPDF/tree/swift-4.2
The errors are:
• Value of type 'PDFTable' has no member 'generateCells' - for "try table.generateCells(data: cellsData, alignments: alignments)"
• Value of type 'PDFTable' has no member 'setCellStyle' - for "try table.setCellStyle(row: 0, column: 0, style: headerCell)"
• Extra arguments at positions #1, #3, #4 in cal - for "try PDFGenerator.generate(document: document, to: docURL, progress: { progress in }, debug: false)}, debug: false)"
Each of them are in a do try catch or do try statement

TPPDF Environment

TPPDF version: ℹ2.3.4
Xcode version: ℹ12.4
Swift version: ℹ5 - SwiftUI

Demo Code / Project

ℹ Please add a code snippet, link to or upload a project we can download that reproduces the issue.
ℹ We need a fully compilingPDFDocument

do {
try table.generateCells(data: cellsData, alignments: alignments)
} catch PDFError.tableContentInvalid(let value) {
// In case invalid input is provided, this error will be thrown.
//ProgressHUD.showError("Qualcosa è andato storto")
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.
//ProgressHUD.showError("Qualcosa è andato storto")
print("Error while creating table: " + error.localizedDescription)
}

do {
// Style each cell individually
try table.setCellStyle(row: 0, column: 0, style: headerCell)
try table.setCellStyle(row: 0, column: 1, style: headerCell)
try table.setCellStyle(row: 0, column: 2, style: headerCell)
try table.setCellStyle(row: 0, column: 3, style: headerCell)
try table.setCellStyle(row: 0, column: 4, style: headerCell)
try table.setCellStyle(row: 0, column: 5, style: headerCell)
try table.setCellStyle(row: 0, column: 6, style: headerCell)
try table.setCellStyle(row: 0, column: 7, style: headerCell)
} 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)
            }

do {

                try PDFGenerator.generate(document: document, to: docURL, progress: { progress in
                    print(progress)
                    //self.popUpPdfProgressView.setProgress(Float(progress), animated: true)

                }, debug: false)

                let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
                let url = NSURL(fileURLWithPath: path)
                if let pathComponent = url.appendingPathComponent("report.pdf") {
                    let filePath = pathComponent.path
                    let fileManager = FileManager.default
                    if fileManager.fileExists(atPath: filePath) {
                        print("FILE AVAILABLE")

                        let controller = UIDocumentInteractionController(url: pathComponent as URL)
                        controller.presentPreview(animated: true)
                    } else {
                        print("FILE NOT AVAILABLE")
                    }
                } else {
                    print("FILE PATH NOT AVAILABLE")
                }

            } catch {
                print("Error while generating PDF: " + error.localizedDescription)
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions