国产linux系统常见的为麒麟Linux,统信UOS等,基本都是基于debian再开发的linux。
问题描述:
windows下有多种软件可以轻松实现将图片批量生成PDF,比如利用虚拟打印机打印,比如利用niroPDF软件直接生成等,国产(麒麟)linux如何将图片批量生成PDF?
具体方法:
方法一,虚拟打印机的办法。
1. 安装cups 和cups-pdf,其中cups-pdf是虚拟打印的主要模块:
sudo apt-get install cups-pdf
2. cups-pdf 要求 root 权限,所以设置一下权限:
sudo chmod 4755 /usr/lib/cups/backend/cups-pdf
3. 用图片浏览器打开文件,选打印->打印到文件(这里可以设置目标文件路径)->OK
现在就得到了pdf格式的文件了.
方法二,利用安装特殊图片浏览器批量生成PDF的办法,很多图片浏览器集成了将图片生成PDF文件的功能。
1、你需要安装一个免费的图片浏览管理器gThumb
sudo apt install gthumb
2、在需要批量将图片转换为PDF 的文件夹打开浏览管理器gThumb,全选后----》打印到文件------》输出格式为pdf即可,异常简单,不赘述。
1、首先,我们到百度搜索相应的PDF编辑软件来对要修改PDF修改。PDF编辑软件运行修改如图所示:2、有了PDF编辑软件后,我们打开编辑软件菜单中文档下拉菜单,选择crop pages中的裁剪页面选择。
3、打开裁剪页面界面后,我们可以看到裁剪外边框和页面范围的选项。我们在裁剪外边框中可以手动的设置裁剪外边框的大小和删除空格等 *** 作。
4、还可以选择直接设为空白的外边框。
5、外边框设置完成后,我们在下面的页面范围中设置裁剪页面要执行的页面。可以是多个页面,多个页面输入时中间要用逗号隔开。
6、裁剪页面 *** 作完成后点击确定按钮即可完成 *** 作。确认无误后点击菜单文件下拉菜单,选择另存为以保持修改后的PDF文件。
tcpdf类生成PDF文件:一、安装tcpdf
二、tcpdf插件中examples
三、写入方法生成pdf页面
方法一、在index.php中写入pdfdemo方法
01)、使用命名空间
user TCPDF
02)、引入example01方法
public function pdfdemo(){
$html = '<h1 style="color: #0000FF">hello tcpdf</h1><br>我是波哥,我爱Thinkphp!!!<img src="logo.png"/>'
Pdf::createPdf($html)
exit()
}
public function pdfdemo1(){
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false)
// set document information
$pdf->SetCreator(PDF_CREATOR)
$pdf->SetAuthor('Nicola Asuni')
$pdf->SetTitle('TCPDF Example 001')
$pdf->SetSubject('TCPDF Tutorial')
$pdf->SetKeywords('TCPDF, PDF, example, test, guide')
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128))
$pdf->setFooterData(array(0,64,0), array(0,64,128))
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN))
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA))
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED)
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT)
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER)
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER)
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM)
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO)
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php')
$pdf->setLanguageArray($l)
}
// ---------------------------------------------------------
// set default font subsetting mode
$pdf->setFontSubsetting(true)
// Set font
// dejavusans is a UTF-8 Unicode font, if you only need to
// print standard ASCII chars, you can use core fonts like
// helvetica or times to reduce file size.
$pdf->SetFont('dejavusans', '', 14, '', true)
// Add a page
// This method has several options, check the source code documentation for more information.
$pdf->AddPage()
// set text shadow effect
$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'))
// Set some content to print
$html = <<<EOD
<h1>Welcome to <a href="http://www.tcpdf.org" style="text-decoration:nonebackground-color:#CC0000color:black"><span style="color:black">TC</span><span style="color:white">PDF</span></a>!</h1>
<i>This is the first example of TCPDF library.</i>
<p>This text is printed using the <i>writeHTMLCell()</i>method but you can also use: <i>Multicell(), writeHTML(), Write(), Cell() and Text()</i>.</p>
<p>Please check the source code documentation and other examples for further information.</p>
<p style="color:#CC0000">TO IMPROVE AND EXPAND TCPDF I NEED YOUR SUPPORT, PLEASE <a href="http://sourceforge.net/donate/index.php?group_id=128076">MAKE A DONATION!</a></p>
EOD
// Print text using writeHTMLCell()
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true)
// ---------------------------------------------------------
// Close and output PDF document
// This method has several options, check the source code documentation for more information.
$pdf->Output('example_001.pdf', 'I')
exit()
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)