PDF Command Line Suite - PDF-Tools AG

Transcription

PDF Command Line SuiteVersion 4.12User ManualContact:pdfsupport@pdf-tools.comOwner:PDF Tools AGKasernenstrasse 18184 pyright2000-2018

PDF Command Line Suite, Version 4.12Page 2 of 65November 27, 2018Table of ContentsTable of Contents. 21Overview . 61.11.21.32The Different Tools.6Installation.7Using the Tools .7License Management . 82.12.22.33Graphical License Manager Tool .8List all installed license keys.8Add and delete license keys .8Display the properties of a license .9Select between different license keys for a single product .9Command Line License Manager Tool .9List all installed license keys.9Add and delete license keys .9Select between different license keys for a single product .9License Key Storage . 10Windows. 10Mac OS X. 10Unix / Linux . 10General Options . 103.13.24Usage. 10Encrypted files. 10-pwDecrypt the Input Files . 11-perm Set Permission Flags . 11-owner Set Owner Password . 11-user Set User Password . 11-lkSet License Key . 11pdcat . 124.14.2Description . 12Functionality and Options. 12Merge documents . 12-rAllow replacing the file specified for output . 12-eexit with error on processing problem . 12-annot Delete Text Annotations . 12-bglogo Set a Background Logo . 12-box Set the Media Box . 13-bs:Border Style of Hyperlinks . 13-cSet the Document Information . 13-clip Clip Pages. 13-crop Set the Crop Box . 14-ICreate Bookmarks for each Input File. 14-nDo not copy bookmarks of next input file . 14-lUse a Control File . 14Create Link Annotations . 14Create Bookmarks with Links . 16PDF Tools AG – Premium PDF Technology

PDF Command Line Suite, Version 4.12Page 3 of 65November 27, 20184.35Create a Free Text Annotation . 17-logo Add Logos from a PDF Document . 19-mAdd Named Destinations for each Page . 19-dDo not copy named destinations of next input file(s) . 19-MSet Metadata . 19-oTSet Page Mode . 19-p:Copy a Specified Range of Pages . 19-plSet Page Layout . 19-RRotate Pages . 20-sSubstitute Text Strings in Action Links . 20-spSubstitute a Substring in Action Links . 20-ucUn-embed File Collection . 20-vpSet Viewer Preferences. 20-wcWarn about collections . 21-ucUnembed collections . 21Common Transformations . 22Page Sizes . 23Examples for Transformations . 24pdsplit . 325.15.26Description . 32Functionality and Options. 32Split Files and name Output Files . 32-bExtract all or individual Chapters According to Bookmarks . 33-lRestrict the Processing to a Specific Bookmark Level . 33-mExclude low-level Bookmarks . 33-pSplit a Document into Parts with Specified Number of Pages . 34-xExchange Bookmark Characters in File Names. 34pdsel . 356.16.27Description . 35Functionality and Options. 35Select Individual Pages or Ranges of Pages . 35-aRemove Annotations . 35pdw . 367.17.28Description . 36Functionality and Options. 36-cBreak down Text Blocks to Individual Character . 36-crAdd Carriage Return before New Lines . 36-oList the Annotations in a Separate File. 36-rTake Account of the Page Rotation . 36-uList the Text in Unicode Encoding . 36-wBreak down Text Blocks to Blank Separated Words . 36pdform . 388.18.2Description . 38Functionality and Options. 38Fill in data . 38Add a new form field . 38Delete a field . 38-lList all Form Fields . 38PDF Tools AG – Premium PDF Technology

PDF Command Line Suite, Version 4.12Page 4 of 65November 27, 20189pdwebl . 399.19.210Description . 39Functionality and Options. 39Add URL Links to a PDF Document . 39Add Page links to a PDF Document. 39Add Java Scripts . 39-iRead Input File from Standard Input . 39-l:Define Key/Link Pairs in a File or Standard Input . 40-qQuite Mode . 40-sSet the border style of links . 40pdtoc . 4210.1 Description . 4210.2 Functionality and Options. 42-bCreate or Omit Bookmarks. 42-ISet New Titles . 42-dPlace the Current Date on the Pages . 42-wSet the Page Width . 42-tPlace a Header Text on the Pages . 42-cSet the Document Title. 42-dest Create Named Destination Links . 42-urlCreate URL Links . 43-@Read Input from a Control File . 4311pdbm . 4411.1 Description . 4411.2 Functionality and Options. 44-dList Named Destinations . 44-DList Named Destinations Tab-separated . 44-oRedirect the Output to a File . 44-oaPage Mode, Initial Page Number, Open Action . 44-aAdd Bookmarks from an Input File . 45-nDo not Print Destinations . 46-n1Add a Leading Hyphen . 4612pdpg . 4712.1 Description . 4712.2 Functionality and Options. 47-cList the CropBox . 47-fList All Fonts on Pages. 47-pAll Get the Total Number of Pages in a PDF Document . 48-fAllList all Fonts in a Document . 48-mList the MediaBox . 48-pSet the Page Range . 48-rList the Page Rotation . 49-sAbbreviate Output . 49-uDisable UserUnit Adjustment . 4913pdxt . 5013.1 Description . 5013.2 Functionality and Options. 50PDF Tools AG – Premium PDF Technology

PDF Command Line Suite, Version 4.12Page 5 of 65November 27, 2018Specify a PDF File Containing the Logo . 50Select the logo page . 50Put the Logo on top of the Page or in the Background . 5014txt2pdf . 5114.1 Description . 5114.2 Functionality and Options. 51-ffSet the font . 52-fsSet the font size . 52-pbSet the page border size. 52-psSet the page size . 52-twSet the line wrap mode . 52-vSet verbose mode. 5214.3 Error messages and codes . 5215pdcrop . 5315.1 Desciption . 5315.2 Functionality and Options. 53-obBase the Cropping on a Specified Box . 53-nbSpecify the Box Type to Be Set . 53-shrink Shrink the Box . 5316pdmerge . 5516.1 Description . 5516.2 Functionality and Options. 55Simple Merge of PDF Files . 55-cCreate a Table of Contents. 55-tMerge PDF Files and Add Individual Outlines . 56-WPSpecify Javascript Code . 56@Use a Control File . 57-axSet XMP Metadata . 57pdinfo . 5817pdobj . 5918pdls. 6019COM Interface. 6119.1 Overview . 6119.2 Installation. 6119.3 Examples . 62Declaration . 62Parameter Passing . 62Execution . 62Appendix A: Security . 63Appendix B: Link Definition Files for pdcat . 63PDF Tools AG – Premium PDF Technology

PDF Command Line Suite, Version 4.12Page 6 of 65November 27, 20181Overview1.1The Different ToolsThe Command Line Suite consists of a series of tools to manipulate PDF documents invarious ways or extract information. The tools are based on the PDF Library SDK.The following tools are part of the PDF Command Line Suite.pdcatThe pdcat tool concatenates (merges) PDF files. The tool can also mergeannotations from another PDF file, generate book marks, add a nameddestination for each page, set the title text of the output file, rotatepages, add link annotations specified in an ASCII file, substitute filenames in action links, clip and crop pages, and morepdwThe pdw tool analyses text and prints it along with position and sizeinformation. You can process this output to generate the hyperlinkdefinitions for pdlink. (The pdw sample program does not handle the fullset of stream operators and neither all fonts).pdxtThe pdxt tool adds a logo taken from a first PDF file and puts it on allpages of a second input PDF file. The logo can be put behind or on top ofthe page content.pdformThe pdform tool displays information about text form fields, or fills in datainto form fields.pdselThe pdsel tool allows to select (extract) pages from a PDF file.pdweblThe pdwebl tools can add web links (URL link annotations) to a PDF file.pdtocThe pdtoc tool creates a PDF file containing links to existing PDF files. Itcan also add URL links and links to named destinations.pdsplitThis tool splits a PDF file into single page files, changing links betweenpages into links between the spited files.pdbmThis tool lists bookmarks contained in a PDF file.pdpgThis tool lists basic information about a PDF file, such as number of pages,fonts, MediaBox, CropBox etc.txt2pdfThe txt2pdf tool creates PDF files from ASCII textpdcropThis tool can be used to crop PDF files.pdinfo*pdobj*pdls*The pdinfo tool lists the info object of a PDF fileThe pdobj tool lists individual objects of the PDF fileThe pdls tool lists all pages objects of a PDF file and optionally theircontents streams(*) These tools are specialized tools which require profound knowledge about PDFtechnology.PDF Tools AG – Premium PDF Technology

PDF Command Line Suite, Version 4.12Page 7 of 65November 27, 20181.2InstallationThe PDF Command Line Suite comes as a compressed archive (ZIP for Windows, tar.gzfor Unix platforms). Extract the contents of the archive to the file system. There will bea “bin” folder containing a Win32, x86, and/or an x64 subfolder (depending on theplatform). These subfolders contain the executables. You may run them directly fromthis location in the file system, or copy them to a more suitable folder (like /usr/bin onUnix).The Windows kit also contains the PDApp.DLL file which offers the functionalities of thepdcat and the pdsplit command line tools via a COM interface. To use this functionality,the 32-bit and the 64-bit DLLs need to be registered with COM using theREGSVR32.EXE tool (administrator privileges required).1.3Using the ToolsEach tool prints a short text on how to use it to standard output when executedwithout parameters. This text consists of the usage and a list of the availableparameters.The command line syntax is Unix like. Command line arguments in brackets ([ . ])are optional. Arguments in curly brackets ({ . }) can be repeated.The tools have a usage, to provide a brief description of all available features. Toretrieve the usage, they the tool name without any arguments.This documentation does not cover all features, but only common features andmeaningful use-cases. For undocumented features, please refer to the usage.PDF Tools AG – Premium PDF Technology

PDF Command Line Suite, Version 4.12Page 8 of 65November 27, 20182License ManagementThere are three possibilities to pass the license key to the application:1. The license key is installed using the GUI tool (Graphical user interface). This isthe easiest way if the licenses are managed manually. It is only available onWindows.2. The license key is installed using the shell tool. This is the preferred solution forall non-Windows systems and for automated license management.3. The license key is passed to the application at runtime via the command lineswitch -lk property. This is the preferred solution for OEM scenarios.2.1Graphical License Manager ToolThe GUI tool LicenseManager.exe is located in the bin directory of the product kit.List all installed license keysThe license manager always shows a list of all installed license keys on the left pane ofthe window. This includes licenses of other PDF Tools products.The user can choose between:Licenses available for all users. Administrator rights are needed for modifications.Licenses available for the current user only.Add and delete license keysLicense keys can be added or deleted with the “Add Key” and “Delete” buttons in thetoolbar.The “Add key” button installs the license key into the currently selected list.The “Delete” button deletes the currently selected license keys.PDF Tools AG – Premium PDF Technology

PDF Command Line Suite, Version 4.12Page 9 of 65November 27, 2018Display the properties of a licenseIf a license is selected in the license list, its properties are displayed in the right paneof the window.Select between different license keys for a single productMore than one license key can be installed for a specific product. The checkbox on theleft side in the license list marks the currently active license key.2.2Command Line License Manager ToolThe command line license manager tool licmgr is available in the bin directory for allplatforms except Windows.A complete description of all commands and options can be obtained by running theprogram without parameters:licmgrList all installed license keyslicmgr listThe currently active license for a specific product is marked with a star ‘*’ on the leftside.Add and delete license keysInstall new license keylicmgr store X-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXXDelete old license keylicmgr delete X-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXXBoth commands have the optional argument -s that defines the scope of the action:g: For all usersu: Current userSelect between different license keys for a single productlicmgr select X-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXXPDF Tools AG – Premium PDF Technology

PDF Command Line Suite, Version 4.12Page 10 of 65November 27, 20182.3License Key StorageDepending on the platform the license management system uses different stores forthe license keys.WindowsThe license keys are stored in the registry:HKLM\Software\PDF Tools AG(for all users)HKCU\Software\PDF Tools AG(for the current user)Mac OS XThe license keys are stored in the file system:/Library/Application Support/PDF Tools AG (for all users) /Library/Application Support/PDF Tools AG (for the current user)Unix / LinuxThe license keys are stored in the file system:/etc/opt/pdf-tools (for all users) /.pdf-tools (for the current user)Note: The user, group and permissions of those directories are set explicitly by thelicense manager tool.It may be necessary to change permissions to make the licenses readable for all users.Example:chmod -R go rx /etc/opt/pdf-tools3General Options3.1UsageThe usage will be listed by typing a command without parameters.You may detect useful options for some of the tools that are not described in detail inthis manual.3.2Encrypted filesEncrypted input files, that have a user password, can be read with most tools if eitherthe user or owner password is provided.PDF Tools AG – Premium PDF Technology

PDF Command Line Suite, Version 4.12Page 11 of 65November 27, 2018A PDF document can have two passwords: The owner password and a user password.The owner password is to protect the document from unwanted changes or actionstaken. There are several security flags which can be set for this purpose (see AppendixA: Security). When a PDF document is encrypted with a user password, the content ofthe document can only be read (opened) when the user password is known.Most, but not all tools of the PDF Command Line Suite support the following encryptionrelated options:-pwDecrypt the Input FilesSpecify either the user or the owner password to read an encrypted PDF inputdocument.pdcat -pw PW1 in1.pdf -pw PW2 in2.pdf out.pdf-perm Set Permission FlagsSet the access permission flags. See also Appendix: Security for additional information.-owner Set Owner PasswordSet the owner’s password. That’s the password required to change the accesspermissions of the document, such as the passwords and the permission flags.-userSet User PasswordSet the user’s password. If that password is set, the user is prompted a password toopen and read the document.Specify a user and owner password and access permissions to encrypt the output files.pdcat -user upw -owner opw -permit psca in.pdf out.pdfFor the permissions flags see Appendix A: Security-lkSet License KeyPass a license key to the application at runtime instead of installing it on the system.PDF Tools AG – Premium PDF Technology

PDF Command Line Suite, Version 4.12Page 12 of 65November 27, 20184pdcat4.1DescriptionThe main functionality of pdcat is to concatenate pages from different input documentsinto one new output document. It can also add and replace links, reset the media andcrop box, as well as clip and scale pages or add logos.Please note that if a PDF document is provided multiple times as input file, theresources (such as images or embedded fonts) will no longer be shared. This can leadto an increase of the file size.4.2Functionality and OptionsMerge documentsMerge the pages of multiple (two ore more) PDF input documents into one outputdocument:pdcat in1.pdf in2.pdf in3.pdf out.pdfUser’s Tip: One should try and avoid using the same input document multiple times.The main reason is that resources (such as embedded fonts and images) areembedded from every input file. Hence if the same resource is used on two differentpages of the same input document, and these two pages are merged using the sameinput file twice, the resource is embedded twice. For page re-assembly of the sameinput document use the tool pdsel instead.-rAllow replacing the file specified for outputpdcat –r in1.pdf in2.pdf in3.pdf out.pdfThis option must be specified as the first option and will allow that the file specified asoutput can be overwritten.-eexit with error on processing problem-annot Delete Text AnnotationsDo not copy any text annotations to the output file.pdcat -annot in.pdf out.pdf-bglogo Set a Background LogoUse logo.pdf as background logo, in.pdf as input and create a new output documentwith the logo called out.pdf. In the background means behind the content of the page.PDF Tools AG – Premium PDF Technology

PDF Command Line Suite, Version 4.12Page 13 of 65November 27, 2018pdcat -bglogo:1-1 logo.pdf in.pdf out.pdfUser’s Tip: If the page contains opaque items, such as non-transparent images orvector graphics a logo in the background might remain partially or fully hidden behindthese objects. In this situation use the switch –logo to put the logo in the foreground.Add a logo with its size reduced to 50%. The coordinates of the lower left corner of thelogo remain the same.pdcat -logo "0.5 0 0 0.5 0 0" logo.pdf in.pdf out.pdfAdd a logo with its size reduced to 25% and move it 200 points to the right and 300points to the top. Add the logo only to page 2 of in.pdf.pdcat -logo:2-2 "0.25 0 0 0.25 200 300" logo.pdf in.pdf out.pdfUser’s Tip: See also chapter Common Transformations.-boxSet the Media BoxThe media box marks the size of the page.Set the media box to a square of 300x300 points at x 100/y 250.pdcat -box "100 250 400 550" in.pdf out.pdfUser’s Tip: The media-box defines the size of the page. If it’s changed it has noimpact on any objects on the page. This means resetting the media-box does notautomatically delete objects outside the media-box. It therefore does not reduce thefile size nor should be used to hide any confidential information, since it could simplybe reset again.-bs:Border Style of HyperlinksSet the set border style for hyperlinks added via switch –l.See chapter “Border Style” to find out more about bor

PDF Command Line Suite, Version 4.12 Page 7 of 65 November 27, 2018 PDF Tools AG – Premium PDF Technology 1.2 Installation The PDF Command Line Suite comes as a compressed archive (ZIP for Windows, tar.gz for Unix platforms). Extract the