在表格视图单元格中预览PDF

时间:2021-08-10 22:19:41

Help me making a PDF preview, in a UITableViewCell. As I have read the documentation of QLPreviewController and UIDocumentInteractionController, these 2 only allow a full screen preview but I need to make a tiny preview in a table view cell. How could I do it?

帮我在UITableViewCell中做一个PDF预览。正如我读过QLPreviewController和UIDocumentInteractionController的文档,这两个只允许全屏预览,但我需要在表视图单元格中做一个小预览。我怎么做呢?

2 个解决方案

#1


3  

Here I posted some code to get an image (thumbnail) out of a PDF page. If you just want to preview and UIImage should be good enough. Once you have the image you can just add it as an UIImageVIew to the UITableViewCell. Just be careful to the the rendering both lazy and async, otherwise your table will lag badly.

这里我发布了一些代码,从PDF页面中获取图像(缩略图)。如果你只想预览UIImage就足够好了。一旦你有了图像,你可以把它作为UIImageVIew添加到UITableViewCell。只要小心延迟和异步的呈现,否则您的表将严重滞后。

#2


2  

CGPDFDocumentRef is what you want to look into. The iPhone demo "ZoomingPDFViewer" shows you how to create a PDF viewer, using CGPDFDocumentRef.

CGPDFDocumentRef是您要研究的内容。iPhone演示“ZoomingPDFViewer”向您展示如何使用CGPDFDocumentRef创建PDF查看器。

If you want to create a thumbnail, then you can create a image of the pdf first page and scale it to your need. This forum talks about how to do that.

如果您想创建一个缩略图,那么您可以创建pdf的第一个页面的图像,并将其缩放到您的需要。本论坛讨论如何做到这一点。

Happy coding.

快乐的编码。

#1


3  

Here I posted some code to get an image (thumbnail) out of a PDF page. If you just want to preview and UIImage should be good enough. Once you have the image you can just add it as an UIImageVIew to the UITableViewCell. Just be careful to the the rendering both lazy and async, otherwise your table will lag badly.

这里我发布了一些代码,从PDF页面中获取图像(缩略图)。如果你只想预览UIImage就足够好了。一旦你有了图像,你可以把它作为UIImageVIew添加到UITableViewCell。只要小心延迟和异步的呈现,否则您的表将严重滞后。

#2


2  

CGPDFDocumentRef is what you want to look into. The iPhone demo "ZoomingPDFViewer" shows you how to create a PDF viewer, using CGPDFDocumentRef.

CGPDFDocumentRef是您要研究的内容。iPhone演示“ZoomingPDFViewer”向您展示如何使用CGPDFDocumentRef创建PDF查看器。

If you want to create a thumbnail, then you can create a image of the pdf first page and scale it to your need. This forum talks about how to do that.

如果您想创建一个缩略图,那么您可以创建pdf的第一个页面的图像,并将其缩放到您的需要。本论坛讨论如何做到这一点。

Happy coding.

快乐的编码。