pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r969976 - /websites/production/pdfbox/content/2.0/migration.html
Date Fri, 23 Oct 2015 13:33:59 GMT
Author: msahyoun
Date: Fri Oct 23 13:33:58 2015
New Revision: 969976

Log:
Site checkin for project Apache PDFBox Website

Modified:
    websites/production/pdfbox/content/2.0/migration.html

Modified: websites/production/pdfbox/content/2.0/migration.html
==============================================================================
--- websites/production/pdfbox/content/2.0/migration.html (original)
+++ websites/production/pdfbox/content/2.0/migration.html Fri Oct 23 13:33:58 2015
@@ -222,7 +222,7 @@ results when switching to PDFBox 2.0.0.<
 <p>Font handling now has full Unicode support and supports font subsetting.</p>
 
 <p>TrueType fonts shall now be loaded using</p>
-<div class="highlight"><pre><code class="language-text" data-lang="text">PDType0Font.load
+<div class="highlight"><pre><code class="language-java" data-lang="java"><span
class="n">PDType0Font</span><span class="o">.</span><span class="na">load</span>
 </code></pre></div>
 <p>to leverage that. </p>
 
@@ -247,41 +247,47 @@ and so on. The <code>add</code> method n
 <h3 id="iterating-pages">Iterating Pages</h3>
 
 <p>With PDFBox 2.0.0 the prefered way to iterate through the pages of a document is</p>
-<div class="highlight"><pre><code class="language-text" data-lang="text">for(PDPage
page : document.getPages())
+
+<p>~~java
+for(PDPage page : document.getPages())
 {
- ... (do something)
+    ... (do something)
 }
-</code></pre></div>
+~~~</p>
+
 <h3 id="pdf-rendering">PDF Rendering</h3>
 
 <p>With PDFBox 2.0.0 <code>PDPage.convertToImage</code>has been removed.
Instead the new <code>PDFRenderer</code> class shall be used.</p>
-<div class="highlight"><pre><code class="language-text" data-lang="text">PDDocument
document = PDDocument.load(new File(pdfFilename));
-PDFRenderer pdfRenderer = new PDFRenderer(document);
-int pageCounter = 0;
-for (PDPage page : document.getPages())
-{ 
-    pdfRenderer.renderImageWithDPI(pageCounter, 300, ImageType.RGB);
-
-    // suffix in filename will be used as the file format
-    ImageIOUtil.writeImage(bim, pdfFilename + &quot;-&quot; + (pageCounter++) + &quot;.png&quot;,
300);
-}
-document.close();
+<div class="highlight"><pre><code class="language-java" data-lang="java"><span
class="n">PDDocument</span> <span class="n">document</span> <span
class="o">=</span> <span class="n">PDDocument</span><span class="o">.</span><span
class="na">load</span><span class="o">(</span><span class="k">new</span>
<span class="nf">File</span><span class="o">(</span><span class="n">pdfFilename</span><span
class="o">));</span>
+<span class="n">PDFRenderer</span> <span class="n">pdfRenderer</span>
<span class="o">=</span> <span class="k">new</span> <span class="nf">PDFRenderer</span><span
class="o">(</span><span class="n">document</span><span class="o">);</span>
+<span class="kt">int</span> <span class="n">pageCounter</span> <span
class="o">=</span> <span class="mi">0</span><span class="o">;</span>
+<span class="k">for</span> <span class="o">(</span><span class="n">PDPage</span>
<span class="n">page</span> <span class="o">:</span> <span class="n">document</span><span
class="o">.</span><span class="na">getPages</span><span class="o">())</span>
+<span class="o">{</span> 
+    <span class="n">pdfRenderer</span><span class="o">.</span><span
class="na">renderImageWithDPI</span><span class="o">(</span><span
class="n">pageCounter</span><span class="o">,</span> <span class="mi">300</span><span
class="o">,</span> <span class="n">ImageType</span><span class="o">.</span><span
class="na">RGB</span><span class="o">);</span>
+
+    <span class="c1">// suffix in filename will be used as the file format</span>
+    <span class="n">ImageIOUtil</span><span class="o">.</span><span
class="na">writeImage</span><span class="o">(</span><span class="n">bim</span><span
class="o">,</span> <span class="n">pdfFilename</span> <span class="o">+</span>
<span class="s">&quot;-&quot;</span> <span class="o">+</span>
<span class="o">(</span><span class="n">pageCounter</span><span
class="o">++)</span> <span class="o">+</span> <span class="s">&quot;.png&quot;</span><span
class="o">,</span> <span class="mi">300</span><span class="o">);</span>
+<span class="o">}</span>
+<span class="n">document</span><span class="o">.</span><span class="na">close</span><span
class="o">();</span>
 </code></pre></div>
 <h3 id="pdf-printing">PDF Printing</h3>
 
 <p>With PDFBox 2.0.0 <code>PDFPrinter</code> has been removed.</p>
 
 <p>Users of <code>PDFPrinter.silentPrint()</code> should now use this code:</p>
-<div class="highlight"><pre><code class="language-text" data-lang="text">PrinterJob
job = PrinterJob.getPrinterJob();
+
+<p>~~java
+PrinterJob job = PrinterJob.getPrinterJob();
 job.setPageable(new PDFPageable(document));
 job.print();
-</code></pre></div>
+~~~</p>
+
 <p>While users of <code>PDFPrinter.print()</code> should now use this code:</p>
-<div class="highlight"><pre><code class="language-text" data-lang="text">PrinterJob
job = PrinterJob.getPrinterJob();
-job.setPageable(new PDFPageable(document));
-if (job.printDialog()) {
-    job.print();
-}
+<div class="highlight"><pre><code class="language-java" data-lang="java"><span
class="n">PrinterJob</span> <span class="n">job</span> <span class="o">=</span>
<span class="n">PrinterJob</span><span class="o">.</span><span
class="na">getPrinterJob</span><span class="o">();</span>
+<span class="n">job</span><span class="o">.</span><span class="na">setPageable</span><span
class="o">(</span><span class="k">new</span> <span class="nf">PDFPageable</span><span
class="o">(</span><span class="n">document</span><span class="o">));</span>
+<span class="k">if</span> <span class="o">(</span><span class="n">job</span><span
class="o">.</span><span class="na">printDialog</span><span class="o">())</span>
<span class="o">{</span>
+    <span class="n">job</span><span class="o">.</span><span class="na">print</span><span
class="o">();</span>
+<span class="o">}</span>
 </code></pre></div>
 <p>Advanced use case examples can be found in th examples package under org/apache/pdfbox/examples/printing/Printing.java</p>
 
@@ -292,10 +298,10 @@ there is a clear distinction between fie
 tree are now represented by the <code>PDNonTerminalField</code> class.</p>
 
 <p>With PDFBox 2.0.0 the prefered way to iterate through the fields is now</p>
-<div class="highlight"><pre><code class="language-text" data-lang="text">for
(PDField field : form.getFieldTree())
-{
-    ... (do something)
-}
+<div class="highlight"><pre><code class="language-java" data-lang="java"><span
class="k">for</span> <span class="o">(</span><span class="n">PDField</span>
<span class="n">field</span> <span class="o">:</span> <span class="n">form</span><span
class="o">.</span><span class="na">getFieldTree</span><span class="o">())</span>
+<span class="o">{</span>
+    <span class="o">...</span> <span class="o">(</span><span class="k">do</span>
<span class="n">something</span><span class="o">)</span>
+<span class="o">}</span>
 </code></pre></div>
 <p>Most <code>PDField</code> subclasses now accept Java generic types such
as <code>String</code> as parameters instead of the former <code>COSBase</code>
subclasses.</p>
 



Mime
View raw message