A method for converting PDF files into layout data stream files

By parsing and concurrently processing PDF files and converting them into format data flow files, it solves the problems of high technical threshold and complex editing of PDF, achieves rapid conversion and diversified approval, improves the flexibility and readability of files, and is suitable for Multiple operating systems.

CN114154460BActive Publication Date: 2024-10-29JIANGSU ZHONGWEI TECH SOFTWARE SYST
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111455573.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-02
Publication Date
2024-10-29
Estimated Expiration
2041-12-02

AI Technical Summary

Technical Problem

Existing PDF technology has problems such as high technical threshold, complex editing, and inability to dynamically split and merge, making it difficult to achieve flexible data interaction and diversified signing and approval methods.

Method used

This paper proposes a method for converting PDF files into layout data flow files. By parsing the PDF file, allocating multiple threads to concurrently process the content of each page, converting basic objects and object attributes, forming a layout data flow file object, and storing it as a key Value pairs enable multi-threaded concurrent processing and asynchronous loading, simplifying the file conversion process.

Benefits of technology

It realizes the rapid conversion of PDF files, improves the loading speed and the editability of files. It has the characteristics of editable content, clear hierarchy and strong readability. It is suitable for running on multiple operating systems, supports multiple input methods, and enhances signing and approval. practicality and applicability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114154460B_ABST
    Figure CN114154460B_ABST
Patent Text Reader

Abstract

The invention discloses a method for converting a PDF file to a layout data stream file, including parsing a PDF layout file; reading the file content of the PDF, parsing to obtain the page number of the PDF, allocating multiple threads, and concurrently processing and parsing the content of the PDF; the content of the PDF includes basic objects, object attributes, and its resource objects; processing various objects of the PDF, and converting the coordinates, width, and height in the object attributes, and combining with the layout data stream element object to form a layout data stream file object, the layout data stream element object includes basic objects, drawing parameters, resource reference paths, and resource objects; creating a layout data stream file base; filling the layout data stream file object into the layout data stream file base to form a standard layout data stream file. The method described in the invention realizes the conversion of the PDF file to the original layout data stream file, and has the advantages of simple conversion method, using reference to call, removing redundant elements, and ensuring the conversion speed of the file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method for converting a PDF file into a formatted data stream file. Background Art

[0002] PDF is one of the most popular linear file transfer formats in the world. It was developed by Adobe Systems for file exchange in a way that is independent of applications, operating systems, and hardware. It became an international standard in 2008. However, there are some problems with PDF technology, such as high technical barriers, complex editing technology, and the inability to split and merge dynamically.

[0003] Layout data stream file is a file software under Jiangsu Zhongwei Technology Software System Co., Ltd. Zhongwei Technology has standardized a set of standard document format systems, integrating three major applications in the user interface: layout file reading, file and stream data interaction, and form handwritten signing and approval;

[0004] The documents are mainly based on innovative technologies such as automatic reconstruction of document base, multi-level hierarchical structure display, handwriting engine with pen tip, multi-file merging and smooth reading, traceable signature and approval closure, and overlapping approval.

[0005] To achieve:

[0006] 1. Reading experience of layout software

[0007] 2. Flexibility: It also realizes flexible interaction of data.

[0008] 3. Diversification: Standardized signing and approval methods. Documents support mixed signing and approval by keyboard, handwriting, pictures or audio. The handwriting signing and approval baseplates control each other, which solves the problem that a single user inputs too much content and the cells cannot be extended to occupy other input areas, improving the practicality and applicability of signing and approval. The signing and approval content is automatically sorted according to certain rules, making the approval of opinions more standardized.

[0009] 4. The layered rendering method is conducive to transmission, with high cohesion and low coupling, and the layers are mutually dependent.

[0010] 5. Compatibility: It can run on multiple different operating systems such as Windows, Linux, Kylin, UOS, Zhongke Fangde, Hongmeng, iOS, Android, etc.

[0011] 6. Stability: After the evolution of several major versions, the product is feature-rich, stable and reliable, can highly replace imported software of the same type, and has many innovative functions. It is an excellent domestically-produced file software with independent innovation. Summary of the invention

[0012] The object of the present invention is to provide a method for converting a PDF file into a formatted data stream file, so as to solve one or more of the above-mentioned problems in the prior art.

[0013] The present invention provides a method for converting a PDF file into a formatted data stream file, comprising:

[0014] Parse pdf layout files;

[0015] Read the file content of PDF, parse and obtain the page number of PDF, put it into a queue to form a page number queue, allocate multiple threads for concurrent processing to obtain the content of each page of PDF; the content of PDF includes basic objects, object attributes and its resource objects;

[0016] Basic objects include text objects, path objects, and image objects; path objects include straight lines, rectangles, Bezier curves, or a combination of multiple of them;

[0017] Object attributes include coordinates, width, height, drawing parameters, and resource reference paths. The resource reference path is the reference path between the basic object and the resource object.

[0018] Resource object attachments, multimedia files, fonts;

[0019] Process the basic objects, object attributes and resource objects of PDF, convert their coordinates, width and height according to the rules, and combine them with the layout data stream element objects to form the layout data stream file objects. The layout data stream element objects include basic objects, drawing parameters, resource reference paths and resource objects.

[0020] Create a layout data stream file base plate according to the page number queue; fill the layout data stream file object into the layout data stream file base plate to form a standard layout data stream file.

[0021] In some embodiments,

[0022] The total number of pages in the pdf layout file is the same as the total number of pages in the layout data stream file;

[0023] One page of the pdf layout file corresponds to one thread;

[0024] The pages of the pdf layout file correspond one-to-one to the pages of the layout data stream file.

[0025] In some implementations, the layout data stream file object is divided into four arrays for storage, and the four arrays are respectively a first array, a second array, a third array, and a fourth array.

[0026] The first array is used to store page numbers and content objects, where the content objects include basic objects, and the coordinates, width, and height corresponding to the basic objects;

[0027] The second array is used to store drawing parameters;

[0028] The third array is used to store resource objects;

[0029] The fourth array is used to store reference paths, which include resource reference paths and drawing parameter reference paths. The drawing parameter reference paths refer to reference paths between basic objects and drawing parameters.

[0030] In some implementations, the page number and content object are used as key and value.<key,value> The key-value pairs are stored in the first array.

[0031] In some implementations, the id and drawing parameters are used as key and value.<key,value> The key-value pairs are stored in the corresponding array. The id starts to increase from 1. If the same drawing parameters already exist in the array, they will not be added repeatedly. If the same drawing parameters do not exist in the array, the corresponding drawing parameters will be added to the array.

[0032] In some implementations, the id and resource object are used as key and value.<key,value> The key-value pairs are stored in the corresponding array. The id starts to increase from 1. The hash value of the resource file is obtained. If a resource object with the same hash value already exists in the array, it means that it already exists and will not be added repeatedly. If a resource object with the same hash value does not exist in the array, the corresponding resource object will be added to the array.

[0033] In some implementations, the id and reference path are used as key and value.<key,value> The key-value pairs are stored in the corresponding array, and the id starts to increase from 1. If the same reference path already exists in the array, it will not be added repeatedly; if the same reference path does not exist in the array, the corresponding resource reference path will be added to the array.

[0034] In some implementations, converting the coordinates, width, and height refers to converting the coordinates, width, and height obtained by parsing the PDF layout file into coordinates, width, and height based on 1024 points.

[0035] In some implementations, the pdf layout file is parsed to obtain the page width width of the pdf layout file.

[0036] Parse the PDF layout file to obtain the coordinates, width, and height of the object, respectively (x, y), w, and h.

[0037] The converted coordinates, width, and height are (x1, y1), w1, and h1 respectively.

[0038] The conversion rules of coordinates, width and height are:

[0039] scale = width / 1024;

[0040] x1=x*scale,y1=y*scale;

[0041] w1=w*scale;

[0042] h1=h*scale.

[0043] In some implementations, the PDF layout files include but are not limited to text-only PDF layout files, text-plus-picture mixed PDF layout files, and picture-only PDF layout files.

[0044] The advantages of the method for converting a PDF file to a layout data stream file described in the present invention are:

[0045] 1. Directly use PDF data to convert the original version, the conversion method is simple;

[0046] 2. Divide the PDF element objects into PDF objects, resource objects and resource paths stored in different arrays, and call them by reference, effectively removing redundant elements and ensuring the file conversion speed;

[0047] 3. Use multi-threaded concurrent processing to obtain PDF objects and object attributes of each page, and store data in the form of key and value pairs for easy retrieval, parsing and rendering;

[0048] 4. Use multi-threaded concurrent processing to obtain PDF objects and object properties of each page, separate coordinates, width, height and drawing parameters, realize asynchronous loading, improve loading speed and facilitate overall maintenance;

[0049] 5. Through position conversion, the position of the same content in the PDF layout file corresponds to the position in the layout data stream file, so that the page effect after conversion can be foreseen before conversion;

[0050] 6. Converting a PDF layout file into a layout data stream file can make the file have the characteristics of a layout data stream file:

[0051] The content is editable, clearly structured, and highly readable;

[0052] It not only displays the layout files, but also integrates with the data flow. When signing and approving, the data of the local area can be filled and extended according to actual needs;

[0053] More open (easier to integrate with other files), easier to maintain and convert. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 A flowchart of a method for converting a PDF file to a layout data stream file in some implementations of the present invention;

[0055] Figure 2 It is a schematic diagram of the framework elements of the layout data stream file of the present invention;

[0056] Figure 3 This is the directory structure of the layout data stream file generated in some implementation modes of the present invention. DETAILED DESCRIPTION

[0057] Combination Figure 1 According to the content shown, in some embodiments of the present invention, a method for converting a PDF file to a formatted data stream file is proposed, comprising the following steps:

[0058] S1, read the pdf format file;

[0059] S2. Read the file content of the PDF, parse and obtain the page number of the PDF, and place it in a queue to form a page number queue. With the upper left corner of the PDF page as the origin, multiple threads are allocated for concurrent processing to obtain the content of each page of the PDF. One page of the PDF layout file corresponds to one thread; the content of the PDF includes basic objects, object attributes, and its resource objects;

[0060] Basic objects include text objects, path objects, and image objects;

[0061] Object attributes include coordinates, width, height, drawing parameters, and resource reference paths. The resource reference path is the reference path between the basic object and the resource object.

[0062] Resource object attachments, multimedia files, fonts;

[0063] Drawing parameters include but are not limited to line connection style, wireframe, dashed line style (default starts from 0), dashed line repeat style (dash width, interval width), line endpoint style, fill color, outline color, bold, italic, whether it is a fixed width font, embedded font, whether the font is filled, fill color, whether the font is outlined, outline color, thickness value, image border horizontal angle radius, image border vertical angle radius, image border style (line width, color, outline fill, dashed line), where colors include (basic color, background fill, radial gradient, axial gradient, Gouraud gradient), resource reference path is the reference path between PDF object and PDF resource object, PDF resource object includes attachment, video, font;

[0064] Text objects include but are not limited to words, punctuation marks, text separators, bullets, numbers, formulas, or a combination thereof;

[0065] The path object includes a straight line, a rectangle, a Bezier curve, or any shape formed by a combination of multiple thereof;

[0066] Image objects include images and videos;

[0067] S3, convert the coordinates, width, and height in the object attributes of the PDF into coordinates, width, and height based on 1024 points, and set the page width width of the PDF layout file to be obtained.

[0068] Parse the PDF layout file to obtain the coordinates, width, and height of the object, respectively (x, y), w, and h.

[0069] The converted coordinates, width, and height are (x1, y1), w1, and h1 respectively.

[0070] The conversion rules of coordinates, width and height to coordinates, width and height based on 1024 points are as follows:

[0071] scale = width / 1024;

[0072] x1=x*scale,y1=y*scale;

[0073] w1=w*scale;

[0074] h1=h*scale;

[0075] The converted coordinates, width, height and layout data stream element object are combined to form a layout data stream file object. The layout data stream element object includes basic objects, drawing parameters, reference paths and resource objects. The reference paths include resource reference paths and drawing parameter reference paths. The drawing parameter reference paths refer to the reference paths between basic objects and drawing parameters.

[0076] S4. Generate an empty array, which includes pagelist array, drawparmlist array, reslist array and pathlist array.

[0077] The pagelist array is used to store page numbers and content objects. The content objects include basic objects and the coordinates, width, and height corresponding to the basic objects.

[0078] The drawparmlist array is used to store drawing parameters;

[0079] The reslist array is used to store resource objects;

[0080] The pathlist array is used to store reference paths;

[0081] S5. The specific operations of storing the format data stream file object are as follows:

[0082] Stores the pdf object, with the page number and content object as page and pdfpageobj,<key,value> The key-value pair method will<page,pdfpageobj> Put it into the pagelist array;

[0083] Store drawing parameters, using id and drawing parameters as key and value.<key,value> The key-value pairs are stored in the drawparmlist array, and the id starts to increase from 1. If the same drawing parameters already exist in the array, they will not be added repeatedly; if the same drawing parameters do not exist in the array, the corresponding drawing parameters will be added to the drawparmlist array;

[0084] Store resource objects, using id and resource objects as id and resources.<key,value> Key-value pair method<id,resources> In the form of , put it into the reslist array, and the id starts to increase from 1. Get the hash value of the resource file. If there is a resource object with the same hash value in the array, it means it already exists and will not be added repeatedly. If there is no resource object with the same hash value in the array, add the corresponding resource object to the array. Using the hash value has a better deduplication effect, because some are actually the same, but with different names.

[0085] Generate the resource reference path in the layout data stream object attribute, which is the reference path between the content object and the resource object, store the resource reference path in the layout data stream object attribute, and use the id and resource reference path as id and path.<key,value> Key-value pair method<id,path> The id is put into the pathlist array in the form of , and it increases from 1. If the same reference relationship already exists in the array, it will not be added repeatedly; if the same reference relationship does not exist in the array, the corresponding resource reference path will be added to the array;

[0086] Example:

[0087] A pdf format file,

[0088] Page 1: The title is Development Agreement (font size 20, block letters, bold), with a detailed description of the content of the Development Agreement (font size 16, Songti), and the first page is also marked (horizontal line, red, line frame 5);

[0089] Page 2: Title Agency Agreement (font size 20, block letters, bold), detailed description of the Agency Agreement (font size 16, Songti), with a mark (horizontal line, red, line frame 5) on the second page, and the third page also contains the Agency Agreement (font size 16, Songti), with a mark (wavy line, yellow, line frame 5);

[0090] Generate pagelist array, drawparmlist array, reslist array and pathlist array during conversion;

[0091] The first page generates the layout data stream file object obj, which contains the object of each character of textobj1, generates the drawing object drawparm1 (id1, size 20, regular script, bold), determines whether the reslist array exists, and puts it into the reslist array if it does not exist; generates font1 (id2, regular script, path) to determine whether it exists in the pathlist array, and adds it to the pathlist array if it does not exist. textobj1 references drawparm1, font1; for each text object of textobj2, generates the drawing object drawparm2 (id2, size 16, Songti), determines whether the reslist array exists, and puts it into the reslist array if it does not exist; generates font2 (id2, Songti, path) to determine whether it exists in the pathlist array, and adds it to the pathlist array if it does not exist; traverses to the mark, pathobj1 (the starting point of the line), draws the object drawparm3 (id3, horizontal line, red, wireframe 5), and pathobj1 references drawparm3. The second page is the same, and the id reference is used when referencing.

[0092] S6. Create a layout data stream file baseplate according to the page number queue. The total number of pages of the layout data stream file baseplate is equal to the total number of pages of the PDF layout file. The origin on the layout data stream file baseplate is consistent with the origin on the page of the PDF layout file, both of which are in the upper left corner of the page.

[0093] S7, Combination Figure 2 The content shown in the figure is filled into the layout data stream file base plate according to the layout data stream file standard, for example: Figure 3 The content shown in the figure writes pagelist into the contents file:

[0094]

[0095]

[0096] Each page content is written in the pages directory, corresponding to the path in contents, and the resource object is copied to the resources directory;

[0097] S8. Pack and generate standard format data stream files.

[0098] S3 and S4 can be executed synchronously.

[0099] The page content of the layout data stream file generated according to the above method corresponds one to one with the page content of the pdf layout file.

[0100] In some embodiments, the system for converting a PDF layout file to a layout data stream file includes a storage medium and a processor, the storage medium is used to store program code and data that needs to be stored during the execution of the method for converting a PDF file to a layout data stream file, and the processor is used to execute the program code to implement the method for converting a PDF file to a layout data stream file.

[0101] The above-mentioned PDF layout files include but are not limited to pure text type PDF layout files, text plus picture mixed type PDF layout files and pure picture type PDF layout files.

[0102] It is apparent to those skilled in the art that several similar variations and improvements may be made without departing from the inventive concept of the present invention, and these should also be considered within the protection scope of the present invention.

Claims

1. A method for converting a PDF file into a formatted data stream file, characterized in that: include: Parse pdf layout files; Read the file content of PDF, parse and obtain the page number of PDF, put it into a queue to form a page number queue, allocate multiple threads for concurrent processing to obtain the content of each page of PDF; the content of PDF includes basic objects, object attributes and its resource objects; Basic objects include text objects, path objects, and image objects; path objects include straight lines, rectangles, Bezier curves, or a combination of multiple of them; Object attributes include coordinates, width, height, drawing parameters, and resource reference paths. The resource reference path is the reference path between the basic object and the resource object. Resource objects include attachments, multimedia files, and fonts; Process the basic objects, object properties and resource objects of PDF, convert their coordinates, width and height according to the rules, and combine them with the layout data stream element objects to form the layout data stream file objects. The layout data stream element objects include basic objects, drawing parameters, resource reference paths and resource objects. Create a layout data stream file base plate according to the page number queue; fill the layout data stream file object into the layout data stream file base plate to form a standard layout data stream file.

2. A method for converting a PDF file into a layout data stream file according to claim 1, wherein: The total number of pages in the pdf layout file is the same as the total number of pages in the layout data stream file; One page of the pdf layout file corresponds to one thread; The pages of the pdf layout file correspond one-to-one to the pages of the layout data stream file.

3. A method for converting a PDF file into a formatted data stream file according to claim 1, wherein: The layout data stream file object is divided into four arrays for storage, and the four arrays are the first array, the second array, the third array and the fourth array. The first array is used to store page numbers and content objects, where the content objects include basic objects, and the coordinates, width, and height corresponding to the basic objects; The second array is used to store drawing parameters; The third array is used to store resource objects; The fourth array is used to store reference paths, which include resource reference paths and drawing parameter reference paths. The drawing parameter reference paths refer to reference paths between basic objects and drawing parameters.

4. A method for converting a PDF file into a layout data stream file according to claim 3, wherein: Use the page number and content object as key and value.<key,value> The key-value pairs are stored in the first array.

5. A method for converting a PDF file into a layout data stream file according to claim 3, wherein: Use id and drawing parameters as key and value.<key,value> The key-value pairs are stored in the corresponding array. The id starts to increase from 1. If the same drawing parameters already exist in the array, they will not be added repeatedly. If the same drawing parameters do not exist in the array, the corresponding drawing parameters will be added to the array.

6. A method for converting a PDF file into a layout data stream file according to claim 3, wherein: Use id and resource object as key and value.<key,value> The key-value pairs are stored in the corresponding array. The id starts to increase from 1. The hash value of the resource file is obtained. If a resource object with the same hash value already exists in the array, it means that it already exists and will not be added repeatedly. If a resource object with the same hash value does not exist in the array, the corresponding resource object will be added to the array.

7. A method for converting a PDF file into a layout data stream file according to claim 3, wherein: Use the id and reference path as key and value.<key,value> The key-value pairs are stored in the corresponding array, and the id starts to increase from 1. If the same reference path already exists in the array, it will not be added repeatedly; if the same reference path does not exist in the array, the corresponding reference path will be added to the array.

8. A method for converting a PDF file into a layout data stream file according to claim 1, wherein: Converting coordinates, width, and height means converting the coordinates, width, and height obtained by parsing the PDF layout file into coordinates, width, and height based on 1024 points.

9. A method for converting a PDF file into a layout data stream file according to claim 8, wherein: Parse the pdf layout file to get the page width of the pdf layout file, Parse the PDF layout file to obtain the coordinates, width, and height of the object, respectively (x, y), w, and h. The converted coordinates, width, and height are (x1, y1), w1, and h1 respectively. The conversion rules of coordinates, width and height are: scale=width / 1024; x1=x*scale,y1=y*scale; w1=w*scale; h1=h*scale.

10. A method for converting a PDF file to a layout data stream file according to any one of claims 1 to 9, wherein: PDF layout files include but are not limited to pure text PDF layout files, mixed text and image PDF layout files and pure image PDF layout files.

Citation Information

Patent Citations

  • PDF academic paper retypesetting system and method based on mobile equipment

    CN109522539A

  • Extracting information from PDF Documents using Black-Box Image Processing

    US20160140145A1