Repository: pdfbox-docs Updated Branches: refs/heads/asf-site 3aa32c870 -> f74750dc2
Site checkin for project Apache PDFBox Website Project: http://git-wip-us.apache.org/repos/asf/pdfbox-docs/repo Commit: http://git-wip-us.apache.org/repos/asf/pdfbox-docs/commit/f74750dc Tree: http://git-wip-us.apache.org/repos/asf/pdfbox-docs/tree/f74750dc Diff: http://git-wip-us.apache.org/repos/asf/pdfbox-docs/diff/f74750dc Branch: refs/heads/asf-site Commit: f74750dc2578fec03837f575dca8ae946d5d5779 Parents: 3aa32c8 Author: Maruan Sahyoun <sahy...@fileaffairs.de> Authored: Mon Jul 18 07:39:15 2016 +0200 Committer: Maruan Sahyoun <sahy...@fileaffairs.de> Committed: Mon Jul 18 07:39:15 2016 +0200 ---------------------------------------------------------------------- content/2.0/migration.html | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/pdfbox-docs/blob/f74750dc/content/2.0/migration.html ---------------------------------------------------------------------- diff --git a/content/2.0/migration.html b/content/2.0/migration.html index 2645b33..c2a7b86 100644 --- a/content/2.0/migration.html +++ b/content/2.0/migration.html @@ -201,10 +201,13 @@ results when switching to PDFBox 2.0.0.</p> <p>to leverage that.</p> <h3 id="pdf-resources-handling">PDF Resources Handling</h3> -<p>The individual calls to add resources such as <code class="highlighter-rouge">PDResource.addFont(PDFont font)</code> and <code class="highlighter-rouge">PDResource.addXObject(PDXObject xobject, String prefix)</code> -have been replaced with <code class="highlighter-rouge">PDResource.add(resource type)</code> where <code class="highlighter-rouge">resource type</code> represents the different resource classes such as <code class="highlighter-rouge">PDFont</code>, <code class="highlighter-rouge">PDAbstractPattern</code> +<p>The individual calls to add resources such as <code class="highlighter-rouge">PDResources.addFont(PDFont font)</code> and <code class="highlighter-rouge">PDResources.addXObject(PDXObject xobject, String prefix)</code> +have been replaced with <code class="highlighter-rouge">PDResources.add(resource type)</code> where <code class="highlighter-rouge">resource type</code> represents the different resource classes such as <code class="highlighter-rouge">PDFont</code>, <code class="highlighter-rouge">PDAbstractPattern</code> and so on. The <code class="highlighter-rouge">add</code> method now supports all the different type of resources available.</p> +<p>Instead of returning a <code class="highlighter-rouge">Map</code> like with <code class="highlighter-rouge">PDResources.getFonts()</code> or <code class="highlighter-rouge">PDResources.getXObjects()</code> in 2.0 an <code class="highlighter-rouge">Iterable<COSName></code> of references shall be retrieved with <code class="highlighter-rouge">PDResources.getFontNames()</code> or +<code class="highlighter-rouge">PDResources.getXObjectNames()</code>. The individual item can be retrieved with <code class="highlighter-rouge">PDResources.getFont(COSName fontName)</code> or <code class="highlighter-rouge">PDResources.getXObject(COSName xObjectName)</code>.</p> + <h3 id="working-with-images">Working with Images</h3> <p>The individual classes <code class="highlighter-rouge">PDJpeg()</code>, <code class="highlighter-rouge">PDPixelMap()</code> and <code class="highlighter-rouge">PDCCitt()</code> to import images have been replaced with <code class="highlighter-rouge">PDImageXObject.createFromFile</code> which works for JPG, TIFF (only G4 compression), PNG, BMP and GIF.</p> @@ -255,7 +258,7 @@ and so on. The <code class="highlighter-rouge">add</code> method now supports al <span class="n">PDFRenderer</span> <span class="n">pdfRenderer</span> <span class="o">=</span> <span class="k">new</span> <span class="n">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="o">{</span> <span class="c1">// note that the page number parameter is zero based</span> <span class="n">BufferedImage</span> <span class="n">bim</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> @@ -306,7 +309,7 @@ https://bugs.openjdk.java.net/browse/JDK-8041125</p> <p>Advanced use case examples can be found in th examples package under org/apache/pdfbox/examples/printing/Printing.java</p> <h3 id="text-extraction">Text Extraction</h3> -<p>In 1.8, to get the text colors, one method was to pass an expanded .properties file to the PDFStripper constructor. To achieve the same +<p>In 1.8, to get the text colors, one method was to pass an expanded .properties file to the PDFStripper constructor. To achieve the same in PDFBox 2.0 you can extend <code class="highlighter-rouge">PDFTextStripper</code>and add the following <code class="highlighter-rouge">Operators</code> to the constructor:</p> <div class="highlighter-rouge"><pre class="highlight"><code><span class="n">addOperator</span><span class="o">(</span><span class="k">new</span> <span class="n">SetStrokingColorSpace</span><span class="o">());</span> @@ -326,7 +329,7 @@ in PDFBox 2.0 you can extend <code class="highlighter-rouge">PDFTextStripper</co <h3 id="interactive-forms">Interactive Forms</h3> <p>Large parts of the support for interactive forms (AcroForms) have been rewritten. The most notable change from 1.8.x is that -there is a clear distinction between fields and the annotations representing them visually. Intermediate nodes in a field +there is a clear distinction between fields and the annotations representing them visually. Intermediate nodes in a field tree are now represented by the <code class="highlighter-rouge">PDNonTerminalField</code> class.</p> <p>With PDFBox 2.0.0 the prefered way to iterate through the fields is now</p>