let generator = QLThumbnailGenerator.shared
Task {
do {
let generated = try await generator.generateBestRepresentation(for: request)
print(generated) // <----- cannot get this when the file is large.
}
catch let err {
print(err)
}
}
I'm trying to create thumbnails for some pdf files. Everything works perfectly with small pdf files. But I cannot get the thumbnail for the large pdfs (e.g., > 10M).
Is there any file size limitation of QLThumbnailGenerator?
Thanks!
CodePudding user response:
I think this is a limitation of the async version of generateBestRepresentation. Try instead calling
generateRepresentations(
for request: QLThumbnailGenerator.Request,
update updateHandler: ((QLThumbnailRepresentation?, QLThumbnailRepresentation.RepresentationType, Error?) -> Void)? = nil
)
This will make multiple callbacks to updateHandler and you can keep checking the representation type until you get the .thumbnail, or you can just stop when you get the first .lowQualityThumbnail if you like.
