-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with generateCells, setCellStyle and PDFGenerator.generate #269
Comments
Hi, thanks for filing an issue. It seems like you missed a few updates, so I'll quickly summarize them:
So in case you want to use version 2.X.X, I recommend you update to the latest table syntax 😃 |
Thank you I'm update the code of an outdated project and i was looking in the wrong page for the documentation, I like the changes but when I try to access the row I'm having a fatal error - Index out of range
|
Thanks for pointing this out. In fact, this is a documentation error. Excerpt from PDFTable.swift:
As you can see, it is necessary to provide a table size, so the subscript accessors work properly. I changed your example a little bit and it works now:
I will furthermore remove the default size |
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 compiling
PDFDocument
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
do {
The text was updated successfully, but these errors were encountered: