pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject [50/51] [partial] pdfbox-docs git commit: Site checkin for project Apache PDFBox Website
Date Tue, 07 Jun 2016 20:51:12 GMT
http://git-wip-us.apache.org/repos/asf/pdfbox-docs/blob/cd8511a3/content/1.8/architecture.html
----------------------------------------------------------------------
diff --git a/content/1.8/architecture.html b/content/1.8/architecture.html
index 4f673ad..f4aad24 100644
--- a/content/1.8/architecture.html
+++ b/content/1.8/architecture.html
@@ -246,21 +246,21 @@ doesn’t provide the functionality needed.</p>
 
 <p>A page in a pdf document is represented with a COSDictionary. The entries that are
available for a page can be seen in the PDF Reference and an example of a page looks like
this:</p>
 
-<p><code class="highlighter-rouge">text
-&lt;&lt;
+<div class="highlighter-rouge"><pre class="highlight"><code>&lt;&lt;
     /Type /Page
     /MediaBox [0 0 612 915]
     /Contents 56 0 R
 &gt;&gt;
-</code></p>
+</code></pre>
+</div>
 
 <p>The information within the dictionary can be accessed using the COS model</p>
 
-<p><code class="highlighter-rouge">java
-COSDictionary page = ...;
-COSArray mediaBox = (COSArray)page.getDictionaryObject( "MediaBox" );
-System.out.println( "Width:" + mediaBox.get( 3 ) );
-</code></p>
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="n">COSDictionary</span>
<span class="n">page</span> <span class="o">=</span> <span class="o">...;</span>
+<span class="n">COSArray</span> <span class="n">mediaBox</span> <span
class="o">=</span> <span class="o">(</span><span class="n">COSArray</span><span
class="o">)</span><span class="n">page</span><span class="o">.</span><span
class="na">getDictionaryObject</span><span class="o">(</span> <span
class="s">"MediaBox"</span> <span class="o">);</span>
+<span class="n">System</span><span class="o">.</span><span class="na">out</span><span
class="o">.</span><span class="na">println</span><span class="o">(</span>
<span class="s">"Width:"</span> <span class="o">+</span> <span
class="n">mediaBox</span><span class="o">.</span><span class="na">get</span><span
class="o">(</span> <span class="mi">3</span> <span class="o">)</span>
<span class="o">);</span>
+</code></pre>
+</div>
 
 <p>As can be seen from that little example the COS model provides a low level API to
access 
 information within the PDF. In order to use the COS model successfully a good knowledge of
@@ -278,11 +278,11 @@ available to access the attributes.</p>
 
 <p>The same code from above to get the page width can be rewritten to use PD Model
classes.</p>
 
-<p><code class="highlighter-rouge">java
-PDPage page = ...;
-PDRectangle mediaBox = page.getMediaBox();
-System.out.println( "Width:" + mediaBox.getWidth() );
-</code></p>
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="n">PDPage</span>
<span class="n">page</span> <span class="o">=</span> <span class="o">...;</span>
+<span class="n">PDRectangle</span> <span class="n">mediaBox</span>
<span class="o">=</span> <span class="n">page</span><span class="o">.</span><span
class="na">getMediaBox</span><span class="o">();</span>
+<span class="n">System</span><span class="o">.</span><span class="na">out</span><span
class="o">.</span><span class="na">println</span><span class="o">(</span>
<span class="s">"Width:"</span> <span class="o">+</span> <span
class="n">mediaBox</span><span class="o">.</span><span class="na">getWidth</span><span
class="o">()</span> <span class="o">);</span>
+</code></pre>
+</div>
 
 <p>PD Model objects sit on top of COS model. Typically, the classes in the PD Model
will only
 store a COS object and all setter/getter methods will modify data that is stored in the

http://git-wip-us.apache.org/repos/asf/pdfbox-docs/blob/cd8511a3/content/1.8/faq.html
----------------------------------------------------------------------
diff --git a/content/1.8/faq.html b/content/1.8/faq.html
index 7231308..aafc4bd 100644
--- a/content/1.8/faq.html
+++ b/content/1.8/faq.html
@@ -155,25 +155,25 @@
 <p><a name="log4j"></a>
 ### I am getting the below Log4J warning message, how do I remove it? ###</p>
 
-<p><code class="highlighter-rouge">java
-log4j:WARN No appenders could be found for logger (org.apache.pdfbox.util.ResourceLoader).
-log4j:WARN Please initialize the log4j system properly.
-</code></p>
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nl">log4j:</span><span
class="n">WARN</span> <span class="n">No</span> <span class="n">appenders</span>
<span class="n">could</span> <span class="n">be</span> <span class="n">found</span>
<span class="k">for</span> <span class="n">logger</span> <span
class="o">(</span><span class="n">org</span><span class="o">.</span><span
class="na">apache</span><span class="o">.</span><span class="na">pdfbox</span><span
class="o">.</span><span class="na">util</span><span class="o">.</span><span
class="na">ResourceLoader</span><span class="o">).</span>
+<span class="nl">log4j:</span><span class="n">WARN</span> <span
class="n">Please</span> <span class="n">initialize</span> <span class="n">the</span>
<span class="n">log4j</span> <span class="n">system</span> <span
class="n">properly</span><span class="o">.</span>
+</code></pre>
+</div>
 
 <p>This message means that you need to configure the log4j logging system.
 See the <a href="http://logging.apache.org/log4j/1.2/manual.html">log4j documentation</a>
for more information.</p>
 
 <p>PDFBox comes with a sample log4j configuration file.  To use it you set a system
property like this</p>
 
-<p><code class="highlighter-rouge">java
-java -Dlog4j.configuration=log4j.xml org.apache.pdfbox.ExtractText &lt;PDF-file&gt;
&lt;output-text-file&gt;
-</code></p>
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="n">java</span>
<span class="o">-</span><span class="n">Dlog4j</span><span class="o">.</span><span
class="na">configuration</span><span class="o">=</span><span class="n">log4j</span><span
class="o">.</span><span class="na">xml</span> <span class="n">org</span><span
class="o">.</span><span class="na">apache</span><span class="o">.</span><span
class="na">pdfbox</span><span class="o">.</span><span class="na">ExtractText</span>
<span class="o">&lt;</span><span class="n">PDF</span><span
class="o">-</span><span class="n">file</span><span class="o">&gt;</span>
<span class="o">&lt;</span><span class="n">output</span><span
class="o">-</span><span class="n">text</span><span class="o">-</span><span
class="n">file</span><span class="o">&gt;</span>
+</code></pre>
+</div>
 
 <p>If this is not working for you then you may have to specify the log4j config file
using a URL path, like this:</p>
 
-<p><code class="highlighter-rouge">java
-log4j.configuration=file:///&lt;path to config file&gt;
-</code></p>
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="n">log4j</span><span
class="o">.</span><span class="na">configuration</span><span class="o">=</span><span
class="nl">file:</span><span class="c1">///&lt;path to config file&gt;</span>
+</code></pre>
+</div>
 
 <p><a name="threadsafe"></a>
 ### Is PDFBox thread safe? ###</p>
@@ -189,20 +189,20 @@ don’t then the document will not be closed properly.  Also, you must
close all
 PDDocument objects that get created.  The following code creates <strong>two</strong>
 PDDocument objects; one from the “new PDDocument()” and the second by the load method.</p>
 
-<p><code class="highlighter-rouge">java
-PDDocument doc = new PDDocument();
-try
-{
-   doc = PDDocument.load( "my.pdf" );
-}
-finally
-{
-   if( doc != null )
-   {
-      doc.close();
-   }
-}
-</code></p>
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="n">PDDocument</span>
<span class="n">doc</span> <span class="o">=</span> <span class="k">new</span>
<span class="n">PDDocument</span><span class="o">();</span>
+<span class="k">try</span>
+<span class="o">{</span>
+   <span class="n">doc</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="s">"my.pdf"</span> <span class="o">);</span>
+<span class="o">}</span>
+<span class="k">finally</span>
+<span class="o">{</span>
+   <span class="k">if</span><span class="o">(</span> <span class="n">doc</span>
<span class="o">!=</span> <span class="kc">null</span> <span class="o">)</span>
+   <span class="o">{</span>
+      <span class="n">doc</span><span class="o">.</span><span
class="na">close</span><span class="o">();</span>
+   <span class="o">}</span>
+<span class="o">}</span>
+</code></pre>
+</div>
 
 <h2 id="text-extraction-1">Text Extraction</h2>
 

http://git-wip-us.apache.org/repos/asf/pdfbox-docs/blob/cd8511a3/content/2.0/cookbook/encryption.html
----------------------------------------------------------------------
diff --git a/content/2.0/cookbook/encryption.html b/content/2.0/cookbook/encryption.html
index 0cbd1d6..d8978f2 100644
--- a/content/2.0/cookbook/encryption.html
+++ b/content/2.0/cookbook/encryption.html
@@ -138,28 +138,28 @@
 
 <p>This small sample shows how to encrypt a file so that it can be viewed, but not
printed..</p>
 
-<p>``` java
-PDDocument doc = PDDocument.load(“filename.pdf”);</p>
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="n">PDDocument</span>
<span class="n">doc</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="s">"filename.pdf"</span><span class="o">);</span>
 
-<p>// Define the length of the encryption key.
-// Possible values are 40, 128 or 256.
-int keyLength = 256;</p>
-
-<p>AccessPermission ap = new AccessPermission();</p>
-
-<p>// disable printing, everything else is allowed
-ap.setCanPrint(false);</p>
-
-<p>// owner password (to open the file with all permissions) is “12345”
-// user password (to open the file but with restricted permissions, is empty here) 
-StandardProtectionPolicy spp = new StandardProtectionPolicy(“12345”, “”, ap);
-spp.setEncryptionKeyLength(keyLength);
-spp.setPermissions(ap);
-doc.protect(spp);</p>
-
-<p>doc.save(“filename-encrypted.pdf”);
-doc.close();
-```</p>
+<span class="c1">// Define the length of the encryption key.</span>
+<span class="c1">// Possible values are 40, 128 or 256.</span>
+<span class="kt">int</span> <span class="n">keyLength</span> <span
class="o">=</span> <span class="mi">256</span><span class="o">;</span>
+    
+<span class="n">AccessPermission</span> <span class="n">ap</span>
<span class="o">=</span> <span class="k">new</span> <span class="n">AccessPermission</span><span
class="o">();</span>
+        
+<span class="c1">// disable printing, everything else is allowed</span>
+<span class="n">ap</span><span class="o">.</span><span class="na">setCanPrint</span><span
class="o">(</span><span class="kc">false</span><span class="o">);</span>
+        
+<span class="c1">// owner password (to open the file with all permissions) is "12345"</span>
+<span class="c1">// user password (to open the file but with restricted permissions,
is empty here) </span>
+<span class="n">StandardProtectionPolicy</span> <span class="n">spp</span>
<span class="o">=</span> <span class="k">new</span> <span class="n">StandardProtectionPolicy</span><span
class="o">(</span><span class="s">"12345"</span><span class="o">,</span>
<span class="s">""</span><span class="o">,</span> <span class="n">ap</span><span
class="o">);</span>
+<span class="n">spp</span><span class="o">.</span><span class="na">setEncryptionKeyLength</span><span
class="o">(</span><span class="n">keyLength</span><span class="o">);</span>
+<span class="n">spp</span><span class="o">.</span><span class="na">setPermissions</span><span
class="o">(</span><span class="n">ap</span><span class="o">);</span>
+<span class="n">doc</span><span class="o">.</span><span class="na">protect</span><span
class="o">(</span><span class="n">spp</span><span class="o">);</span>
+        
+<span class="n">doc</span><span class="o">.</span><span class="na">save</span><span
class="o">(</span><span class="s">"filename-encrypted.pdf"</span><span
class="o">);</span>
+<span class="n">doc</span><span class="o">.</span><span class="na">close</span><span
class="o">();</span>
+</code></pre>
+</div>
 
             </div>
         </div>


Mime
View raw message