Powerful PDF file Manipulation gadget--pdftk small white usage

Source: Internet
Author: User

Preface

As programmers, we all know, will always be technical little white ask all kinds of programming with no relationship to the hardware, software problems. Once a technical small white colleague asked if there is any way to merge PDF files, then they are also confused, because their work life is rarely to operate PDF files, and at that time the company to the developer's computer rights management is very strict, whether it is the Internet or install software, are subject to great restrictions, Finally, the bite of the bullet was not solved for a while.

The previous two days in the batch processing program, found that the batch program is the command to merge files, I suddenly think of this colleague's problem, I tried to merge the PDF, but not. Although lost a bit, but in the spirit of learning or Baidu a bit about the PDF of some knowledge, found that most of the operation of the PDF file software installation is not only trouble, but also basic charges, I go, even I programmers are too troublesome things, the shy all teach small white? But when I tried the next pdftk, the instant was attracted, because it is really very simple to use, as long as a little processing, you can throw it to the small white.

Meet PDFTK

PDFTK (official website: https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/) is a software developed abroad that aims to make PDFs easier to operate. Official online hanging some of the core features of customer software is actually to be charged to use, but it has a server version is free, this is the protagonist of this article. PDFTK supports merging, rotating, adding watermarks, adding attachments, encrypting,

Download Installation

: https://www.pdflabs.com/tools/pdftk-server/

Select the version of the operating system to download, the installation process is not table, small white installation can be. After successful installation, the bin directory of the installation directory will have Libiconv2.dll and Pdftk.exe files, which is the PDFTK tool for manipulating PDFs. The environment variable also has the path to this tool. If you have a company like Bo owners do not install software, copy these two files can be.

Action Commands

On the official website (https://www.pdflabs.com/docs/pdftk-cli-examples/) There are some examples, here to tidy up a batch of orders convenient small white, The related command is saved as a. bat file, and then the PDF file and the. bat file you want to manipulate are placed in the same directory.

Merge all PDFs within the folder, output combind.pdf

@echo off PDFTK% CD%\*.pdf cat output%CD%\combined.pdf

Combine different pages of multiple PDFs into a new PDF document, take Base1.pdf's first page, base2.pdf first page, Output combined2.pdf

@echo off pdftk A=%cd%\base1.pdf b=%cd%\base2.pdf cat A1 B1 output%CD%\combined2.pdf

Rotate the PDF, rotate the angle to the north left West right east (North\south\west\east), the following example, combined the first page to the right and others remain unchanged, the rotation parameter is 1east 2-end, If all rotation is 1-endeast (note: There are no spaces here)

@echo off  %cd%\combined. PDF Cat 1east 2-end output%cd%\rotate.pdf

The PDF is owner-encrypted using 128-bit strength (owner password), the PDF file is read-only after encryption, and no owner password can be used to perform various file operations on the PDF. This is the owner-encrypted base1.pdf, the password is foopass, the output file is Poopass.128.pdf

@echo off PDFTK% CD%\base1.pdf output%cd%\foopass.128.pdf OWNER_PW foopass

The same time, the PDF plus the visitor password (will pop up a password input box) This example of the original file is in.pdf, encrypted file is mydoc.128.pdf, the owner password is foopass, the visitor password is Baz

@echo off PDFTK% CD%\base1.pdf output%cd%\foopassbaz.128.pdf owner_pw foopass USER_PW Baz

Decrypt the PDF document, INPUT_PW empty, and then the owner password, where the input file is the encrypted file foopassbaz.128.pdf, the output file nopass.pdf, the output file will remove the owner password and the visitor password.

@echo off  %cd%\foopassbaz.128.pdf input_pw foopass output%cd%\nopass.pdf

Add Watermark, The following command will stamp.pdf as a background watermark (that is, stamp.pdf superimposed on the bottom) to base1 and output stampback.pdf, if you want to stamp.pdf synthesis base1 the foreground watermark (that is, stamp.pdf superimposed on the surface), the following Backgroud replaced Stamp can be.

@echo off  %cd%\base1. pdf background%cd%\stamp.pdf output%cd%\stampback.pdf

The above is commonly used in the operation of the relevant command of the PDF file, in fact, PDFTK also provides a number of functions, specifically with the reference website and input in the cmd input pdftk--help to view relevant information, here do not write, after all, small white do not use so meticulous function.

Attachment

Attachments provide their own test PDFs and widgets Libiconv2.dll and Pdftk.exe files, and if a friend is not convenient to install (like my home company) can download the attachment directly to operate.

PDF gadget

Reference:

http://blog.csdn.net/fresherman/article/details/5979204

https://www.pdflabs.com/docs/pdftk-cli-examples/

Powerful PDF file Manipulation gadget--pdftk small white usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.