I would like to draw out text from a portion (utilizing coordinates) of PDF utilizing Ghostscript. Can anybody helpme out?
You will have a lot of trouble doing that with collaborates. That would require finding every text cell in the document, calculating string width and wrapping, then calculation clipping windows and selecting inclusion/exclusion. Then would come the task of buying it aesthetically.
With Ghostscript, you can extract text from PDFs. Exactly what you can do: extract the text of a particular range of pages only.
You ‘d need to convert your PDF to PostScript, then run this command on the PS file
If the -dSIMPLE parameter is not defined, each output line contains some extra information beyond the pure text material about fonts and fontsize used.
If you replace that criterion by -dCOMPLEX, you’ll get additional details about colors and images utilized.
Read the comments inside the ps2ascii.ps to get more information about this utility.
A more comfy way to do text extraction: utilize pdftotext (readily available for Windows in addition to Linux/Unix or Mac OS X). This energy is based either on Poppler or on XPDF.
This will display the page variety 13 (first page) to 17 (last page), preserve the design of a double-password safeguarded named PDF file (utilizing user and owner passwords supersecret and secret), with Unix EOL convention, but without inserting pagebreaks in between PDF pages, piped through less …
pdftotext -h displays all offered commandline alternatives.
Of course, both tools only work for the text parts of PDFs (if they have any).
The cross-platform, open source MuPDF application (made by the exact same company that also develops Ghostscript) has bundled a command line tool, mutool. To draw out text from a PDF with this tool
TET, the Text Extraction Toolkit from the pdflib household of products can discover the x-y-coordinate of text content in a PDF file (and a lot more). TET has a commandline interface, and it’s the most effective of all text extraction tools I understand.
I’m uncertain GhostScript can accept coordinates, however you can convert the PDF to a image and send it to an OCR engine either as a subimage cropped from the offered coordinates or as the entire image along with the coordinates. Some OCR API accepts a rectangle criterion to narrow the area for OCR.
Take a look at VietOCR for a working example, which utilizes Tesseract as its OCR engine and GhostScript as PDF-to-image converter.
I am questioning if there’s a way to extract text from pdf in C#? I have already surveyed some npm modules like PDF-TO-TEXT but they all take in a file path name as input. I am utilizing the react-drop-to-upload module to enable the user to drop the pdf to a respond part. The respond component takes in the pdf file and returns a File things rather than a file path. Is there a method to convert PDF kept in an File challenge text?