From d1d1b23f2f93aaa4eb2fc2522bb2a98aadd0a655 Mon Sep 17 00:00:00 2001
From: Ariel Sosnovsky The library is constructed from 4 base modules: WIP Contains high-level classes for conversion of the fundamental pdf structures to other formats. This library includes 4 high-level conversion classes: These classes all extend the PDFConverter. To use them simply call the static method parse_file. a interpreter of the pdf-standard commands This generator-function yields individual pages which contain their respected items. This function returns a generator that yields PDFInterpreter. This generator-function-class yields individual layout items. All layout items extend the All of these classes extend the LTContainer class. All of these classes extend the LTComponent class. Contains high-level functions for conversion of the fundamental pdf structures to other formats. This library includes 4 high-level conversion cases: These formats are all generated using the PageInterpreter. To use them simply call the static method parse_file. A high-level abstraction for the conversion classes. Extends initialization function for the class returns the output file TextIOWrapper. WIP WIP PDF-Major is a fork of PDF-Major is a fork of See documentation here. 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 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
+
@@ -111,37 +111,82 @@
API
-
+parser
+interpreter
-
-WIP
-converters
-
-
-Example
-from pdfmajor.converters import HTMLConverter
+
-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("/path/to/pdf.pdf"):
+ print("page start", page.page_num)
+ for item in page:
+ print(" >", item)
+ print("page end", page.page_num)
converters.convert_file(input_file, output_file, image_folder_path, codec, maxpages, password, caching, check_extractable, pagenos, out_type)
+interpreter.PDFInterpreter
+Arguments
+
+
+input_file_path: strpreload: bool defaults to Falsemaxpages: int defaults to 0 password: str defaults to None caching: bool defaults to True check_extractable: bool defaults to Truepagenos: List[int] defaults to Nonedebug_level: logging.levels defaults logging.WARNINGYield Value
+interpreter.PageInterpreter
+Layout Items
+LTItem class. There are two kinds of layout items:
+
+LTItem class, this class will have additional values such as boundary boxes, height and widthLTComponent 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.Layout Containers
+
+
+TJ or Tj operators is issued within a text object.BT and ET operators pair in the pdf standardLayout Components
+
+
+self.paths)converters
+
+
+Example
+
+
+from pdfmajor.converters import convert_file
+
+convert_file(
+ "path/to/input/file.pdf",
+ "path/to/output/file.html",
+ out_type="html"
+)
+converters.convert_file
-input_file: TextIOWrapper pagenos: List[int] defaults to Noneout_type: str defaults to 'html'Example (converters.convert_file)
-
-
-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()
-converters.PDFConverter
-layouts.PDFLayoutAnalyzer.converters.PDFConverter.__init__(rsrcmgr, outfp, imagewriter, codec, pageno)
-
-
-rsrcmgr: PDFResourceManageroutfp: TextIOWrapperimagewriter: ImageWritercodec: str defaults to 'utf-8'pageno: int defaults to 1converters.PDFConverter.parse_file(input_file, output_file, image_folder_path, codec, maxpages, password, caching, check_extractable, pagenos)
-
-
input_file: TextIOWrapper output_file: TextIOWrapper image_folder_path: str defaults to Nonecodec: str defaults to 'utf-8'maxpages: int defaults to 0 password: str defaults to None caching: bool defaults to True check_extractable: bool defaults to Truepagenos: List[int] defaults to Noneimagewriter
-layouts
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.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
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. This versions intends to make use of the latest improvement in the python language while remaining fairly simple to develop with. 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
-
-pdfmajor.layouts.PDFLayoutAnalyzer class, but at the current time is not supported.pdfmajor.interpreter.PageInterpreter class, but at the current time is not supported.How to Install
Source
@@ -227,5 +240,5 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.