techprimate/TPPDF

PDFGenerator generateData takes no argument

Closed this issue · 1 comments

What did you do?

let generator = PDFGenerator(document: document)
let data = try PDFGenerator.generateData(document: document, progress: { progress in
print("progress: ", progress)
}, debug: false)

What did you expect to happen?

This used to work, but don't work anymore. Can't see any method that makes data from PDFDocument

What happened instead?

Unable to compile

TPPDF Environment

Hi,

this API has been updated a while ago for a simpler approach.
Take a look at the PDFGenerator+Generation.swift file for all options on how to generate a PDF.

While checking out the Usage description, I realized the usage is not complete and sometimes wrong - this will be updated accordingly.

For your use case, try the following:

let generator = PDFGenerator(document: document)
let observer: NSObjectProtocol! = generator.progress.observe(\.fractionCompleted) { (p, _) in
    print(p.localizedDescription ?? "")
}
let data = try generator.generateData()

(keep in mind, the observer must not be deallocated, such as describe here)