PDF Software

How to merge and combine PDF files using Python language?

In this tutorial I will show you how to merge and combine two or more PDF files into one PDF file using Python 3.

VeryUtils PythonPDF Library is a Python Library for splitting and merging the pages of PDF and PDF/A conform documents with practical additional functions. It can process multiple input and output documents simultaneously. PDF Merge Split is available as shell tool for batch processing with the command line and as API to be integrated with Python, PHP, C#, Visual Basic, Java or C/C++.

PythonPDF Library can be purchased on this web page,

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

after you purchase it, you will get a download URL to the latest version of PythonPDF Library, please download and unzip it to a folder, such as,

D:\downloads\python-pdfrw

before you use it, please set the main path to "PYTHONPATH" first, for example,

set PYTHONPATH=D:\downloads\python-pdfrw

then please go to "examples" folder, run following command line to test the PDF Merging function,

python cat.py testcmd.pdf watermark.pdf

You will get a merged PDF file after a few seconds, in the following screenshot, the pages #1-#32 are come from first PDF file, the pages #33-#43 are come from second PDF file,

image

The following is the Python source code of cat.py file,

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

from pdfrw import PdfReader, PdfWriter, IndirectPdfDict

inputs = sys.argv[1:]
assert inputs
outfn = 'cat.' + os.path.basename(inputs[0])

writer = PdfWriter()
for inpfn in inputs:
    writer.addpages(PdfReader(inpfn).pages)

writer.trailer.Info = IndirectPdfDict(
    Title='your title goes here',
    Author='your name goes here',
    Subject='what is it all about?',
    Creator='some script goes here',
)
writer.write(outfn)
--------------------------------------------------

This cat.py file demonstrates two features:

1) Concatenating multiple input PDFs.
2) Adding metadata to the PDF.

If you have any question for the PythonPDF Library, please feel free to let us know, we are glad to assist you asap,

https://veryutils.com/contact

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.