# US 2024/0005083 A1 · Method and system for merging pdf files in a large batch

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2024/0005083 A1
- Document ID: US20240005083A1
- Status: Published application
- Kind: A1
- Application number: 18/035,161
- Filed: 2022-03-30
- Published: 2024-01-04
- Earliest claimed: 2021-04-19
- Assignees: Fujian Foxit Software Development Joint Stock Co., Ltd.
- Applicants: Fujian Foxit Software Development Joint Stock Co., Ltd.
- Inventors: Junyi LIANG
- Web page: https://patentgrep.com/patent/US20240005083A1

## CPC

- G06F 40/131: Fragmentation of text files, e.g. creating reusable text-blocks; Linking to fragments, e.g. using XInclude; Namespaces
- G06F 40/137: Hierarchical processing, e.g. outlines
- G06F 40/103: Formatting, i.e. changing of presentation of documents (automatic justification G06F40/189; automatic line break hyphenation G06F40/191)
- G06F 40/117: Tagging; Marking up (details of markup languages G06F40/143); Designating a block; Setting of attributes (style sheets, e.g. eXtensible Stylesheet Language Transformation [XSLT], G06F40/154)
- G06F 40/143: Markup, e.g. Standard Generalized Markup Language [SGML] or Document Type Definition [DTD]
- G06F 40/157: using dictionaries or tables
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Disclosed are a method and system for merging a large batch of PDF files. The method comprises: outputting header information of a target PDF file, outputting catalog dictionary information, and generating an object number of a PDF page object and recording same; parsing in sequence PDF files to be merged, and acquiring the object number and the offset of all indirect objects and the catalog dictionary information; parsing in sequence, from within the catalog dictionary information, page object dictionary information corresponding to the PDF files to be merged, and reading in sequence object number information of each page object; invoking a global object number generator to generate a new object number, and recording the correspondence between original object number information and the new object number in a map; invoking an output class of a PDF indirect object, outputting a page object of the PDF files to be merged into a page object of the target PDF file, and recording same in the start position and length in the target PDF file; and checking whether all PDF files to be merged have completed merging.

## Claims

### Claim 1

A method for merging PDF files in a large batch, comprising the following steps:
Step 1: determining and outputting header information of a merged target PDF file, outputting corresponding catalog dictionary information, and generating and recording objnums (object numbers) of corresponding PDF pages;
Step 2: sequentially parsing a plurality of PDF files to be merged to obtain objnums and offsets of all indirect objects of each PDF file to be merged as well as catalog dictionary information of each PDF file to be merged;
Step 3: sequentially parsing page dictionary information corresponding to each PDF file to be merged from the catalog dictionary information of the PDF file to be merged, and sequentially reading the objnum information of each page from all the page dictionary information;
Step 4: calling a global objnum generator to generate new objnums, and recording the corresponding relationship between the original objnum information and the new objnums into a map;
Step 5: calling an output class for the PDF indirect objects to output the pages of each PDF file to be merged into pages of the merged target PDF file, and recording their starting positions and lengths in the target PDF file;
Step 6: checking whether all the PDF files to be merged have been merged,
if not, returning to Step 2;
if so, combining global information into the merged target PDF file according to page dictionary information of the target PDF file.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the information parsed from the catalog dictionary information of each PDF file to be merged in Step 3 further comprises AcroForm information and bookmark information corresponding to the PDF file to be merged.

### Claim 3 (depends on 1)

The method according to claim 1, wherein Step 5 specifically comprises:
Step 501: storing all the indirect objects referenced in the page dictionary information of each PDF file to be merged into a vector;
Step 502: circularly outputting all the indirect objects in the vector into the merged target PDF file, and if any output is a parent dictionary of the pages of the PDF file to be merged, using a page of the target PDF file to replace and end the corresponding output;
Step 503: judging whether all the indirect objects have been output,
if so, arranging the page dictionary information of each PDF file to be merged, and recording starting positions and lengths of all the indirect objects in the vector in the merged target PDF file;
if not, returning to Step 3.

### Claim 4 (depends on 3)

The method according to claim 3, wherein in Step 501, the indirect objects of the parent of the pages of each PDF file to be merged are modified into the pages of the merged target PDF file when stored.

### Claim 5 (depends on 3)

The method according to claim 3, wherein the output of any indirect object in Step 502 is performed only once.

### Claim 6 (depends on 1)

The method of claim 1, wherein the global information combined in Step 6 comprises AcroForm information and bookmark information.

### Claim 7 (depends on 1)

A system for merging PDF files in a large batch, configured to implement the method of claim 1, and comprising:
a PDFMerger module, configured to manage a merged target PDF file, which comprises objnums of all indirect objects output in the process of PDF merging, offsets of all the indirect objects, and page dictionary information of the target PDF file;
a MergePDFDocument module, configured to manage and parse the PDF files to be merged, and parsed contents comprising the objnums and offsets of all the indirect objects, catalog dictionary information of the PDF files to be merged, all the page dictionary information and AcroForm dictionary information;
a MergePDFPage module, configured to process all the indirect objects to be output in the page dictionaries of the PDF files to be merged; and
a PDFObjnumGenerator module, configured to generate objnums of the indirect objects of the merged target PDF file, and being a global-oriented class module.
