PDF Software

How to read, write and watermark/stamp PDF files in Python language?

How to read and write PDF files in Python language?

VeryUtils PythonPDF Library is a Python library and utility that reads and writes PDF files. PythonPDF Library is tested and works on Python 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.8 and later versions.

image

PythonPDF Library has following highlight features:
* Support operations include subsetting, merging, rotating, modifying metadata, etc.
* The fastest pure Python PDF parser library.
* Has been used for years by a printer in pre-press production.
* Can be used with rst2pdf to faithfully reproduce vector images.
* Can be used either standalone, or in conjunction with reportlab to reuse existing PDFs in new ones.
* PythonPDF Library will faithfully reproduce vector formats without rasterization.

PythonPDF Library can also be used in conjunction with reportlab, in order to re-use portions of existing PDFs in new PDFs created with reportlab.

PythonPDF Library can be purchased from this web page,

https://veryutils.com/pythonpdf-library-source-code

You will get a package after you purchase it, please download it and unzip it to a folder, such as, you may unzip it to "D:\downloads\python-pdfrw" folder, you need also set "PYTHONPATH" to the main folder PythonPDF Library, for example,

set PYTHONPATH=D:\downloads\python-pdfrw

after you set the path to "PYTHONPATH", please run following command line to test watermark function using PythonPDF Library,

python watermark.py testcmd.pdf watermark.pdf

Here is the screenshot of watermarked PDF file,

image

watermark.py contains following Python Source Code,

--------------------------------------------------------
import sys
import os

from pdfrw import PdfReader, PdfWriter, PageMerge

argv = sys.argv[1:]
underneath = '-u' in argv
if underneath:
    del argv[argv.index('-u')]
inpfn, wmarkfn = argv
outfn = 'watermark.' + os.path.basename(inpfn)
wmark = PageMerge().add(PdfReader(wmarkfn).pages[0])[0]
trailer = PdfReader(inpfn)
for page in trailer.pages:
    PageMerge(page).add(wmark, prepend=underneath).render()
PdfWriter(outfn, trailer=trailer).write()
--------------------------------------------------------

Other Example programs:
* 4up.py -- Prints pages four-up
* alter.py -- Simple example of making a very slight modification to a PDF.
* booklet.py -- Converts a PDF into a booklet.
* cat.py -- Concatenates multiple PDFs, adds metadata.
* poster.py -- Changes the size of a PDF to create a poster
* print_two.py  -- this is used when printing two cut-down copies on a single sheet of paper (double-sided)  Requires uncompressed PDF.
* rotate.py -- This will rotate selected ranges of pages within a document.
* subset.py -- This will retrieve a subset of pages from a document.
* watermark.py  -- Adds a watermark to a PDF

VeryUtils

Partner with VeryUtils

VeryUtils is a Digital Products Trading Platform that sells Digital Products, Digital Downloads and Subscriptions Online.

image

Partner with VeryUtils
Everything's better when you work together. Which is why we're always looking for opportunities to work with new partners.

Resellers
We partner with regional resellers to distribute our products in markets across the globe. Find out why becoming a VeryUtils reseller can work for you.

Affiliates
Becoming an affiliate is an easy way to maximize your website's traffic. By joining our affiliates program you can earn up to 50% commission.

Business partnerships
Make your hardware, software, and technical services stand out by incorporating VeryUtils technology.

Cross marketing
Utilize co-marketing across various channels to increase your sales and brand recognition.

Product partnerships
Offer packaged solutions and bundled offers to add value for your clients.

Technology integration
Deliver seamless integration fast and efficiently by integrating your solutions with our products.

Interested in exploring Business Partnership opportunities with VeryUtils? please feel free to contact us,

The links of VeryUtils Partners,

Business Software, PDF Software, Photo Software, Scripts

How to use PHP Folder Watcher to monitor a folder and print JPG files to a certain tray of the printer?

Hi David,

Quick question about PHP Folder Watcher. Running PHP on Windows via Xampp. All I need is a watcher to see new .jpg files and send them to a local printer. But some files I need to send to a certain tray of the printer (i.e. Legal or Letter size). If your script doesn't already do that, do you think it's something I can modify? I know ONLY PHP. Also the printer is NOT the default printer and is shared on a network. Is that an issue?

Thanks so much!
Customer
---------------------------------------------

image
Hello,

Thanks for your message, PHP Folder Watcher is just a "watcher" to some folders, if you need to print JPG files to a certain tray of the printer, you need to use following product,

https://veryutils.com/pdf-print-command-line

You may login and download the trial version for free.

PHP Folder Watcher can be purchased on this web page,

https://veryutils.com/php-folder-watcher

PDFPrint Command Line is a Windows Command Line application which can be used to print PDF and Image files to a certain tray of the printer (i.e. Legal or Letter size), the network printer is not an issue, you can use PDFPrint Command Line to print PDF and Image files to both local and network printers without any problem.

  -listbins                        : list bins/trays of a printer
  -listjobs                        : list print jobs in printer's queue
  -listall                         : list printers, ports, monitors etc.
  -listpapers                      : list supported papers from a printer.
  -chgbin <int>                    : change bin/tray for printer by number
  -papersource <string>            : change bin/tray for printer by name
  -settraytopclfile <string>       : set tray to PCL file directly, only work when '-papersource' used

for example, you may call following command lines from PHP Folder Watcher to print PDF or JPG files to special tray of the printer,

   pdfprint.exe -listbins -printer "docPrint"
   pdfprint.exe -listpapers -printer "docPrint"
   pdfprint.exe -chgbin 15 -printer "docPrint" C:\input.pdf
   pdfprint.exe -papersource "auto" -printer "docPrint" C:\input.pdf
   pdfprint.exe -papersource "Tray 1" -printer "docPrint" C:\input.pdf
   pdfprint.exe -papersource "Manual Feed" -printer "docPrint" C:\input.pdf
   pdfprint.exe -papersource "Media Tray" -printer "docPrint" C:\input.pdf
   pdfprint.exe -papersource "Tray 3" -settraytopclfile C:\test.pcl
   pdfprint.exe -papersource "auto" -printer "docPrint" C:\input.jpg
   pdfprint.exe -papersource "Tray 1" -printer "docPrint" C:\input.png
   pdfprint.exe -papersource "Tray 2" -printer "docPrint" C:\input.tif
   pdfprint.exe -papersource "Tray 3" -printer "docPrint" C:\input.doc
   pdfprint.exe -papersource "Tray 4" -printer "docPrint" C:\input.docx

In the PHP Folder Watcher script, you can modify RunExternalEXE() function to call the PDFPrint.exe application, for example,

function PrintFile($strInFile)
{
    $strCurrentFolder = dirname(__FILE__);
    $strExeFile =  $strCurrentFolder . '/pdfprint/pdfprint.exe';
    $strCmd  = "\"$strExeFile\" -papersource \"Tray 4\" \"$strInFile\"";
    MyEcho(__FILE__, __LINE__, '', $strCmd);
    $strRawOutput = shell_exec($strCmd);
    MyEcho(__FILE__, __LINE__, '', "<pre>$strRawOutput</pre><br>");
    return $strRawOutput;
}

function RunExternalEXE($strInFile, $strInRootFolder, $strOutFolder, $strBackupFolder)
{
    MyEcho(__FILE__, __LINE__, '', "[RunExternalEXE] $strInFile => $strOutFolder");
    PrintFile($strInFile);   
}

If you encounter any problem, please feel free to let us know, we are glad to assist you asap.

VeryUtils

CAD Software, PDF Software

Convert DWG to PDF from Command Line using VeryUtils DWG to PDF Converter Command Line

Do you want to share AutoCAD DWG and DXF files easily in a format that's guaranteed to be accessible? Yes, VeryUtils has a DWG to PDF Converter Command Line software which will help you, you can convert your AutoCAD DWG and DXF files to PDF files easily with this DWG to PDF Converter Command Line software, this software is designed specifically for web-server and services, this app can be also integrated into any interface to make its options more comfortable for users.

VeryUtils DWG to PDF Converter Command Line has following highlight features:
* Convert thousands of files and keep folder structure.
* Batch convert AutoCAD DWG and DXF files to PDF files.
* Combine multiple DWG files into a single PDF in batch.
* Create a .bat file to reuse project settings.
* Send prompts from directly within the command line environment.
* You can call DWG to PDF Converter Command Line from your application using CreateProcess(), system(), exec(), shell() or similar functions.

After installing the VeryUtils DWG and DXF to PDF Converter Command Line software on a web server, the program becomes available for all users online. They don't even need to know how to convert DWG to PDF from Windows command line. It doesn't get any easier then that!

Please by following steps to convert a DWG or DXF file to PDF file using DWG to PDF Converter Command Line software,

1. Please download DWG to PDF Converter Command Line from this web page, you need login your account before you are able to download the software,

https://veryutils.com/dwg-to-pdf-converter-command-line

2. After you download and unzip it to a folder, please run a CMD window, then you can run following command lines in the CMD window to convert a DWG or DXF files to PDF files,

dwg2vec.exe C:\test.dwg C:\out.pdf
dwg2vec.exe -byview C:\test.dwg C:\out.pdf
dwg2vec.exe C:\test.dwg C:\out.emf
dwg2vec.exe C:\test.dwg C:\out.wmf
dwg2vec.exe C:\test.dwg C:\out.ps
dwg2vec.exe -noext C:\test.dwg C:\out.emf
dwg2vec.exe C:\*.dwg C:\*.pdf
dwg2vec.exe -fontdir "C:\fonts" C:\test.dwg C:\out.pdf
dwg2vec.exe -linewidth "1=0.1;2=0.1;3=0.1" C:\test.dwg C:\out.tif
dwg2vec.exe -width 612 -height 792 C:\test.dwg C:\out.tif
dwg2vec.exe -linewidth "1=0.1;2=0.1;3=0.1" C:\test.dwg C:\out.pdf

image

This is the screenshot of input DWG file,

image

This is the screenshot of converted PDF file,

image

dwg2vec.exe application can also convert from DWG and DXF files to WMF, EMF, PS, EPS, SVG, SWF, PCL, PLT, XPS etc. vector formats, for example,

..\dwg2vec.exe test1.dwg _test1.pdf
..\dwg2vec.exe test1.dwg _test1_wmf.wmf
..\dwg2vec.exe test1.dwg _test1_emf.emf
..\dwg2vec.exe test1.dwg _test1.ps
..\dwg2vec.exe test1.dwg _test1.eps
..\dwg2vec.exe test1.dwg _test1.svg
..\dwg2vec.exe test1.dwg _test1.swf
..\dwg2vec.exe test1.dwg _test1.pcl
..\dwg2vec.exe test1.dwg _test1.plt
..\dwg2vec.exe test1.dwg _test1.xps
..\dwg2vec.exe -colormode 1 test1.dwg _test1_bw.svg
..\dwg2vec.exe -colormode 1 test1.dwg _test1_bw.swf

..\dwg2vec.exe test2.dwg _test2.pdf
..\dwg2vec.exe test2.dwg _test2.xps
..\dwg2vec.exe test2.dwg _test2.pcl
..\dwg2vec.exe test2.dwg _test2_wmf.wmf
..\dwg2vec.exe test2.dwg _test2_emf.emf
..\dwg2vec.exe test2.dwg _test2.ps

..\dwg2vec.exe -colormode 1 -byview -width 792 -height 612 test2.dwg _test2_byview.pdf

..\dwg2vec.exe text.dwg _text.pdf

image

Please find all options in dwg2vec.exe software at below,

C:\>dwg2vec.exe
DWG Tools Converter Command Line v3.2
Convert DWG and DXF files to Vector PDF, WMF, EMF, PS, EPS, SVG, SWF, PCL, HPGL, XPS formats.
Release Date: Sep 15 2016
Web: http://www.verypdf.com
Web: http://www.verydoc.com
Email: support@verypdf.com
Usage: dwg2vec [options] <dwg-file> [<out-file>]
  -fontdir <string>  : a folder contain .ctb, .shx, etc. files
  -dpi <int>         : set DPI to output file
  -width <fp>        : set width, unit is point
  -height <fp>       : set height, unit is point
  -unit <string>     : cm, mm, pt, in, default is pt
  -linewidth <string>: set line width, unit in mm
  -colormode <int>   : set color mode, 0 is color and 1 is black and white
  -byview            : create an output file for each view
  -noext             : don't append suffix to filename for single page file
  -fixed             : fix precision problem
  -debug             : output debug message
  -$ <string>        : input registration key

If you encounter any problem with dwg2vec.exe application, please feel free to let us know, we are glad to assist you asap.

PDF Software

How to extract text and text coordinates from a PDF file? PDF Parsing with Text and Coordinates. PDF Text Extraction with Coordinates.

I want to extract all the text boxes and text box coordinates from a PDF file. I would like to extract text from a portion (using coordinates) of PDF page, can anyone help me out?

Given a PDF file, output should look something like:

   489, 41,  "Signature"
   500, 52,  "b"
   630, 202, "a_g_i_r"

Customer #1  
-----------------------------------------------
Hi,

I was wondering if anyone could recommend a program which can extract the starting (top left) coordinates (x,y) of each word in a PDF file (and the end if possible). Ideally output would be in a format that could be easily inserted into a database.

Customer #2
-----------------------------------------------

image
Sometimes, we have some customers who want to extract text contents and their positions from PDF pages, the text positions are used to parse the values, such as read invoice numbers from PDF files or looking for some other information.

PDF Extractor SDK (PDF Parser SDK and Command Line) is a good product to extract various information from PDF files, of course, it can extract text contents and text coordinates also.

1. You may download the trial version of PDF Extractor SDK (PDF Parser SDK and Command Line) from this web page first,

https://veryutils.com/pdf-extractor-sdk-pdf-parser-sdk-and-command-line

2. After you download it, you may unzip it to a folder.

3. Please run a CMD window first, if you don't know how to run a CMD window, please look at following web page,

https://veryutils.com/blog/top-10-methods-to-run-a-command-line-window-in-windows-10/

4. pdfextract.exe is a command line application, it supports following command line options,

D:\VeryPDF_PDFExtractTool>pdfextract.exe
pdfextract.exe version 3.0
Copyright 1996-2017 VeryPDF.com Inc.
Product Name: VeryPDF PDF Extract Tool Command Line
http://www.verypdf.com
http://www.verydoc.com
http://support.verypdf.com
Email: support@verypdf.com
Usage: pdfextract.exe [options] <PDF-file>
  -f <int>           : first page to print
  -l <int>           : last page to print
  -opw <string>      : owner password (for encrypted files)
  -upw <string>      : user password (for encrypted files)
  -outfolder <string>: Set a folder to store extracted files
  -layout            : maintain original physical layout
  -textfile          : Extract text contents from PDF file
  -textpos           : Extract text and coordinates from PDF file
  -nopgbrk           : don't insert page breaks between pages
  -h                 : print usage information
  -help              : print usage information
  --help             : print usage information
  -?                 : print usage information
  -$ <string>        : input your license key
Example:
   pdfextract.exe D:\in.pdf
   pdfextract.exe -outfolder D:\out\ D:\in.pdf
   pdfextract.exe -outfolder D:\out\ D:\in.pdf
   pdfextract.exe -opw 123 -upw 456 -outfolder D:\out\ D:\in.pdf
   pdfextract.exe -outfolder D:\out\ D:\in.pdf > out.log
   pdfextract.exe -outfolder D:\out\ D:\in.pdf out.log
   pdfextract.exe D:\in.pdf out.log
   pdfextract.exe -textpos D:\in.pdf D:\out.txt
   pdfextract.exe -textpos -nopgbrk D:\in.pdf D:\out.txt
   pdfextract.exe -textfile D:\in.pdf D:\out.txt
   pdfextract.exe -layout -textfile D:\in.pdf D:\out.txt

5. You can simple run following command line to extract all information from your PDF file,

pdfextract.exe -outfolder D:\VeryUtils\test\ D:\downloads\Test_in.pdf

6. You will find a "TextFileWithPosition.txt" file in the "D:\VeryUtils\test" folder, this text file contains all text contents and coordinates for each word, such as,

image

7. "PageContents.xml" is a XML file which contain coordinates for each character, such as,

image

8. Now, you can write a simple PHP or Python application to read and parse X/Y positions from these PDF files, then you can process these PDF files easily.

image

If you wish extract more information from PDF files, such as hyperlinks, colorspaces, attachments, bookmarks, pictures, embedded fonts, forms, etc. elements, please feel free to contact us, we are glad to assist you asap,

https://veryutils.com/contact