PDF file generation method, device and electronic device
By decomposing the PDF file generation method into a solidified page before the page, a modified page and a reconstructed page after the page, and performing small-domain-wide typesetting and dynamic version judgment, the problem of low efficiency of full-scale typesetting algorithms in the existing technology is solved, and efficient PDF file generation and output is achieved.
Patent Information
- Application Number
- CN202411578764.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-11-07
AI Technical Summary
The existing method of typing and generating PDF files uses a full-scale typing algorithm, which leads to low efficiency and cannot meet the needs of typing and outputting PDFs.
By decomposing the PDF file generation method into a solidified page before the page, the current modified page and the reconstructed page after the page, and performing small-domain-wide layout based on the current modified area, determining whether the dynamic version is active, and automatically recombining the solidified page, the current page and the reconstructed page according to the dynamic version situation.
This greatly improves the layout efficiency, reduces the layout of the entire document into the currently modified area's small domain layout and reorganizes the layout content of pages, blocks, columns, segments, and rows, so as to achieve the need for immediate output.
Smart Images

Figure CN119088769B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of PDF (Portable Document Format) conversion, and in particular to a method, device and electronic equipment for generating a PDF file. Background Art
[0002] At present, most of the existing methods of typesetting and generating PDF files are implemented by full typesetting algorithms. In the actual typesetting process, many additions, modifications, and deletions of content are based on the behavior of the current operation unit, and there is no need to recalculate the entire file for typesetting and outputting PDF. Therefore, the efficiency of full typesetting algorithm output is relatively low and cannot meet the needs of outputting PDF immediately after typesetting. Summary of the invention
[0003] In view of this, the purpose of the present invention is to provide a method, device and electronic device for generating a PDF file, so as to reduce the entire document layout into a small domain layout of the current modification area and reorganize the layout content of pages, blocks, columns, paragraphs and lines, thereby greatly improving the layout efficiency.
[0004] In a first aspect, an embodiment of the present invention provides a method for generating a PDF file, the method comprising: generating a full PDF file and an index file based on units of a target file; wherein the units of the target file include pages, blocks, columns, paragraphs, and lines of the target file; the full PDF file is a combined PDF file in which each unit is an independent PDF page; the index file includes description information of each unit of the target file; when typesetting the target file, obtaining the current modified area position of the target file, decomposing the target file into a front-end solidified page, a current modified page, and a back-end reconstructed page based on the current modified area; determining the front-end solidified page in the index file The page unit description information of the modified page and the page unit PDF corresponding to the front solidified page in the full PDF file are combined and written into a new PDF file; the fixed block of the current modified page in the index file is determined, and the fixed block unit PDF of the current modified page is combined and written into the new PDF file according to the coordinate matrix position based on the layer order in the index file; the typesetting result of the current modified area is obtained, and whether the current modified area is dynamic based on the typesetting result of the current modified area is determined; based on whether the current modified area is dynamic, each unit PDF of the current modified page and each unit PDF of the post-reconstructed page are combined and written into the new PDF file.
[0005] In an optional embodiment of the present application, the above-mentioned index file is used to identify the page where each unit is located, the column corresponding to the page, the coordinate matrix, height, layout connection order, layer order, and unit content type. The index file is also used to assign a unique ID to each unit.
[0006] In an optional embodiment of the present application, the above-mentioned step of decomposing the target file into front-page solidified pages, current modified pages and back-page reconstructed pages based on the current modified area includes: dividing the pages where the current modified area in the target file is located into current modified pages; dividing the pages in the target file with page numbers before the current modified area into front-page solidified pages; dividing the pages in the target file with page numbers after the current modified area into back-page reconstructed pages.
[0007] In an optional embodiment of the present application, after the step of obtaining the current modification area position of the target file when typesetting the target file, the method also includes: responding to the modification of the target paragraph of the current modification area, typesetting the paragraph environment layout of the target paragraph in a small area, and outputting the typesetting result PDF of the current modification area.
[0008] In an optional embodiment of the present application, the above-mentioned step of stitching together the unit PDFs of the current modified page and the unit PDFs of the reconstructed page after the page into a new PDF file based on whether the current modified area is dynamic, includes: if the current modified area does not have a dynamic version, reading the block units, column units, paragraph units, and line units outside the current modified area of the current modified page in the index file, and stitching together the unit PDFs outside the current modified area and the typesetting result PDF of the current modified area into a new PDF file based on the layer order in the index file; determining the page unit description information of the reconstructed page after the page in the index file, and the page unit PDF corresponding to the reconstructed page after the page in the full PDF file, and stitching the page unit PDFs of the reconstructed page after the page into the new PDF file.
[0009] In an optional embodiment of the present application, the above-mentioned step of writing each unit PDF of the current modified page and each unit PDF of the reconstructed page after the page into a PDF file based on whether the current modified area is dynamic, includes: if the current modified area is dynamic, reading the block unit, column unit, paragraph unit, and line unit before the current modified area of the current modified page in the index file, and writing the unit PDF before the current modified area and the typesetting result PDF of the current modified area into a new PDF file based on the layer order in the index file; calculating the dynamic displacement offset according to the typesetting result of the current modified area and the coordinate matrix corresponding to the original current modified area in the index file, and reading Get the column units, paragraph units, and line units after the current modified area of the current modified page in the index file, calculate the coordinate positions of the column units, paragraph units, and line units after the current modified area based on the dynamic version displacement offset, and stitch the unit PDFs after the current modified area into a new PDF file according to the coordinate positions based on the layer order in the index file; read the column units, paragraph units, and line units of the page after the page is reconstructed in the index file, calculate the coordinate positions of the column units, paragraph units, and line units of the page after the page is reconstructed based on the dynamic version displacement offset, and stitch the unit PDFs of the page after the page is reconstructed into a new PDF file according to the coordinate positions based on the layer order in the index file.
[0010] In an optional embodiment of the present application, the above-mentioned step of reading the block units, column units, paragraph units, and line units before the current modification area of the current modification page in the index file includes: based on the principle of rounding up and taking the maximum unit set of lower-level units that cannot be rounded up, reading the block units, column units, paragraph units, and line units before the current modification area of the current modification page in the index file.
[0011] In an optional embodiment of the present application, the above method further includes: merging common items of the new PDF file after deduplication and splicing to obtain a final new PDF file.
[0012] In a second aspect, an embodiment of the present invention further provides a device for generating a PDF file, the device comprising: a full PDF file and index file generation module, which is used to generate a full PDF file and an index file based on the units of a target file; wherein the units of the target file include pages, blocks, columns, paragraphs, and lines of the target file; the full PDF file is a combined PDF file in which each unit is an independent PDF page; the index file includes description information of each unit of the target file; a target file decomposition module, which is used to obtain the current modified area position of the target file when typesetting the target file, and decompose the target file into a solidified page before the page, a current modified page, and a reconstructed page after the page based on the current modified area; a first splicing writing module, which is used to determine The page unit description information of the front-cured page in the index file and the page unit PDF corresponding to the front-cured page in the full PDF file are combined and written into the new PDF file; a second combination writing module is used to determine the fixed block of the current modified page in the index file, and the fixed block unit PDF of the current modified page is combined and written into the new PDF file according to the coordinate matrix position based on the layer order in the index file; a third combination writing module is used to obtain the typesetting result of the current modified area, and determine whether the current modified area is dynamic based on the typesetting result of the current modified area; based on whether the current modified area is dynamic, each unit PDF of the current modified page and each unit PDF of the post-reconstructed page are combined and written into the new PDF file.
[0013] In a third aspect, an embodiment of the present invention further provides an electronic device, including a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the above-mentioned PDF file generation method.
[0014] The embodiments of the present invention bring the following beneficial effects:
[0015] The embodiment of the present invention provides a method, device and electronic device for generating a PDF file, which divides the original typesetting generated PDF into a fixed page, a current page and a reconstructed page, wherein the small domain typesetting is performed for the current paragraph environment of the current page, and the modified content of the current paragraph is judged whether to move the page, and the fixed page, the current page and the reconstructed page are automatically reorganized according to the up and down displacement of the moving page. The entire document typesetting can be reduced to the small domain typesetting of the current modified area and the reorganization of the typeset content of the page, block, column, paragraph and line, which greatly improves the typesetting efficiency.
[0016] Other features and advantages of the present disclosure will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present disclosure.
[0017] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 A flowchart of a method for generating a PDF file provided by an embodiment of the present invention;
[0020] Figure 2 A flowchart of another method for generating a PDF file provided by an embodiment of the present invention;
[0021] Figure 3 A schematic diagram of the structure of a device for generating a PDF file provided by an embodiment of the present invention;
[0022] Figure 4 A schematic diagram of the structure of another device for generating a PDF file provided by an embodiment of the present invention;
[0023] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] At present, most of the existing methods of typesetting and generating PDF files adopt full typesetting algorithms. Among them, full typesetting means that each time a PDF file is generated, the file needs to be uniformly typeset from the beginning to the end.
[0026] In the actual typesetting process, the addition, modification, and deletion of many contents are based on the behavior of the current operation unit, and it is not necessary to recalculate the algorithm for typesetting and outputting PDF for the entire file. Therefore, the efficiency of the full typesetting algorithm output is relatively low and cannot meet the needs of immediate typesetting and output of PDF.
[0027] Based on this, the embodiment of the present invention provides a method, device and electronic device for generating a PDF file, which specifically provides a method for generating PDF by incremental typesetting in a small domain, breaking the concept of full re-typesetting in traditional typesetting methods, and dividing the original typesetting generated PDF into solidified pages, current pages and reconstructed pages, wherein small domain range typesetting is performed for the current paragraph environment of the current page, and whether the modified content of the current paragraph is dynamic, and the solidified page, current page and reconstructed page are automatically reorganized according to the up and down displacement of the dynamic version. The entire document typesetting can be reduced to the small domain typesetting of the current modified area and the reorganization of the typeset content of pages, blocks, columns, paragraphs and lines, greatly improving the typesetting efficiency.
[0028] To facilitate understanding of this embodiment, a method for generating a PDF file disclosed in an embodiment of the present invention is first introduced in detail.
[0029] Embodiment 1:
[0030] The embodiment of the present invention provides a method for generating a PDF file. Figure 1 The flowchart of a method for generating a PDF file is shown in FIG. 1 , and the method for generating a PDF file comprises the following steps:
[0031] Step S102, generating a full PDF file and an index file based on the units of the target file; wherein the units of the target file include pages, blocks, columns, paragraphs, and lines of the target file; the full PDF file is a combined PDF file in which each unit is an independent PDF page; and the index file includes description information of each unit of the target file.
[0032] When the present embodiment typeset and outputs PDF, in addition to normal full-text PDF output, a full PDF file can also be generated by extracting units such as pages, blocks, columns, paragraphs, and lines. The full PDF file is a combined PDF file of all units of the target file in which each unit is an independent PDF page. When forming the combined PDF file of all units, hidden duplicate information is removed for each unit PDF page. The specific method is to use a cropping method to crop the full-text PDF to generate each unit PDF page, parse and extract the common information of the unit PDF page, parse and extract the context description information about the unit on the unit PDF page, such as the font, font size, and font, parse and extract the content information of the unit, and remove other information other than the extracted content on the unit PDF page. In addition, a unit description information XML (Extensible Markup Language) index file corresponding to the full PDF file can also be generated.
[0033] In some embodiments, the above index file is used to identify the page where each unit is located, the column corresponding to the page, the coordinate matrix, height, layout connection order, layer order, and unit content type. The above index file is also used to assign a unique ID to each unit.
[0034] The index file in this embodiment can identify the page where each unit is located, the column corresponding to the page, the coordinate matrix, the height, the layout connection order, the layer order Z-index, the unit content type, and assign a unique ID to each unit.
[0035] Step S104, when typesetting the target file, obtain the current modified area position of the target file, and decompose the target file into a front solidified page, a current modified page and a back reconstructed page based on the current modified area.
[0036] When typesetting a file, this embodiment can decompose the PDF into three parts by page according to the position of the current modification area, including: a solidified page before the page, a current modification page, and a reconstructed page after the page.
[0037] In some embodiments, the page where the current modification area in the target file is located can be divided into the current modification page; the page in the target file before the current modification area can be divided into the front-page solidified page; the page in the target file after the current modification area can be divided into the back-page reconstructed page.
[0038] For example, if the target file includes 10 pages 1-10, and the current modification area is located on page 3, page 3 (i.e., the page where the current modification area is located in the target file) can be divided into the current modification page; pages 1-2 (i.e., the pages in the target file before the current modification area) can be divided into the front-page solidification pages; pages 4-10 (i.e., the pages in the target file after the current modification area) can be divided into the back-page reconstruction pages.
[0039] In some embodiments, in response to the modification of the target paragraph in the current modification area, the paragraph environment layout of the target paragraph can be typeset in a small area, and a typeset result PDF of the current modification area can be output.
[0040] During the typesetting process, the current modification area, such as a typesetting paragraph (i.e., the target paragraph), can be modified. When the modified content is confirmed, this embodiment can reduce the original typesetting for the full text layout to the paragraph environment layout for the modified paragraph, that is, perform small area typesetting. This embodiment can output this paragraph instantly.
[0041] Step S106, determining the page unit description information of the front page in the index file and the page unit PDF corresponding to the front page in the full PDF file, and combining the page unit PDF of the front page into a new PDF file.
[0042] For the page before the page where the current modification area is located (i.e., the solidified page before the page), this embodiment can directly read the corresponding page unit description information in the index file, obtain the page unit PDF in the full PDF file, and directly stitch them into a new PDF file.
[0043] Step S108, determining the fixed block of the current modified page in the index file, and writing the fixed block unit PDF of the current modified page into a new PDF file according to the coordinate matrix position based on the layer order in the index file.
[0044] For the page where the current modification area is located (ie, the current modification page), this embodiment can read the index file to obtain the fixed block unit description information of the current modification page, and directly stitch and write the page into the new PDF file according to the layer order Z-index.
[0045] Step S110, obtaining the layout result of the current modified area, and judging whether the current modified area is dynamic based on the layout result of the current modified area; and combining the unit PDFs of the current modified page and the unit PDFs of the subsequent reconstructed page into a new PDF file based on whether the current modified area is dynamic.
[0046] This embodiment can also determine whether the current region modification results in a dynamic layout based on the typesetting result of the current modified region that is output immediately. The dynamic layout can be understood as a highly inconsistent layout difference between the typesetting result of the current modified region and the typesetting result before the modification.
[0047] Based on whether the current modified area is dynamic, in this embodiment, different methods can be used to combine the unit PDFs of the current modified page and the unit PDFs of the subsequent reconstructed page into a new PDF file.
[0048] The embodiment of the present invention provides a method for generating a PDF file, which divides the original typesetting generated PDF into a fixed page, a current page, and a reconstructed page, wherein the small domain typesetting is performed for the current paragraph environment of the current page, and the modified content of the current paragraph is judged whether to move the page, and the fixed page, the current page and the reconstructed page are automatically reorganized according to the up and down displacement of the moving page. The entire document typesetting can be reduced to the small domain typesetting of the current modified area and the reorganization of the typeset content of the page, block, column, paragraph, and line, which greatly improves the typesetting efficiency.
[0049] Embodiment 2:
[0050] This embodiment provides another method for generating a PDF file. This method is implemented on the basis of the above embodiment. This embodiment focuses on describing the specific steps of writing the current modified page and the subsequent reconstructed page into the PDF file based on whether the current modified area is dynamic. Figure 2 The flowchart of another method for generating a PDF file is shown, and the method for generating a PDF file includes the following steps:
[0051] Step S202, generating a full PDF file and an index file based on the units of the target file; wherein the units of the target file include pages, blocks, columns, paragraphs, and lines of the target file; the full PDF file is a combined PDF file in which each unit is an independent PDF page; and the index file includes description information of each unit of the target file.
[0052] Step S204, when typesetting the target file, the current modified area position of the target file is obtained, and based on the current modified area, the target file is decomposed into a front solidified page, a current modified page and a back reconstructed page.
[0053] Step S206 , determining the page unit description information of the front page in the index file and the page unit PDF corresponding to the front page in the full PDF file, and combining the page unit PDF of the front page into a new PDF file.
[0054] Step S208, determining the fixed block of the current modified page in the index file, and writing the fixed block unit PDF of the current modified page into a new PDF file according to the coordinate matrix position based on the layer order in the index file.
[0055] Step S210, obtaining the typesetting result of the current modified area, and judging whether the current modified area is dynamic based on the typesetting result of the current modified area; and combining the unit PDFs of the current modified page and the unit PDFs of the subsequent reconstructed page into a new PDF file based on whether the current modified area is dynamic.
[0056] In some embodiments, if the current modified area has no dynamic version, the block units, column units, paragraph units, and line units outside the current modified area of the current modified page in the index file are read, and the unit PDF outside the current modified area and the typesetting result PDF of the current modified area are spliced and written into a new PDF file based on the layer order in the index file; the page unit description information of the post-page reconstructed page in the index file and the page unit PDF corresponding to the post-page reconstructed page in the full PDF file are determined, and the page unit PDF of the post-page reconstructed page is spliced and written into the new PDF file.
[0057] If the current modified area has no dynamic version, you can write the current modified page and the next reconstructed page into a new PDF file through steps A1 and A2:
[0058] Step A1, read the block units, column units, paragraph units, and line units outside the current modification area of the current modification page in the index file in sequence, and together with the typesetting result PDF of the current modification area output immediately, directly splice the PDFs of each unit according to the layer order Z-index and write them into the current page of the new PDF file.
[0059] Step A2: For the page following the page where the current modified area is located (i.e., the reconstructed page after the page), since it is not fixed, the corresponding page unit description information in the index file can be directly read to obtain the page unit PDF in the full PDF file, and directly merge and write into the new PDF file.
[0060] In some embodiments, if the current modified area is a dynamic version, the block unit, column unit, paragraph unit, and line unit before the current modified area of the current modified page in the index file are read, and the unit PDF before the current modified area and the typesetting result PDF of the current modified area are spliced and written into a new PDF file based on the layer order in the index file; the typesetting result of the current modified area and the coordinate matrix corresponding to the original current modified area in the index file are determined to calculate the dynamic version displacement offset, the column unit, paragraph unit, and line unit after the current modified area of the current modified page in the index file are read, the coordinate position of the column unit, paragraph unit, and line unit after the current modified area is calculated based on the dynamic version displacement offset, and the unit PDF after the current modified area is spliced and written into the new PDF file according to the coordinate position based on the layer order in the index file; the column unit, paragraph unit, and line unit of the page after the page is reconstructed in the index file are read, the coordinate position of the column unit, paragraph unit, and line unit of the page after the page is reconstructed is calculated based on the dynamic version displacement offset, and the unit PDF of the page after the page is reconstructed is spliced and written into the new PDF file according to the coordinate position based on the layer order in the index file.
[0061] If the current modified area is dynamic, you can write the current modified page and the next reconstructed page into a new PDF file through steps B1 to B3:
[0062] Step B1, sequentially read the block unit, column unit, paragraph unit, and line unit before the current modification area of the current modification page in the index file, and directly write them into the current page of the new PDF file together with the current modification area unit output in real time according to the layer order Z-index.
[0063] In some embodiments, based on the principle of rounding up and taking the maximum unit set of lower-level units that cannot be rounded up, the block units, column units, paragraph units, and line units before the current modified area of the current modified page in the index file can be read.
[0064] For the three units of column, paragraph and line, the specific reading method in this embodiment can be the principle of the largest unit set: round up, and take the lower level unit if it cannot be rounded. For example, when the whole paragraph can be arranged in translation, the paragraph is directly taken. When the paragraph cannot be arranged as a whole, such as when turning columns or pages, all the line units contained in the paragraph are read. The purpose of the above reading method is to obtain the optimal reading and writing efficiency.
[0065] Step B2, determine the upper and lower dynamic plate displacement offset caused by the modification of the current modification area of the current modification page, read the column unit, paragraph unit, and line unit after the current modification area of the current modification page in the index file in sequence, recalculate the coordinate position, and directly splice and write this page of the new PDF file according to the layer order Z-index.
[0066] Step B3, for the page behind the page where the current modification area is located (i.e., the reconstructed page after the page), according to the up and down dynamic displacement offset caused by the dynamic version, read the column unit, paragraph unit, and line unit associated with the reconstructed page after the page in the index file in sequence, recalculate the coordinate position, directly reconstruct according to the layer order Z-index, and write them into the new PDF file.
[0067] Step S212, merging the common items of the new PDF file after deduplication and splicing to obtain a final new PDF file.
[0068] For the complete new PDF file, this embodiment can also merge and eliminate duplicate common items, including removing repeated references to common information after the unit PDF pages are spliced together, merging and reducing context description information such as font size and font style, etc., thereby reducing the size of the new PDF file and generating the final new PDF file.
[0069] The above method of the embodiment of the present invention specifically provides a method for generating PDF by incremental typesetting in a small domain, breaking the concept of full re-typesetting in traditional typesetting methods, and dividing the original typesetting generated PDF into fixed pages, current pages, and reconstructed pages, wherein small domain range typesetting is performed for the current paragraph environment of the current page, and whether the modified content of the current paragraph is dynamic is determined, and the fixed page, current page, and reconstructed page are automatically reorganized according to the up and down displacement of the dynamic version. The entire document typesetting can be reduced to the small domain typesetting of the current modified area and the reorganization of the typeset content of pages, blocks, columns, paragraphs, and rows, greatly improving the typesetting efficiency.
[0070] Embodiment three:
[0071] Corresponding to the above method embodiment, the present invention provides a device for generating a PDF file, see Figure 3 A schematic diagram of the structure of a device for generating a PDF file is shown, and the device for generating a PDF file includes:
[0072] The full PDF file and index file generating module 31 is used to generate a full PDF file and an index file based on the units of the target file; wherein the units of the target file include pages, blocks, columns, paragraphs, and lines of the target file; the full PDF file is a combined PDF file in which each unit is an independent PDF page; the index file includes description information of each unit of the target file;
[0073] The target file decomposition module 32 is used to obtain the current modified area position of the target file when typesetting the target file, and decompose the target file into a front page solidified page, a current modified page and a back page reconstructed page based on the current modified area;
[0074] A first splicing and writing module 33 is used to determine the page unit description information of the pre-cured page in the index file and the page unit PDF corresponding to the pre-cured page in the full PDF file, and splice the page unit PDF of the pre-cured page into a new PDF file;
[0075] A second splicing and writing module 34 is used to determine the fixed block of the current modified page in the index file, and splice the fixed block unit PDF of the current modified page into a new PDF file according to the coordinate matrix position based on the layer order in the index file;
[0076] The third splicing and writing module 35 is used to obtain the typesetting result of the current modified area, and determine whether the current modified area is dynamic based on the typesetting result of the current modified area; based on whether the current modified area is dynamic, the unit PDFs of the current modified page and the unit PDFs of the subsequent reconstructed page are spliced and written into a new PDF file.
[0077] The embodiment of the present invention provides a device for generating a PDF file, which divides the original typesetting generated PDF into a fixed page, a current page, and a reconstructed page, wherein the small domain typesetting is performed for the current paragraph environment of the current page, and the modified content of the current paragraph is judged whether to move the page, and the fixed page, the current page and the reconstructed page are automatically reorganized according to the up and down displacement of the moving page. The entire document typesetting can be reduced to the small domain typesetting of the current modified area and the reorganization of the typeset content of the page, block, column, paragraph, and line, which greatly improves the typesetting efficiency.
[0078] The above index file is used to identify the page where each unit is located, the column corresponding to the page, the coordinate matrix, the height, the layout connection order, the layer order, and the unit content type. The index file is also used to assign a unique ID to each unit.
[0079] The above-mentioned target file decomposition module is used to divide the page where the current modification area in the target file is located into the current modification page; divide the page in the target file before the current modification area into the front-page solidified page; and divide the page in the target file after the current modification area into the back-page reconstructed page.
[0080] See also Figure 4 The schematic diagram of the structure of another device for generating a PDF file is shown, and the device for generating a PDF file also includes: a current modification area layout module 36, which is used to respond to the modification of the target paragraph in the current modification area, perform small area layout on the paragraph environment layout of the target paragraph, and output the layout result PDF of the current modification area.
[0081] The third splicing and writing module is used to read the block units, column units, paragraph units, and line units outside the current modified area of the current modified page in the index file if there is no dynamic version in the current modified area, and splice the unit PDF outside the current modified area and the typesetting result PDF of the current modified area into a new PDF file based on the layer order in the index file; determine the page unit description information of the post-page reconstructed page in the index file, and the page unit PDF corresponding to the post-page reconstructed page in the full PDF file, and splice the page unit PDF of the post-page reconstructed page into the new PDF file.
[0082] The third splicing and writing module is used to read the block unit, column unit, paragraph unit, and line unit before the current modification area of the current modification page in the index file if the current modification area is dynamic, and splice the unit PDF before the current modification area and the typesetting result PDF of the current modification area into a new PDF file based on the layer order in the index file; calculate the dynamic version displacement offset according to the typesetting result of the current modification area and the coordinate matrix corresponding to the original current modification area in the index file, read the column unit, paragraph unit, and line unit after the current modification area of the current modification page in the index file, calculate the coordinate position of the column unit, paragraph unit, and line unit after the current modification area based on the dynamic version displacement offset, and splice the unit PDF after the current modification area into a new PDF file according to the coordinate position based on the layer order in the index file; read the column unit, paragraph unit, and line unit of the page after the page is reconstructed in the index file, calculate the coordinate position of the column unit, paragraph unit, and line unit of the page after the page is reconstructed based on the dynamic version displacement offset, and splice the unit PDF of the page after the page is reconstructed according to the coordinate position based on the layer order in the index file.
[0083] The third splicing and writing module is used to read the block unit, column unit, paragraph unit and line unit before the current modified area of the current modified page in the index file based on the principle of rounding up and taking the maximum unit set of the lower-level unit if rounding is not possible.
[0084] like Figure 4 As shown, the PDF file generation device also includes: a common item merging and deduplication module 37, which is used to merge and deduplication the common items of the new PDF file written after splicing and writing to obtain a final new PDF file.
[0085] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device for generating a PDF file described above can refer to the corresponding process in the embodiment of the aforementioned method for generating a PDF file, and will not be repeated here.
[0086] Embodiment 4:
[0087] The embodiment of the present invention also provides an electronic device for executing the above-mentioned PDF file generation method; see Figure 5 A structural schematic diagram of an electronic device is shown, the electronic device includes a memory 100 and a processor 101, wherein the memory 100 is used to store one or more computer instructions, and the one or more computer instructions are executed by the processor 101 to implement the above-mentioned PDF file generation method.
[0088] Further, Figure 5 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 101 , the communication interface 103 and the memory 100 are connected via the bus 102 .
[0089] The memory 100 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0090] The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 101. The above processor 101 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100 and completes the steps of the method of the above embodiment in combination with its hardware.
[0091] An embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned PDF file generation method. The specific implementation can be found in the method embodiment, which will not be repeated here.
[0092] The PDF file generation method, device and computer program product of the electronic device provided in the embodiments of the present invention include a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the method in the previous method embodiment. The specific implementation can be referred to the method embodiment, which will not be repeated here.
[0093] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and / or device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0094] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0095] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0096] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0097] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A method for generating a PDF file, characterized in that: The method comprises: Generate a full PDF file and an index file based on the units of the target file; wherein the units of the target file include pages, blocks, columns, paragraphs, and lines of the target file; the full PDF file is a combined PDF file in which each of the units is an independent PDF page; the index file includes description information of each unit of the target file; When typesetting the target file, the current modified area position of the target file is obtained, and based on the current modified area, the target file is decomposed into a front solidified page, a current modified page, and a back reconstructed page by page; Determine the page unit description information of the pre-cured page in the index file and the page unit PDF corresponding to the pre-cured page in the full PDF file, and combine the page unit PDF of the pre-cured page into a new PDF file; Determine the fixed block of the current modified page in the index file, and write the fixed block unit PDF of the current modified page into the new PDF file according to the coordinate matrix position based on the layer order in the index file; Obtaining the typesetting result of the current modified area, and judging whether the current modified area is dynamic based on the typesetting result of the current modified area; and combining the unit PDFs of the current modified page and the unit PDFs of the subsequent reconstructed page into the new PDF file based on whether the current modified area is dynamic; The step of decomposing the target file into front-page solidified pages, current modified pages and back-page reconstructed pages based on the current modified area includes: dividing the pages in the target file where the current modified area is located into current modified pages; dividing the pages in the target file whose page numbers are before the current modified area into front-page solidified pages; dividing the pages in the target file whose page numbers are after the current modified area into back-page reconstructed pages.
2. The method according to claim 1, characterized in that The index file is used to identify the page where each unit is located, the column corresponding to the page, the coordinate matrix, the height, the layout connection order, the layer order, and the unit content type. The index file is also used to assign a unique ID to each unit.
3. The method according to claim 1, characterized in that When the target file is typesetting, after the step of obtaining the position of the current modified area of the target file, the method further includes: In response to the modification of the target paragraph in the current modification area, small-area typeset is performed on the paragraph environment layout of the target paragraph, and a typeset result PDF of the current modification area is output.
4. The method according to claim 1, characterized in that: The step of combining and writing each unit PDF of the current modified page and each unit PDF of the subsequent reconstructed page into the new PDF file based on whether the current modified area is dynamic, comprises: If the current modified area has no dynamic version, read the block unit, column unit, paragraph unit, and line unit outside the current modified area of the current modified page in the index file, and merge the unit PDF outside the current modified area and the typesetting result PDF of the current modified area into the new PDF file based on the layer order in the index file; Determine the page unit description information of the post-page reconstruction page in the index file and the page unit PDF corresponding to the post-page reconstruction page in the full PDF file, and combine the page unit PDF of the post-page reconstruction page into the new PDF file.
5. The method according to claim 1, characterized in that The step of combining and writing each unit PDF of the current modified page and each unit PDF of the subsequent reconstructed page into the PDF file based on whether the current modified area is dynamic, comprises: If the current modified area is dynamic, read the block unit, column unit, paragraph unit, and line unit before the current modified area of the current modified page in the index file, and combine the unit PDF before the current modified area and the typesetting result PDF of the current modified area into the new PDF file based on the layer order in the index file; The dynamic version displacement offset is calculated according to the typesetting result of the current modified area and the coordinate matrix corresponding to the original current modified area in the index file, the column unit, the paragraph unit, and the line unit after the current modified area of the current modified page in the index file are read, the coordinate position of the column unit, the paragraph unit, and the line unit after the current modified area is calculated based on the dynamic version displacement offset, and the unit PDF after the current modified area is stitched and written into the new PDF file according to the coordinate position based on the layer order in the index file; The column units, paragraph units, and line units of the reconstructed page after the page in the index file are read, the coordinate positions of the column units, paragraph units, and line units of the reconstructed page after the page are calculated based on the dynamic version displacement offset, and the unit PDFs of the reconstructed page after the page are stitched together according to the coordinate positions and written into the new PDF file based on the layer order in the index file.
6. The method according to claim 5, characterized in that The step of reading the block unit, column unit, paragraph unit, and line unit before the current modification area of the current modification page in the index file comprises: Based on the principle of rounding up and taking the maximum unit set of lower-level units that cannot be rounded up, the block unit, column unit, paragraph unit, and line unit before the current modified area of the current modified page in the index file are read.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: The common items of the new PDF files written after deduplication and splicing are merged to obtain the final new PDF file.
8. A device for generating a PDF file, characterized in that: The device comprises: A full PDF file and index file generation module, used to generate a full PDF file and an index file based on the units of the target file; wherein the units of the target file include pages, blocks, columns, paragraphs, and lines of the target file; the full PDF file is a combined PDF file in which each of the units is an independent PDF page; the index file includes description information of each unit of the target file; A target file decomposition module is used to obtain the current modified area position of the target file when typesetting the target file, and decompose the target file into a front page solidified page, a current modified page and a back page reconstructed page based on the current modified area; A first splicing and writing module is used to determine the page unit description information of the pre-cured page in the index file and the page unit PDF corresponding to the pre-cured page in the full PDF file, and splice the page unit PDF of the pre-cured page into a new PDF file; A second splicing and writing module is used to determine the fixed block of the current modified page in the index file, and splice and write the fixed block unit PDF of the current modified page into the new PDF file according to the coordinate matrix position based on the layer order in the index file; A third splicing and writing module is used to obtain the typesetting result of the current modified area, determine whether the current modified area is dynamic based on the typesetting result of the current modified area; and splice each unit PDF of the current modified page and each unit PDF of the subsequent reconstructed page into the new PDF file based on whether the current modified area is dynamic; The target file decomposition module is used to divide the page in the target file where the current modification area is located into the current modification page; divide the page in the target file whose page number is before the current modification area into the front-page solidified page; and divide the page in the target file whose page number is after the current modification area into the back-page reconstructed page.
9. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method for generating a PDF file according to any one of claims 1 to 7.
Citation Information
Patent Citations
PDF file generation method, computer equipment and readable storage medium
CN111090980A
PDF document generation method and device and electronic equipment
CN111881650A