TCPDF 可以将文本输出为本地图像吗 [英] Can TCPDF output text as image natively

查看:42
本文介绍了TCPDF 可以将文本输出为本地图像吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TCPD 在生成 PDF 时似乎非常强大.由于TCPDF中可以直接做很多事情,不知道是否可以在TCPDF中直接将文本转为图像.(或以某种方式保存PDF,使机器无法轻松读取某些文本部分)

TCPDF seems really powerful when generating PDFs. As many things can be done directly in TCPDF, I wonder whether it is possible to convert text to image directly in TCPDF. ( or save the PDF in such a way, that certain text parts cannot be easily read by machines)

目标是提供一种垃圾邮件保护,让抓取工具在不使用 OCR 技术的情况下难以从 PDF 文件中提取某些数据.

The goal is to have a kind of spam protection, by making it hard for scrapers to extract certain data from the PDF files without using OCR techniques.

我能够从 PHP 中的文本创建图像并将它们插入到 TCPDF 中,但是直接在 TCPDF 中进行这种转换可以更轻松地处理字体.

I am able to create images from text in PHP and insert them into TCPDF, but doing this conversion directly in TCPDF would make it easier to handle the fonts.

推荐答案

不,据我所知.我正在回答这个问题,因为 tcpdf 文档目前尚不清楚,我也想知道.仅供参考,我所做的是使用 imagick(安装正确后直接)将 tcpdf pdf 输出转换为图像:

No, not as far as I can tell. I'm answering this question as tcpdf documentation is currently unclear and i wanted to know too. fyi what I did is use imagick (straightforward once its installed right) to turn the tcpdf pdf output into an image:

// from tcpdf...
$pdf_out = $pdf->Output($pdf_filename, 'S'); // returns pdf string
$imagick = new Imagick();
$imagick->setResolution($dpi,$dpi); // eg 300, 300
$imagick->readImageBlob($pdf_out);
$imagick->setImageFormat('pdf');    // for pdf use 'pdf'
$imagick->setImageCompressionQuality(60);
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="' . $pdf_filename . '"');
echo $imagick; // put to broswer

这篇关于TCPDF 可以将文本输出为本地图像吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆