No Plugins; Monolithic

    pdf-red

    0.0.4 • Public • Published

    Pdf-red

    This node will help you to handle (scanned image) pdfs and images. Important Note: Works only in a windows environment.

    • You can get a searchable (OCR) pdf from images and (image) pdfs.
    • You can create .png images from each page of a pdf.
    • You can get the text from images or (image) pdfs.
    • If you have installed tesseract, you can use the command line to directly input an order.

    The OCR will be either made by tesseract.js or if installed by tesseract -> (tested with pre-build installer for windows tesseract 5.0.0 alpha).

    Usage

    1. Configurate the node

    Set the option you wish to do:

    Create readable pdf / Get text

    To improve the ocr reading set a language by using the ISO_639-2/T code. Default is english ('eng').

    Create images from pdf page

    Set the image quality (75 or 150 dpi should be more than enough for good results). Higher values will result in slower ocr / bigger file size.

    If you want to save the files to a directory you can state it under "Save image output to folder".

    Alternatively you can heck 'Return Images' if you want to extract the whole page images from the pdf. The result will be written in msg.pdfImages as an object with the keys 'page' (pagenumber) and 'data' (buffer of the images). You can save them with the standard file node (default or utf-8). The suffix must be '.png'.

    Use tesseract / tesseract command line

    For this option tesseract must be installed!

    If you want to use tesseract instead of tesseract.js you have to state the command call (should be tesseract).

    You can set msg.tessCommand or type it directly in the node. It will be joined with the field 'tesseract command call', so don't start the command line with 'tesseract'.

    2. Get a file

    Load a pdf or valid image file with the 'file in' or the 'http' node. The result of those nodes must be a buffer object. This is not necessary if you use the tesseract command line.

    3. Save the file

    Use the 'file' node to save the pdf and/or the images on your filesystem.

    TLDR

    You can find a sample flow in the node red imports.

    example

    Additional info for tesseract.js

    This node can be used without tesseract installed. This will result in using tesseract.js which is currently much slower to make your images and pdfs readable. You can try to use tessdata fast but it will reduce the quality of the ocr.

    As we can't create multiple workers to recognize multiple pages (can results in memory leak) we only use one tesseract worker. If scheduler with multiple workers can handle the getPdf function someday (or a workaround is found) it could reduce the time significant!

    Therefore if possible install tesseract.

    Tesseract

    For windows you can use a simple installer. Just check if afterwards your environment variable is correctly set and do reboot.

    Control Panel > System and Security > System > Advanced system settings > Advanced > Environment variables > PATH > New

    example

    Install

    npm i pdf-red

    DownloadsWeekly Downloads

    11

    Version

    0.0.4

    License

    MIT

    Unpacked Size

    295 kB

    Total Files

    17

    Last publish

    Collaborators

    • 2weltenchris
    • meijey