updated docs

This commit is contained in:
ari committed 2018-12-24 01:52:52 -05:00
1 parent abfbe98897
commit d1d1b23f2f
6 files changed
+96 -76

No files matched your search

+71 -65
View File
@@ -62,14 +62,14 @@
<ul>
<li><a class="toctree-l3" href="#parser">parser</a></li>
<li><a class="toctree-l3" href="#interpreter">interpreter</a></li>
<li><a class="toctree-l3" href="#converters">converters</a></li>
<li><a class="toctree-l3" href="#imagewriter">imagewriter</a></li>
<li><a class="toctree-l3" href="#layouts">layouts</a></li>
</ul>
@@ -111,37 +111,82 @@
<h1 id="api">API</h1>
<p>The library is constructed from 4 base modules:</p>
<ul>
<li><strong>interpreter</strong>: contains low-level classes for extracting fundamental data-structures from the documents</li>
<li><strong>converters</strong>: contains high-level classes for conversion of the fundamental pdf structures to other formats</li>
<li><strong>parser</strong>: contains low-level classes for extracting fundamental data-structures from the documents</li>
<li><strong>interpreter</strong>: a interpreter of the pdf-standard commands</li>
<li><strong>converters</strong>: contains high-level functions for conversion of the fundamental pdf structures to other formats</li>
<li><strong>imagewriter</strong>: contains a simple implementation for converting PDF Image Streams to png/bmp/img formats</li>
<li><strong>layouts</strong>: contains an abstraction layer for the data-structures found in the pdf</li>
</ul>
<h2 id="parser">parser</h2>
<p>WIP</p>
<h2 id="interpreter">interpreter</h2>
<pre><code>WIP
</code></pre>
<h2 id="converters">converters</h2>
<p>Contains high-level classes for conversion of the fundamental pdf structures to other formats. This library includes 4 high-level conversion classes:</p>
<ul>
<li>HTMLConverter</li>
<li>JSONConverter</li>
<li>XMLConverter</li>
<li>TextConverter</li>
</ul>
<p>These classes all extend the <a href="#converters.PDFConverter">PDFConverter</a>. To use them simply call the static method <a href="#converterspdfconverterparse_fileinput_file-output_file-image_folder_path-codec-maxpages-password-caching-check_extractable-pagenos">parse_file</a>.</p>
<p>a interpreter of the pdf-standard commands</p>
<h3 id="example">Example</h3>
<pre><code class="py">from pdfmajor.converters import HTMLConverter
<pre><code class="py">from pdfmajor.interpreter import PageInterpreter
input_file = open('path/to/input/file.pdf', 'rb')
output_file = open('path/to/output/file.html', 'wb')
HTMLConverter.parse_file(
input_file,
output_file
)
input_file.close()
output_file.close()
for page in PDFInterpreter(&quot;/path/to/pdf.pdf&quot;):
print(&quot;page start&quot;, page.page_num)
for item in page:
print(&quot; &gt;&quot;, item)
print(&quot;page end&quot;, page.page_num)
</code></pre>
<h3 id="convertersconvert_fileinput_file-output_file-image_folder_path-codec-maxpages-password-caching-check_extractable-pagenos-out_type">converters.convert_file(input_file, output_file, image_folder_path, codec, maxpages, password, caching, check_extractable, pagenos, out_type)</h3>
<h3 id="interpreterpdfinterpreter">interpreter.PDFInterpreter</h3>
<p>This generator-function yields individual pages which contain their respected items.</p>
<h4 id="arguments">Arguments</h4>
<ul>
<li><code>input_file_path</code>: <a href="#">str</a></li>
<li><code>preload</code>: <a href="#">bool</a> defaults to False</li>
<li><code>maxpages</code>: <a href="#">int</a> defaults to 0 </li>
<li><code>password</code>: <a href="#">str</a> defaults to None </li>
<li><code>caching</code>: <a href="#">bool</a> defaults to True </li>
<li><code>check_extractable</code>: <a href="#">bool</a> defaults to True</li>
<li><code>pagenos</code>: <a href="#">List[int]</a> defaults to None</li>
<li><code>debug_level</code>: <a href="#https://docs.python.org/3/library/logging.html#levels">logging.levels</a> defaults logging.WARNING</li>
</ul>
<h4 id="yield-value">Yield Value</h4>
<p>This function returns a generator that yields <a href="#interpreterpageinterpreter">PDFInterpreter</a>.</p>
<h3 id="interpreterpageinterpreter">interpreter.PageInterpreter</h3>
<p>This generator-function-class yields individual <a href="#layout-items">layout items</a>.</p>
<h3 id="layout-items">Layout Items</h3>
<p>All layout items extend the <code>LTItem</code> class. There are two kinds of layout items:</p>
<ul>
<li>LTComponent: extends the base <code>LTItem</code> class, this class will have additional values such as boundary boxes, height and width</li>
<li>LTContainer: extends the <code>LTComponent</code> class, this class is used to contain elements of the pdf that would have child elements. Iterating on this element will output its child elements.</li>
</ul>
<h4 id="layout-containers">Layout Containers</h4>
<p>All of these classes extend the LTContainer class.</p>
<ul>
<li>LTXObject: a layout item containing other additional layout items</li>
<li>LTCharBlock: a layout item containing LTChars, this corresponds to whenever a <code>TJ</code> or <code>Tj</code> operators is issued within a text object.</li>
<li>LTTextBlock: a layout item containing LTCharBlocks, note that this directly corresponds to the <code>BT</code> and <code>ET</code> operators pair in the pdf standard</li>
</ul>
<h4 id="layout-components">Layout Components</h4>
<p>All of these classes extend the LTComponent class.</p>
<ul>
<li>LTChar: an individual character</li>
<li>LTCurves: represents a collection of svg-paths (available under <code>self.paths</code>)</li>
<li>LTImage: a component containing information regarding an image</li>
</ul>
<h2 id="converters">converters</h2>
<p>Contains high-level functions for conversion of the fundamental pdf structures to other formats. This library includes 4 high-level conversion cases:</p>
<ul>
<li>HTML</li>
<li>JSON</li>
<li>XML</li>
<li>Text</li>
</ul>
<p>These formats are all generated using the <a href="#PDFInterpreter">PageInterpreter</a>. To use them simply call the static method <a href="#converterspdfconverter">parse_file</a>.</p>
<h3 id="example_1">Example</h3>
<pre><code class="py">from pdfmajor.converters import convert_file
convert_file(
&quot;path/to/input/file.pdf&quot;,
&quot;path/to/output/file.html&quot;,
out_type=&quot;html&quot;
)
</code></pre>
<h3 id="convertersconvert_file">converters.convert_file</h3>
<p>A high-level abstraction for the conversion classes.</p>
<ul>
<li><code>input_file</code>: <a href="https://docs.python.org/3/library/io.html#io.TextIOWrapper">TextIOWrapper</a> </li>
@@ -155,46 +200,7 @@ output_file.close()
<li><code>pagenos</code>: <a href="#">List[int]</a> defaults to None</li>
<li><code>out_type</code>: <a href="#">str</a> defaults to 'html'</li>
</ul>
<h3 id="example-convertersconvert_file">Example (converters.convert_file)</h3>
<pre><code class="py">from pdfmajor.converters import convert_file
input_file = open('path/to/input/file.pdf', 'rb')
output_file = open('path/to/output/file.html', 'wb')
convert_file(
input_file,
output_file
)
input_file.close()
output_file.close()
</code></pre>
<h3 id="converterspdfconverter">converters.PDFConverter</h3>
<p>Extends <code>layouts.PDFLayoutAnalyzer</code>.</p>
<h4 id="converterspdfconverter9595init9595rsrcmgr-outfp-imagewriter-codec-pageno">converters.PDFConverter.__init__(rsrcmgr, outfp, imagewriter, codec, pageno)</h4>
<ul>
<li><code>rsrcmgr</code>: <a href="#interpreter.PDFResourceManager">PDFResourceManager</a></li>
<li><code>outfp</code>: <a href="https://docs.python.org/3/library/io.html#io.TextIOWrapper">TextIOWrapper</a></li>
<li><code>imagewriter</code>: <a href="#imagewriter.ImageWriter">ImageWriter</a></li>
<li><code>codec</code>: <a href="#">str</a> defaults to 'utf-8'</li>
<li><code>pageno</code>: <a href="#">int</a> defaults to 1</li>
</ul>
<p>initialization function for the class</p>
<h4 id="converterspdfconverterparse_fileinput_file-output_file-image_folder_path-codec-maxpages-password-caching-check_extractable-pagenos">converters.PDFConverter.parse_file(input_file, output_file, image_folder_path, codec, maxpages, password, caching, check_extractable, pagenos)</h4>
<p>returns the output file <a href="https://docs.python.org/3/library/io.html#io.TextIOWrapper">TextIOWrapper</a>.</p>
<ul>
<li><code>input_file</code>: <a href="https://docs.python.org/3/library/io.html#io.TextIOWrapper">TextIOWrapper</a> </li>
<li><code>output_file</code>: <a href="https://docs.python.org/3/library/io.html#io.TextIOWrapper">TextIOWrapper</a> </li>
<li><code>image_folder_path</code>: <a href="#">str</a> defaults to None</li>
<li><code>codec</code>: <a href="#">str</a> defaults to 'utf-8'</li>
<li><code>maxpages</code>: <a href="#">int</a> defaults to 0 </li>
<li><code>password</code>: <a href="#">str</a> defaults to None </li>
<li><code>caching</code>: <a href="#">bool</a> defaults to True </li>
<li><code>check_extractable</code>: <a href="#">bool</a> defaults to True</li>
<li><code>pagenos</code>: <a href="#">List[int]</a> defaults to None</li>
</ul>
<h2 id="imagewriter">imagewriter</h2>
<p>WIP </p>
<h2 id="layouts">layouts</h2>
<p>WIP </p>
</div>
+20 -7
View File
@@ -59,6 +59,8 @@
<li><a class="toctree-l3" href="#documentation">Documentation</a></li>
<li><a class="toctree-l3" href="#basic-example">Basic Example</a></li>
<li><a class="toctree-l3" href="#why-another-fork">Why Another Fork?</a></li>
<li><a class="toctree-l3" href="#features">Features</a></li>
@@ -122,23 +124,34 @@
</tr>
</table>
<p>PDF-Major is a fork of <code>PDFMiner.six</code>. It is meant to be a more light-weight implementation that makes fewer assumptions on the data. Additionally, this version intends to be more up to date with recent versions of python and make liberal use of the typing capabilities of python for improved future maintainability.</p>
<p>PDF-Major is a fork of <code>PDFMiner.six</code>. It is meant to be a more light-weight implementation that makes fewer assumptions on the data. The ultimate goal of this project is to provide a simpler, faster and more functional library that both casual and low-level developers could build upon.</p>
<h2 id="documentation">Documentation</h2>
<p>See documentation <a href="https://asosnovsky.github.io/pdfmajor/">here</a>.</p>
<h2 id="basic-example">Basic Example</h2>
<pre><code class="py">from pdfmajor.interpreter import PageInterpreter
for page in PDFInterpreter(&quot;/path/to/pdf.pdf&quot;):
print(&quot;page start&quot;, page.page_num)
for item in page:
print(&quot; &gt;&quot;, item)
print(&quot;page end&quot;, page.page_num)
</code></pre>
<h2 id="why-another-fork">Why Another Fork?</h2>
<p><code>PDFMiner</code> was designed to run in python 2.7&gt;, <code>PDFMiner.six</code> was written to bring cross-version support for python 2 and 3. This versions intends to make use of the latest improvement in the python language while remaining fairly simple to develop with. </p>
<p><code>PDFMiner</code> was designed to run in python 2.7&gt;, <code>PDFMiner.six</code> was written to bring cross-version support for python 2 and 3. However, after attempting to build and extend upon <code>PDFMiner.six</code> I found it rather difficult to extend and identify additional details regarding the items encoded in the pdf. This library will attempt to expose as much information as possible to end-users, without having them solely rely on to-xml or to-json exports.</p>
<h2 id="features">Features</h2>
<ul>
<li>Written entirely in Python.</li>
<li>Functional extraction method based on generators</li>
<li>Parse, analyze, and convert PDF documents.</li>
<li>PDF-1.7 specification support. (well, almost)</li>
<li>Font-Color extraction</li>
<li>Shape fill and stroke color extraction</li>
<li>CJK languages and vertical writing scripts support.</li>
<li>Various font types (Type1, TrueType, Type3, and CID) support.</li>
<li>Basic encryption (RC4) support.</li>
<li>Font-Color extraction</li>
<li>Shape fill and stroke color extraction</li>
</ul>
<p><strong>Note</strong>: We took out the layout-analysis process in this version (there is no more LTTextHorizontal or LTTextVertical). While the mathematics behind the grouping process was sound, the coupling of the layout-analysis process with the parsing and interpretation process produced unfriendly-code. This feature could be brought back by extending the <code>pdfmajor.layouts.PDFLayoutAnalyzer</code> class, but at the current time is not supported.</p>
<p><strong>Note</strong>: We took out the layout-analysis process in this version (there is no more LTTextHorizontal or LTTextVertical). While the mathematics behind the grouping process was sound, the coupling of the layout-analysis process with the parsing and interpretation process produced unfriendly-code. This feature could be brought back by running your own implementation of it on the <code>pdfmajor.interpreter.PageInterpreter</code> class, but at the current time is not supported.</p>
<h2 id="how-to-install">How to Install</h2>
<h3 id="source">Source</h3>
<ul>
@@ -227,5 +240,5 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
<!--
MkDocs version : 1.0.4
Build Date UTC : 2018-11-04 21:27:38
Build Date UTC : 2018-12-24 06:52:28
-->
+1 -1
View File
@@ -1 +1 @@
{"config":{"lang":["en"],"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"PDFMajor Latest Release PDF-Major is a fork of PDFMiner.six . It is meant to be a more light-weight implementation that makes fewer assumptions on the data. Additionally, this version intends to be more up to date with recent versions of python and make liberal use of the typing capabilities of python for improved future maintainability. Documentation See documentation here . Why Another Fork? PDFMiner was designed to run in python 2.7>, PDFMiner.six was written to bring cross-version support for python 2 and 3. This versions intends to make use of the latest improvement in the python language while remaining fairly simple to develop with. Features Written entirely in Python. Parse, analyze, and convert PDF documents. PDF-1.7 specification support. (well, almost) CJK languages and vertical writing scripts support. Various font types (Type1, TrueType, Type3, and CID) support. Basic encryption (RC4) support. Font-Color extraction Shape fill and stroke color extraction Note : We took out the layout-analysis process in this version (there is no more LTTextHorizontal or LTTextVertical). While the mathematics behind the grouping process was sound, the coupling of the layout-analysis process with the parsing and interpretation process produced unfriendly-code. This feature could be brought back by extending the pdfmajor.layouts.PDFLayoutAnalyzer class, but at the current time is not supported. How to Install Source Install Python 3.6.4 or newer. clone this repo git clone https://github.com/asosnovsky/pdfmajor * install repo python setup.py install Pypi Install Python 3.6.4 or newer. install repo pip install pdfmajor Terms and Conditions (This is so-called MIT/X License) Copyright (c) 2018-2019 Ariel Sosnovsky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","title":"Home"},{"location":"#pdfmajor","text":"Latest Release PDF-Major is a fork of PDFMiner.six . It is meant to be a more light-weight implementation that makes fewer assumptions on the data. Additionally, this version intends to be more up to date with recent versions of python and make liberal use of the typing capabilities of python for improved future maintainability.","title":"PDFMajor"},{"location":"#documentation","text":"See documentation here .","title":"Documentation"},{"location":"#why-another-fork","text":"PDFMiner was designed to run in python 2.7>, PDFMiner.six was written to bring cross-version support for python 2 and 3. This versions intends to make use of the latest improvement in the python language while remaining fairly simple to develop with.","title":"Why Another Fork?"},{"location":"#features","text":"Written entirely in Python. Parse, analyze, and convert PDF documents. PDF-1.7 specification support. (well, almost) CJK languages and vertical writing scripts support. Various font types (Type1, TrueType, Type3, and CID) support. Basic encryption (RC4) support. Font-Color extraction Shape fill and stroke color extraction Note : We took out the layout-analysis process in this version (there is no more LTTextHorizontal or LTTextVertical). While the mathematics behind the grouping process was sound, the coupling of the layout-analysis process with the parsing and interpretation process produced unfriendly-code. This feature could be brought back by extending the pdfmajor.layouts.PDFLayoutAnalyzer class, but at the current time is not supported.","title":"Features"},{"location":"#how-to-install","text":"","title":"How to Install"},{"location":"#source","text":"Install Python 3.6.4 or newer. clone this repo git clone https://github.com/asosnovsky/pdfmajor * install repo python setup.py install","title":"Source"},{"location":"#pypi","text":"Install Python 3.6.4 or newer. install repo pip install pdfmajor","title":"Pypi"},{"location":"#terms-and-conditions","text":"(This is so-called MIT/X License) Copyright (c) 2018-2019 Ariel Sosnovsky Permission is hereby granted, free of chargeLine truncated
{"config":{"lang":["en"],"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"PDFMajor Latest Release PDF-Major is a fork of PDFMiner.six . It is meant to be a more light-weight implementation that makes fewer assumptions on the data. The ultimate goal of this project is to provide a simpler, faster and more functional library that both casual and low-level developers could build upon. Documentation See documentation here . Basic Example from pdfmajor.interpreter import PageInterpreter for page in PDFInterpreter(\"/path/to/pdf.pdf\"): print(\"page start\", page.page_num) for item in page: print(\" >\", item) print(\"page end\", page.page_num) Why Another Fork? PDFMiner was designed to run in python 2.7>, PDFMiner.six was written to bring cross-version support for python 2 and 3. However, after attempting to build and extend upon PDFMiner.six I found it rather difficult to extend and identify additional details regarding the items encoded in the pdf. This library will attempt to expose as much information as possible to end-users, without having them solely rely on to-xml or to-json exports. Features Functional extraction method based on generators Parse, analyze, and convert PDF documents. PDF-1.7 specification support. (well, almost) Font-Color extraction Shape fill and stroke color extraction CJK languages and vertical writing scripts support. Various font types (Type1, TrueType, Type3, and CID) support. Basic encryption (RC4) support. Note : We took out the layout-analysis process in this version (there is no more LTTextHorizontal or LTTextVertical). While the mathematics behind the grouping process was sound, the coupling of the layout-analysis process with the parsing and interpretation process produced unfriendly-code. This feature could be brought back by running your own implementation of it on the pdfmajor.interpreter.PageInterpreter class, but at the current time is not supported. How to Install Source Install Python 3.6.4 or newer. clone this repo git clone https://github.com/asosnovsky/pdfmajor * install repo python setup.py install Pypi Install Python 3.6.4 or newer. install repo pip install pdfmajor Terms and Conditions (This is so-called MIT/X License) Copyright (c) 2018-2019 Ariel Sosnovsky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","title":"Home"},{"location":"#pdfmajor","text":"Latest Release PDF-Major is a fork of PDFMiner.six . It is meant to be a more light-weight implementation that makes fewer assumptions on the data. The ultimate goal of this project is to provide a simpler, faster and more functional library that both casual and low-level developers could build upon.","title":"PDFMajor"},{"location":"#documentation","text":"See documentation here .","title":"Documentation"},{"location":"#basic-example","text":"from pdfmajor.interpreter import PageInterpreter for page in PDFInterpreter(\"/path/to/pdf.pdf\"): print(\"page start\", page.page_num) for item in page: print(\" >\", item) print(\"page end\", page.page_num)","title":"Basic Example"},{"location":"#why-another-fork","text":"PDFMiner was designed to run in python 2.7>, PDFMiner.six was written to bring cross-version support for python 2 and 3. However, after attempting to build and extend upon PDFMiner.six I found it rather difficult to extend and identify additional details regarding the items encoded in the pdf. This library will attempt to expose as much information as possible to end-users, without having them solely rely on to-xml or to-json exports.","title":"Why Another Fork?"},{"location":"#features","text":"Functional extraction method based on generators Parse, analyze, and convert PDF documents. PDF-1.7 specification support. (well, almost) Font-Color extraction Shape fill and stroke color extraction CJK languages and vertical writing scripts support. Various font types (Type1, TrueType, Type3, and CID) support. Basic encryption (RC4) support. Note : We took out the layout-analysis process in this version (there is no more LTTLine truncated
+2 -2
View File
@@ -2,12 +2,12 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>None</loc>
<lastmod>2018-11-04</lastmod>
<lastmod>2018-12-24</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>None</loc>
<lastmod>2018-11-04</lastmod>
<lastmod>2018-12-24</lastmod>
<changefreq>daily</changefreq>
</url>
</urlset>
Binary file not shown.