<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>生信菜鸟团 &#187; pdf</title>
	<atom:link href="http://www.bio-info-trainee.com/tag/pdf/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bio-info-trainee.com</link>
	<description>欢迎去论坛biotrainee.com留言参与讨论，或者关注同名微信公众号biotrainee</description>
	<lastBuildDate>Sat, 28 Jun 2025 14:30:13 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.33</generator>
	<item>
		<title>用php脚本把Rstudio公司的所有cheatsheet合并</title>
		<link>http://www.bio-info-trainee.com/1673.html</link>
		<comments>http://www.bio-info-trainee.com/1673.html#comments</comments>
		<pubDate>Thu, 02 Jun 2016 23:51:19 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[计算机基础]]></category>
		<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Rstudio]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1673</guid>
		<description><![CDATA[R studio公司毕竟是商业化公司，在R语言推广方面做得很棒。网站什么总共有9 &#8230; <a href="http://www.bio-info-trainee.com/1673.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>R studio公司毕竟是商业化公司，在R语言推广方面做得很棒。网站什么总共有9个cheatsheet，R语言入门完全可以把这个当做笔记，写代码随时查用！</p>
<p>我批量下载了所有，但是想打印的时候，发现挺麻烦的，因为我不知道批量打印的方法，索性我还是半个程序猿，所以搜索了一下批量合并pdf的方法，这样就可以批量打印了，也方便传输这个文件。</p>
<p>其实如果在linux系统里面，一般都会自带pdf toolkit工具，里面有命令可以合并PDF文档。<span id="more-1673"></span></p>
<p>正好我搜索到了一个比较好玩的实现方法，就是PHP脚本，我还是第一次听说PHP也可以来当做脚本运行，简单浏览了一下，发现跟perl其实差不多，它需要require一些其它public的php脚本，perl就是需要载入一些模块。</p>
<p>首先列出所有下载地址，用wget批量来下载：</p>
<blockquote><p><a href="http://www.rstudio.com/wp-content/uploads/2016/05/base-r.pdf">http://www.rstudio.com/wp-content/uploads/2016/05/base-r.pdf</a></p>
<p><a href="http://www.rstudio.com/wp-content/uploads/2016/02/advancedR.pdf">http://www.rstudio.com/wp-content/uploads/2016/02/advancedR.pdf</a></p>
<p><a href="http://www.rstudio.com/wp-content/uploads/2015/03/rmarkdown-reference.pdf">http://www.rstudio.com/wp-content/uploads/2015/03/rmarkdown-reference.pdf</a></p>
<p><a href="https://www.rstudio.com/wp-content/uploads/2016/01/rstudio-IDE-cheatsheet.pdf">https://www.rstudio.com/wp-content/uploads/2016/01/rstudio-IDE-cheatsheet.pdf</a></p>
<p><a href="https://www.rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf">https://www.rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf</a></p>
<p><a href="https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf">https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf</a></p>
<p><a href="https://www.rstudio.com/wp-content/uploads/2015/03/ggplot2-cheatsheet.pdf">https://www.rstudio.com/wp-content/uploads/2015/03/ggplot2-cheatsheet.pdf</a></p>
<p><a href="https://www.rstudio.com/wp-content/uploads/2015/06/devtools-cheatsheet.pdf">https://www.rstudio.com/wp-content/uploads/2015/06/devtools-cheatsheet.pdf</a></p>
<p><a href="https://www.rstudio.com/wp-content/uploads/2015/02/shiny-cheatsheet.pdf">https://www.rstudio.com/wp-content/uploads/2015/02/shiny-cheatsheet.pdf</a></p></blockquote>
<p>然后写一个PHP函数，get到待合并目录下面的所有pdf文件：</p>
<blockquote><p>&lt;?php</p>
<p>$dir="./Rstudio_cheatsheets/";</p>
<p><strong>$file=array_diff(scandir($dir),array('..','.'));</strong></p>
<p>print_r($file);</p>
<p>?&gt;</p></blockquote>
<p>上面的代码相当于简单的PHP语法入门，其实这个语言感觉跟perl挺像的，就是列出文件夹里面的文件。</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/1.png"><img class="alignnone size-full wp-image-1674" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/1.png" alt="1" width="603" height="264" /></a></p>
<p>然后需要下载两个PHP压缩包，解压到当前文件夹</p>
<p>FPDF: <a href="http://www.fpdf.org/en/download.php">http://www.fpdf.org/en/download.php</a></p>
<p>FPDI: <a href="https://www.setasign.com/products/fpdi/downloads">https://www.setasign.com/products/fpdi/downloads</a></p>
<p>然后写一个脚本来实现合并的功能。</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/2.png"><img class="alignnone size-full wp-image-1675" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/2.png" alt="2" width="462" height="324" /></a></p>
<p>这个语法对我来说很诡异，最后居然还报错！！！</p>
<blockquote><p>PHP Fatal error:  Uncaught exception 'Exception' with message 'This document (/home/jmzeng/tmp/test_php/Rstudio_cheatsheets/advancedR.pdf) <strong>probably uses a compression technique which is not supported by the free parser shipped with FPDI. </strong>(See <a href="https://www.setasign.com/fpdi-pdf-parser">https://www.setasign.com/fpdi-pdf-parser</a> for more details)' in /home/jmzeng/tmp/test_php/pdf_parser.php:322</p>
<p>Stack trace:</p>
<p>#0 /home/jmzeng/tmp/test_php/pdf_parser.php(195): pdf_parser-&gt;_readXref(Array, 116)</p>
<p>#1 /home/jmzeng/tmp/test_php/fpdi_pdf_parser.php(64): pdf_parser-&gt;__construct('/home/jmzeng/tm...')</p>
<p>#2 /home/jmzeng/tmp/test_php/fpdi.php(123): fpdi_pdf_parser-&gt;__construct('/home/jmzeng/tm...')</p>
<p>#3 /home/jmzeng/tmp/test_php/fpdi.php(101): FPDI-&gt;_getPdfParser('/home/jmzeng/tm...')</p>
<p>#4 /home/jmzeng/tmp/test_php/merge_pdf.php(11): FPDI-&gt;setSourceFile('advancedR.pdf')</p>
<p>#5 {main}</p>
<p>thrown in /home/jmzeng/tmp/test_php/pdf_parser.php on line 322</p></blockquote>
<p>简单看了下报错内容，估计是PDF这个技术更新的太快了，R studio公司的 cheatsheet 用的PDF标准不被PHP的那两个模块支持！</p>
<p>后来我直接用了<strong>pdfjoin Rstudio_cheatsheets/*pdf   这个命令，简单粗暴，一下子就搞定了！</strong></p>
<p>----</p>
<blockquote><p>  pdfjam: This is pdfjam version 2.08.</p>
<p>pdfjam: Reading any site-wide or user-specific defaults...</p>
<p>(none found)</p>
<p>pdfjam: Effective call for this run of pdfjam:</p>
<p>/usr/bin/pdfjam --fitpaper 'true' --rotateoversize 'true' --suffix joined -- Rstudio_cheatsheets/advancedR.pdf - Rstudio_cheatsheets/base-r.pdf - Rstudio_cheatsheets/data-wrangling-cheatsheet.pdf - Rstudio_cheatsheets/devtools-cheatsheet.pdf - Rstudio_cheatsheets/ggplot2-cheatsheet.pdf - Rstudio_cheatsheets/rmarkdown-cheatsheet.pdf - Rstudio_cheatsheets/rmarkdown-reference.pdf - Rstudio_cheatsheets/rstudio-IDE-cheatsheet.pdf - Rstudio_cheatsheets/shiny-cheatsheet.pdf -</p>
<p>pdfjam: Calling pdflatex...</p>
<p><strong>  pdfjam: Finished.  Output was to '/home/jmzeng/tmp/test_php/shiny-cheatsheet-joined.pdf'.</strong></p></blockquote>
<p>但是，格式不怎么正常， 我最后还是推荐用一个网页工具，你直接上传你的PDF，人家马上就给你合并好了，你直接下载即可。</p>
<p>这种技术，玩玩就好，不要深究。</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1673.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>perl操作pdf文档</title>
		<link>http://www.bio-info-trainee.com/873.html</link>
		<comments>http://www.bio-info-trainee.com/873.html#comments</comments>
		<pubDate>Fri, 17 Jul 2015 03:47:22 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[模块]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=873</guid>
		<description><![CDATA[大家看看就好，这个模块写的不怎么样，而且有高手已经写了一个pdftoolkit就 &#8230; <a href="http://www.bio-info-trainee.com/873.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>大家看看就好，这个模块写的不怎么样，而且有高手已经写了一个pdftoolkit就是完全用这个模块实现了大部分pdf文档的操作</p>
<p><strong>PDF::API2</strong><strong>模块使用笔记</strong></p>
<p>一：简单使用方法</p>
<p>use PDF::API2;</p>
<table>
<tbody>
<tr>
<td width="284"># Create a blank PDF file</td>
<td width="284">$pdf = PDF::API2-&gt;new();</td>
</tr>
<tr>
<td width="284"># Open an existing PDF file</td>
<td width="284">$pdf = PDF::API2-&gt;open('some.pdf');</td>
</tr>
<tr>
<td width="284"># Add a blank page</td>
<td width="284">$page = $pdf-&gt;page();</td>
</tr>
<tr>
<td width="284"># Retrieve an existing page</td>
<td width="284">$page = $pdf-&gt;openpage($page_number);</td>
</tr>
<tr>
<td width="284"># Set the page size</td>
<td width="284">$page-&gt;mediabox('Letter');</td>
</tr>
<tr>
<td width="284"># Add a built-in font to the PDF</td>
<td width="284">$font = $pdf-&gt;corefont('Helvetica-Bold');</td>
</tr>
<tr>
<td width="284"># Add an external TTF font to the PDF</td>
<td width="284">$font = $pdf-&gt;ttfont('/path/to/font.ttf');</td>
</tr>
<tr>
<td width="284">&nbsp;</p>
<p># Add some text to the page</td>
<td width="284">$text = $page-&gt;text();</p>
<p>$text-&gt;font($font, 20);</p>
<p>$text-&gt;translate(200, 700);</p>
<p>$text-&gt;text('Hello World!');</td>
</tr>
<tr>
<td width="284"># Save the PDF</td>
<td width="284">$pdf-&gt;saveas('/path/to/new.pdf');</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>实例：</p>
<p>use PDF::API2;</p>
<p>$pdf=PDF::API2-&gt;new;</p>
<p>$pdf-&gt;mediabox('A4');</p>
<p>$ft=$pdf-&gt;cjkfont('Song');</p>
<p>$page = $pdf-&gt;page;</p>
<p>$gfx=$page-&gt;gfx;</p>
<p>$gfx-&gt;textlabel(50,750,$ft,20,"\x{Cool44}\x{4EA7}"); # 资产二字</p>
<p>$pdf-&gt;saveas('Song_Test.pdf');</p>
<p>&nbsp;</p>
<p>二：主要对象及方法</p>
<p>1、pdf对象可以创造，可以打开，可以保存，可以更新，还有一堆参数可以设置</p>
<p>$pdf-&gt;preferences(%options)还可以设置一些浏览参数，不过本来pdf阅读器可以设置，没必要在这里花时间。</p>
<p>这个可以当做是个人创建pdf的保密信息，也许有一点用吧。</p>
<p>还可以可以设置页脚$pdf-&gt;pageLabel($index, $options</p>
<p>2、Page对象，可以新建，可以打开，可以保存（需要指定保存的位置）</p>
<p>$page = $pdf-&gt;page()</p>
<p>$page = $pdf-&gt;page($page_number)</p>
<p>$page = $pdf-&gt;openpage($page_number);</p>
<p>还可以更新旧的pdf，这样可以循环获取pdf页面不停的累积到一个新的pdf</p>
<p>$page = $pdf-&gt;import_page($source_pdf, $source_page_number, $target_page_number)</p>
<p>$pdf = PDF::API2-&gt;new();</p>
<p>$old = PDF::API2-&gt;open('our/old.pdf');   # Add page 2 from the old PDF as page 1 of the new PDF</p>
<p>$page = <strong>$pdf-&gt;import_page</strong>($old, 2);</p>
<p>$pdf-&gt;saveas('our/new.pdf');If $source_page_number is 0 or -1, it will return the last page in the document.</p>
<p>$count = $pdf-&gt;pages()Returns the number of pages in the document.</p>
<p>这样就可以写一个简单程序把我们的pdf文件合并</p>
<p>use PDF::API2;</p>
<p>my $new = PDF::API2-&gt;new;</p>
<p>foreach my $filename (@ARGV) {   my $pdf = PDF::API2-&gt;open($filename);   $new-&gt;importpage($pdf, $_) foreach 1 .. $pdf-&gt;pages;}$new-&gt;saveas('new.pdf'); $pdf-&gt;mediabox($name)</p>
<p>可以指定A4，A3，A5等等$pdf-&gt;mediabox($w, $h)可以指定宽度和高度$pdf-&gt;mediabox($llx, $lly, $urx, $ury)</p>
<p>3，还可以随意画点线面及表格，太复杂了就不看了</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/873.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
