Merge and add page numbers of report PDF files

Source: Internet
Author: User
Tags cpdf

A project uses reportmachine as a report template, and then writes a DLL for Java calling in JNI mode. During Processing, multiple reports must be printed and output at a time. Since multiple reports are generated using different report templates, after converting them into PDF files, you need to combine these PDF files into one. In addition, the page number has to be appended to this file, because the original report was archived after being manually stamped by the page number tagging machine. This is troublesome and it is hoped that the page number will be automatically generated during computer output. The problem was finally completely solved today.

1. Merge PDF files. Use the pdftk tool to merge multiple files into one file through the command line.
1. Rotate the horizontally arranged reports to the vertical direction.
Pdftk in1_cat 1-endeast output outputted
2. Merge multiple files into one file
Pdftk 1.pdf 2.pdf 3.pdf output allmodules
See http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/ for this tool

2. Add additional page numbers to the PDF file and use the CPDF tool.
At the beginning, a stamptk tool corresponding to pdftk was used to add a watermark to the PDF file. However, it is a commercial version and needs to be purchased. After connecting to the a-0000.comwebsite, I should find a number.exe attack. Unfortunately, it is a GUI operation method and is not suitable for silent execution using command lines in the background. After a great deal of effort, I found the CPDF tool and tried it. It is really good to add a page number.
Command: CPDF-bottomright 40-font Arial-font-size 16-add-text "% PAGE" 0.pdf-O 1.pdf
This command outputs: for non-policcial use only... you can add the parameter 2> NUL to block it.
CPDF-bottomright 40-font courier-font-size 16-add-text "% PAGE" 0.pdf-O 1.pdf 2> NUL
See: http://community.coherentpdf.com/

So far, the requirements for merging multiple PDF files and adding page numbers are successfully implemented.

Supplement: CPDF can also be used to merge PDF files and rotate them.
Merge: CPDF-merge 1.pdf 2.pdf-O allge
Rotation: CPDF-rotate 270 3.pdf-O 4.pdf
When you add a page number, if a file is a rotated PDF file, you must add the parameter-prerotate to ensure that all the files you see are consistent.
CPDF-prerotate-bottomright 40-font Arial-font-size 16-add-text "% PAGE" 0.pdf-O 1.pdf 2> NUL
At the same time, if the last command line is placed in batch processing, the percent sign (%) needs to be escaped and two % will be used.

 

Currently, CPDF is used for report operations.

 

Merge and add page numbers of report PDF files

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.