Method and device for generating electronic certificates
By parsing and processing electronic certificate templates in memory, generating and compressing page content description files, the problems of large storage space and slow generation speed in traditional methods are solved, achieving more efficient electronic certificate generation.
Patent Information
- Application Number
- CN202210553027.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-20
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2042-05-20
AI Technical Summary
Traditional methods for generating electronic certificates require a large amount of storage space, involve numerous disk read/write operations, and generate large amounts of data, resulting in slow generation speeds.
The intermediate file is obtained by parsing the preset electronic certificate template. The intermediate file is stored in memory in the form of a data stream. Business metadata is obtained and the layout is performed according to the attribute information of the graphic object. The page content description file is generated and compressed using the Deflate algorithm to finally generate the electronic certificate file.
It reduces storage space usage, increases generation speed, and ensures the security of the electronic certificate generation process.
Smart Images

Figure CN114998464B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of electronic certificate technology, specifically relating to an electronic certificate generation method and apparatus. Background Technology
[0002] Electronic certificates refer to various legally valid documents such as certificates, proofs, approvals, appraisal reports, and service results issued by various entities in accordance with the law, including ID cards, marriage certificates, bank repayment statements, and business licenses. The traditional OFD (Open Fixed-layout Document) electronic certificate generation method involves setting a certificate template file, obtaining business data, matching the business data with the certificate template file, parsing the template file after a match, combining the parsed data with the business data to obtain formatted data, and writing the formatted data into the content description file of the OFD file structure. The electronic certificate is then generated based on the content description file of the OFD file structure. However, this method requires re-parsing the certificate template every time an electronic certificate is generated, even for the same type. Figure 1 Each electronic certificate template contains a background image, resulting in a large storage space usage. Furthermore, each file in the OFD file structure is stored in a local directory, and the files in that directory are then ZIP packaged into an electronic certificate. This leads to numerous disk read / write operations and a large amount of data, ultimately resulting in a slow overall electronic certificate generation speed. Summary of the Invention
[0003] To overcome, to some extent, the problems of traditional methods for generating electronic certificates, such as large storage space requirements, numerous disk read / write operations, large amounts of data read / write, and slow overall electronic certificate generation speed, this application provides an electronic certificate generation method and apparatus.
[0004] Firstly, this application provides a method for generating electronic certificates, including:
[0005] An intermediate file is obtained by parsing a preset electronic certificate template. The intermediate file is stored in memory in the form of a data stream. The intermediate file includes the data item names and graphic object attribute information corresponding to the preset electronic certificate template.
[0006] Obtain business metadata, and parse the business metadata to obtain the data content corresponding to the data item name;
[0007] The data content is arranged according to the attribute information of the graphic element object to obtain a page content description file;
[0008] The page content description file is added to the intermediate file to generate the electronic certificate file.
[0009] Furthermore, the process of parsing the preset electronic certificate template to obtain intermediate files includes:
[0010] The preset electronic certificate template is parsed to obtain variable photo metadata and non-variable photo metadata. The variable photo metadata includes at least one of variable text, variable photo and variable table content. The non-variable photo metadata includes at least one of certificate background image, fixed photo text and fixed table.
[0011] The immutable metadata items are stored in the template page description file;
[0012] The variable metadata items are stored in the content description file of the specified page;
[0013] An intermediate file is obtained based on the template page description file and the content description file of the specified page.
[0014] Furthermore, the template page description file also includes:
[0015] A text object, which is used to describe the text information in the immutable metadata item, includes at least one of the following: the bounding rectangle of the text box, the primitive transformation matrix, the text object ID, and font and font size information;
[0016] An image object, which describes the image information in the immutable metadata item, includes at least one of the following: the bounding rectangle of the image, a primitive transformation matrix, an image object ID, and a resource ID;
[0017] A graphic object, which is used to describe the graphic information in the immutable metadata item, includes at least one of the following: the bounding rectangle of the graphic object, the primitive transformation matrix, whether it has an outline, the outline color, whether it is filled, the graphic fill rule, and the fill color.
[0018] Furthermore, the data item names corresponding to the preset electronic certificate template include:
[0019] Custom index data item name and certificate image style metadata name, wherein the custom index data item name is consistent with the certificate image style metadata name;
[0020] The index ID corresponding to the custom index data item is the corresponding primitive object ID in the page content description file;
[0021] The step of parsing the business metadata to obtain the data content corresponding to the data item name includes:
[0022] The business metadata is parsed into certificate metadata names and data content, and the certificate metadata names and data content are stored in an array structure of key-value pairs, wherein the certificate metadata names correspond to the certificate image style metadata names;
[0023] The data content corresponding to the certificate metadata name is used as the data content corresponding to the data item name based on the key-value pair.
[0024] Furthermore, the step of formatting the data content according to the attribute information of the graphic element object to obtain a page content description file includes:
[0025] Based on the corresponding graphic element object attributes, select the appropriate font, font size and display area information to format the data content of the business metadata;
[0026] According to the OFD file standard, the typeset graphic element information is saved in the page description file of the specified page.
[0027] Furthermore, the step of selecting appropriate fonts, font sizes, and display area information to format the data content of the business metadata based on the corresponding graphic element object attributes includes:
[0028] When the metadata content is text-based graphic elements, the required number of lines is calculated based on the text attributes, such as font, font size, and the bounding rectangle information of the display area.
[0029] The required display height is calculated based on the calculated number of lines and the font size.
[0030] If the calculated required display height is greater than the height of the display area, reduce the font size by a preset number of pixels and recalculate until all the text can be displayed.
[0031] Furthermore, the step of adding the page content description file to the intermediate file to generate the electronic certificate file includes:
[0032] The Deflate algorithm is used to compress the page content description file containing the typeset graphic element information;
[0033] Add the compressed page content description file to the intermediate file;
[0034] Based on the template page description file of the intermediate file and the content description file of the specified page containing the typed graphic element information, generate an electronic certificate file with a background image or an electronic certificate file without a background image.
[0035] Furthermore, the compression of the page content description file containing the typeset primitive information using the Deflate algorithm includes:
[0036] Generate compressed file data of the page content description for the corresponding page and obtain the length of the compressed file data of the page content description;
[0037] According to the ZIP format standard, the file header data is generated by concatenating the file header identifier, compression method, file modification time, file size before compression, file size after compression, file name length, and file name information in sequence.
[0038] Search backwards from the end of the intermediate file for the central directory end marker to obtain the central directory offset position;
[0039] The intermediate file is split from the offset position of the central directory to obtain the file data part of the intermediate file and the central directory part of the intermediate file;
[0040] According to the ZIP format standard, the central directory identifier, the size of the file after compression, the size of the file before compression, the file name length, the file header offset position, and the file name information are concatenated in sequence to generate the central directory data of the compressed data;
[0041] The intermediate file data, file header data, page content description file compressed data, central directory data of compressed data, and central directory of intermediate files are concatenated in sequence.
[0042] Modify the central directory parameters to complete file compression.
[0043] Furthermore, it also includes:
[0044] When reading or printing electronic certificates, you can add the certificate image to the electronic certificate file;
[0045] or,
[0046] Using a dedicated electronic certificate reader, the background images of various types of certificates embedded in the reader are used to render the electronic certificates containing the background images.
[0047] or,
[0048] Write the abstract of the certificate's base image file into the signature file corresponding to the OFD document structure container to complete the electronic signature of the OFD electronic certificate file without the base image.
[0049] Secondly, this application provides an electronic certificate generation device, comprising:
[0050] The first parsing module is used to parse the preset electronic certificate template to obtain an intermediate file. The intermediate file is stored in memory in the form of a data stream and includes the data item name and graphic object attribute information corresponding to the preset electronic certificate template.
[0051] The second parsing module is used to obtain business metadata and parse the business metadata to obtain the data content corresponding to the data item name;
[0052] The layout module is used to layout the data content according to the attribute information of the graphic object to obtain a page content description file;
[0053] The generation module is used to add the page content description file to the intermediate file to generate electronic certificate files.
[0054] The technical solutions provided by the embodiments of this application may include the following beneficial effects:
[0055] The present invention provides an electronic certificate generation method and apparatus. The electronic certificate generation method includes parsing a preset electronic certificate template to obtain an intermediate file, the intermediate file being stored in memory in the form of a data stream, and the intermediate file including data item names and graphic object attribute information corresponding to the preset electronic certificate template; obtaining business metadata, parsing the business metadata to obtain data content corresponding to the data item names; formatting the data content according to the graphic object attribute information to obtain a page content description file; and adding the page content description file to the intermediate file to generate an electronic certificate file. This method only requires parsing the same type of certificate template file once to retain the intermediate file, and then repeatedly generating electronic certificate files of the same type using the intermediate file, reducing space usage. Furthermore, parsing and processing are performed in memory, eliminating the need for multiple disk reads and writes, which not only improves the speed of electronic certificate generation but also ensures the security of the electronic certificate file generation process.
[0056] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0057] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0058] Figure 1 This is a flowchart illustrating an electronic certificate generation method provided in one embodiment of this application.
[0059] Figure 2 A flowchart of an electronic certificate generation method provided in another embodiment of this application.
[0060] Figures 3-8 This is a diagram of the OFD file structure during the electronic certificate generation process, provided as an embodiment of this application.
[0061] Figure 9 This is a functional structure diagram of an electronic certificate generation device provided in one embodiment of this application. Detailed Implementation
[0062] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be described in detail below. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other implementation methods obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0063] Figure 1 A flowchart of an electronic certificate generation method provided in one embodiment of this application is shown below. Figure 1 As shown, the method for generating electronic certificates includes:
[0064] S11: Parse the preset electronic certificate template to obtain an intermediate file. The intermediate file is stored in memory in the form of a data stream. The intermediate file includes the data item names and graphic object attribute information corresponding to the preset electronic certificate template.
[0065] S12: Obtain business metadata and parse the business metadata to obtain the data content corresponding to the data item name;
[0066] S13: Arrange the data content according to the attribute information of the graphic element object to obtain the page content description file;
[0067] S14: Add the page content description file to the intermediate file to generate the electronic certificate file.
[0068] The traditional OFD (Off-Demand File) electronic certificate generation method involves setting a certificate template file, acquiring business data, matching the business data with the certificate template file, parsing the template file after a match is found, combining the parsed data with the business data to obtain formatted data, and writing the formatted data into a content description file within the OFD file structure. The electronic certificate is then generated based on the content description file. However, this method requires re-parsing the certificate template every time an electronic certificate is generated, even for the same type. Figure 1 Each electronic certificate template contains a background image, resulting in a large storage space usage. Furthermore, each file in the OFD file structure is stored in a local directory, and the files in that directory are then ZIP packaged into an electronic certificate. This leads to numerous disk read / write operations and a large amount of data, ultimately resulting in a slow overall electronic certificate generation speed.
[0069] In this embodiment, the electronic certificate generation method includes parsing a preset electronic certificate template to obtain an intermediate file. The intermediate file is stored in memory as a data stream and includes data item names and graphic object attribute information corresponding to the preset electronic certificate template; acquiring business metadata and parsing the business metadata to obtain data content corresponding to the data item names; formatting the data content according to the graphic object attribute information to obtain a page content description file; and adding the page content description file to the intermediate file to generate an electronic certificate file. This method only requires parsing the same type of certificate template file once to repeatedly generate electronic certificate files of the same type, reducing space usage. Furthermore, all files are parsed and processed in memory, eliminating the need for multiple disk reads and writes. This not only improves the speed of electronic certificate generation but also ensures the security of the electronic certificate file generation process.
[0070] Figure 2 A flowchart of an electronic certificate generation method provided in another embodiment of this application is shown below. Figure 2 As shown, the method for generating electronic certificates includes:
[0071] S201: Parse the preset electronic certificate template to obtain variable photo metadata and non-variable photo metadata;
[0072] In some embodiments, variable image metadata includes, but is not limited to, variable text, variable photographs, and variable table content;
[0073] In some embodiments, immutable photo metadata includes, but is not limited to, photo background images, fixed text on the photo, and fixed tables;
[0074] S202: Store immutable metadata items in the template page description file;
[0075] S203: Store variable metadata items in the content description file of the specified page;
[0076] Generate intermediate files for OFD electronic certificate templates in memory. The files required to be generated within the OFD document structure container include at least:
[0077] Main entry file, document directory, page directory, resource files, template directory, template page files, and custom index files.
[0078] In some embodiments, the template page description file also includes:
[0079] A text object is used to describe the text information in the immutable metadata item. The text object includes the bounding rectangle of the text box, the primitive transformation matrix, the text object ID, and font and font size information, etc.
[0080] An image object is used to describe the image information in the immutable metadata item. The image object includes the bounding rectangle of the image, the primitive transformation matrix, the image object ID, and the resource ID, etc.
[0081] A graphic object is used to describe the graphic information in the immutable metadata item. The graphic object includes the bounding rectangle of the graphic object, the primitive transformation matrix, whether it has an outline, the outline color, whether it is filled, the graphic fill rule, and the fill color, etc.
[0082] In the specified page content description file, describe the variable photo metadata defined in the electronic certificate style file to obtain the properties of the variable primitive object.
[0083] The names of each data item in the custom index file can be the names of the variable metadata items of the certificate style, and indicate the ID information of the referenced primitive objects.
[0084] S204: Obtain intermediate files based on the template page description file and the content description file of the specified page.
[0085] In this embodiment, the intermediate file is stored in memory in the form of a data stream. The intermediate file includes the data item name and graphic object attribute information corresponding to the preset electronic certificate template.
[0086] The data item names corresponding to the preset electronic certificate template include:
[0087] Custom index data item name and certificate image style metadata name, wherein the custom index data item name is consistent with the certificate image style metadata name;
[0088] The index ID corresponding to the custom index data item is the corresponding graphic object ID in the page content description file.
[0089] The electronic certificate template file is parsed, and based on the background image information, metadata item names, bounding rectangles, positions and sizes, etc., described in the template file, an OFD electronic certificate template intermediate file is generated in memory.
[0090] In the document structure container of the aforementioned OFD electronic certificate template intermediate file, the "template page" file in the OFD document structure container describes immutable graphic elements (such as background images, fixed text, fixed tables, etc.) in the electronic certificate style template file; the content description file of the specified page describes variable graphic elements (such as photos, variable text, table content, and other certificate metadata passed in from the business system), but the content description file of the specified page is not packaged into the specified page directory of the OFD document structure container; the aforementioned "template page" file contains certificate background image description information, but the certificate background image data is not packaged into the OFD document structure container resource directory; the OFD document structure container contains a custom index data file, and the certificate image metadata name corresponds to the data item name of the custom index.
[0091] S205: Obtain business metadata, parse the business metadata into certificate metadata name and data content, and store the certificate metadata name and data content in an array structure of key-value pairs, where the certificate metadata name corresponds to the certificate image style metadata name;
[0092] In some embodiments, the business metadata is passed in by the business system.
[0093] S206: Use the data content corresponding to the certificate metadata name as the data content corresponding to the data item name based on the key-value pair;
[0094] S207: Based on the corresponding graphic element object attributes, select the appropriate font, font size, and display area information to format the data content of the business metadata;
[0095] In some embodiments, the data content of the business metadata is formatted by selecting appropriate font, font size, and display area information based on the corresponding primitive object attributes, including:
[0096] S2071: When the metadata content is textual primitives, calculate the required number of lines based on the text attributes, such as font, font size, and the bounding rectangle information of the display area;
[0097] S2072: Calculate the required display height based on the calculated number of rows and font size;
[0098] S2073: If the calculated required display height is greater than the height of the display area, reduce the font size by a preset number of pixels and recalculate until all the text can be displayed.
[0099] For example, to calculate the required number of rows n line ;n line =(w f ×n text ) / w show , where n lineTo determine the number of lines of text needed to arrange within the display area, w f For text size, n text w represents the length of the text content. show The width of the display area;
[0100] The required display height h is calculated based on the calculated number of rows and the font size.
[0101] h = h f ×n line
[0102] h is the display height required when using the current font size. f For text size, n line To calculate the number of rows;
[0103] If the calculated required display height is greater than the height of the display area, it means that the current font size cannot arrange all the text in the display area. Reduce the font size by 1 pixel and recalculate until all the text can be displayed.
[0104] Generate a new OFD content description file stream for the specified page. The formatted text description information, including text content, font, font size, color, display area, and text offset within the display area, is then formatted into a new page description file stream according to the OFD Text Object Description Language.
[0105] S208: According to the OFD file standard, save the typed graphic element information in the page description file of the specified page;
[0106] S209: Use the Deflate algorithm to compress the page content description file containing typesetting primitive information;
[0107] In this embodiment, the Deflate algorithm is used to compress the page content description file containing the typeset primitive information, including:
[0108] S2091: Generate compressed file data of page content description for the corresponding page and obtain the length of compressed file data of page content description;
[0109] S2092: According to the ZIP format standard, the file header data is generated by concatenating the file header identifier, compression method, file modification time, file size before compression, file size after compression, file name length, and file name information in sequence.
[0110] S2093: Search backwards from the end of the intermediate file for the central directory end marker to obtain the central directory offset position;
[0111] S2094: Split the intermediate file from the offset position of the central directory to obtain the file data part and the central directory part of the intermediate file;
[0112] S209: According to the ZIP format standard, the central directory identifier, the size of the file after compression, the size of the file before compression, the file name length, the file header offset position, and the file name information are concatenated in sequence to generate the central directory data of the compressed data;
[0113] S2095: Concatenate the intermediate file data, file header data, page content description file compressed data, central directory data of compressed data, and central directory of intermediate files in sequence;
[0114] S2096: Modify the central directory parameter information to complete file compression.
[0115] Add the page content description file stream to the OFD electronic certificate template's intermediate file stream. Add the file stream by directly modifying the OFD file stream in memory. Generate the corresponding file data according to the ZIP format standard, add the file data to the template file stream, and modify the relevant ZIP file attributes. Avoid the time-consuming method of decompressing the OFD electronic certificate template's intermediate file stream, adding the file, and then compressing it.
[0116] The page content description file stream is compressed using the Deflate algorithm to generate compressed file data. file And obtain the length n of the compressed data. compress ;
[0117] Based on the ZIP format standard, generate the compressed data header information for the page content description file. The header data (Data) is generated by sequentially concatenating information such as the header identifier, compression method, file modification time, file size before compression, file size after compression, filename length, and filename. haed ;
[0118] Data head =Data headsign +n method +n uncompress +n compress +n name +Data name
[0119] Data haed For the concatenated header data, Data headsign The file header identifier is a fixed value 0x04034b50, n method Compression mode 8 indicates that the Deflate algorithm is used for compression, n uncompress n is the length of the file data before compression. compressn is the length of the compressed file data. name Data is the filename length. name For filenames;
[0120] From the end of the OFD electronic certificate template intermediate file stream, reverse the search to find the central directory end marker and obtain the central directory offset position n. offset The certificate template file stream is split from the central directory offset position, into the file data portion (Data) of the certificate template file. srcdir Data in the central directory section of the certificate template file srcfile ;
[0121] Based on the ZIP format standard, generate the central directory information of the compressed file describing the page content. Concatenate the central directory identifier, compressed file size, uncompressed file size, filename length, file header offset, and filename in sequence to form the central directory data for this compressed data.
[0122] Data dir =Data dirsign +n uncompress +n compress +n name +n offset +Data name
[0123] Data dir For the concatenated central directory data, Data dirsign The central directory identifier is a fixed value 0x02014b50, n uncompress n is the length of the file data before compression. compress n is the length of the compressed file data. name Data is the filename length. name For filename, n offset The offset position of the file header in the compressed data of the page content description file is the central directory offset in the intermediate file stream of the OFD electronic certificate template;
[0124] S210: Add the compressed page content description file to the intermediate file, including:
[0125] The OFD electronic certificate file stream (Data) is constructed by concatenating the header data of the original OFD electronic certificate template intermediate file data, the header data of the page content description file compressed data, the central directory data of the page content description file compressed data, and the central directory data of the original OFD electronic certificate template intermediate file data in that order. result ;
[0126] Data result =Datasrcfile +Data head +Data file +Data dir +Data srcdir
[0127] Data result For the generated OFD electronic certificate file stream, Data srcfile For the intermediate file data section of the OFD electronic certificate template, Data head The header data of the compressed data file describing the page content, Data dir Data is the compressed file data describing the page content. srcdir The page content describes the central directory information for the compressed data of the file. file Central directory data for intermediate files of OFD electronic certificate templates;
[0128] Modify the central directory start offset in the directory end information to the original central directory start offset plus the length of the new file's header data and compressed data;
[0129] Modify the total number of central directories and the number of central directories on the disk in the directory end information to the original number of central directories plus 1;
[0130] Modify the total size of the central directory in the directory end information to the original total size of the central directory plus the length of the central directory data in the new file data.
[0131] If the OFD certificate document has multiple pages of content description files that need to be written, repeat the above process.
[0132] By adding compressed page content description file data to the central directory offset of the OFD electronic certificate template's intermediate file stream, both the file data portion and the central directory information portion are merged. This eliminates the need to separate the central directory data from the directory end data in the OFD electronic certificate template's intermediate file stream, reducing file operations and improving efficiency.
[0133] S211: Generate an electronic certificate file with a base map or an electronic certificate file without a base map based on the template page description file of the intermediate file and the content description file of the specified page containing the layout element information.
[0134] If you need to generate electronic certificates with a background image, you can add the certificate background image file stream to the OFD electronic certificate template intermediate file here.
[0135] OFD electronic certificate files without a certificate background image can reduce the storage space of electronic certificate files; only a new content description file for the specified page needs to be generated, compressed and added to the intermediate file of the OFD electronic certificate template copied in memory, which reduces the file generation and processing time; all file streams are processed in memory, reducing the number of disk read and write operations, and ultimately improving the overall speed of electronic certificate file generation.
[0136] In some embodiments, it also includes:
[0137] When reading or printing electronic certificates, you can add the certificate image to the electronic certificate file;
[0138] or,
[0139] Using a dedicated electronic certificate reader, the background images of various types of certificates embedded in the reader are used to render the electronic certificates containing the background images.
[0140] or,
[0141] Write the abstract of the certificate's base image file into the signature file corresponding to the OFD document structure container to complete the electronic signature of the OFD electronic certificate file without the base image.
[0142] When using OFD electronic certificates, to perform batch electronic signatures, simply write the summary of the certificate's underlying image file into the signature file corresponding to the OFD document structure container before signing. For reading or printing with the underlying image, simply add the certificate's underlying image file to the OFD file's resource file directory, or use a dedicated OFD electronic certificate reader to open an OFD electronic certificate file that does not contain an underlying image. When displaying the OFD electronic certificate file, the reader automatically renders the corresponding certificate's underlying image built into the reader, ensuring the integrity of the preview and printing.
[0143] Taking the generation process of electronic ID card documents as an example, the electronic ID card document mainly consists of a background image, text content, and an ID card photo. Methods for quickly generating OFD electronic documents include:
[0144] Step 1: Parse the electronic ID card template file, generate the OFD electronic ID card template intermediate file, and record the correspondence between the metadata name of the ID card image and the graphic objects in the page content description file.
[0145] The electronic ID card template file describes both mutable and immutable primitive objects, and describes the display information of each object (such as display area, font, metadata name, and color).
[0146] In the aforementioned intermediate file for generating the OFD electronic certificate template, a blank OFD file is generated according to the OFD document standard as the intermediate file for the electronic certificate template. This file only contains the basic OFD file structure, such as... Figure 3 As shown.
[0147] The process parses the electronic ID card template file, extracts immutable graphic objects (such as the ID card background, "name", "gender" text, etc.) from the template file, and generates template page files according to the OFD document standard. These template page files are then placed within the OFD template intermediate file under the "\" directory.
[0148] The location of "Doc_0\Tpls\Tpl_0\Content.xml" should be specified, and a corresponding folder should be created, such as... Figure 4 As shown;
[0149] The process parses the electronic ID card template file and generates a page content description file from the variable graphic elements (such as ID photo, name, gender, etc.) according to the OFD document standard. This file is not added to the OFD template intermediate file. When the template contains images (such as ID photos), they are recorded in the resource file using the generated resource ID, but the file is not placed in the OFD template intermediate file. Based on the information in the electronic ID card template file and the page content description file, the correspondence between the ID card image metadata names and the graphic elements in the page content description file is recorded.
[0150] Based on the correspondence between the metadata names of the certificate / license images and the graphic element objects in the page content description file, a custom index file is generated according to the OFD document standard, using the certificate / license image metadata name as the custom index item name and the graphic element object ID as the custom index item content. This custom index file is placed in the "\Doc_0\CustomTags\Tag_OfficialDocument.xml" location within the OFD template's intermediate file. Figure 5 As shown; and create a custom index file root directory, recording the location of this custom index file. This custom index root directory file is placed in the "\Doc_0\CustomTags.xml" location of the OFD template middle file, such as... Figure 6 As shown;
[0151] Add image resource information to the resource file within the intermediate file stream of the electronic ID card template. This information includes the resource ID and filename of the ID card background image and the ID card photo. The resource ID is used in the template page file and the page content description file, while the filename is used when adding images during the generation of the electronic ID card document file.
[0152] The current OFD template intermediate file stream is an OFD electronic certificate template intermediate file stream that includes a custom index file and template page files, but does not include a page content description file and a certificate background image.
[0153] Step 2: Parse the variable metadata information of the incoming ID card certificate and generate a file stream describing the content of the ID card page.
[0154] The variable metadata information of ID cards and certificates mainly consists of metadata key-value pairs, such as... Figure 7 As shown;
[0155] Parse the key-value pairs of the certificate metadata to obtain the certificate metadata item names and content. Based on the correspondence between the certificate photo metadata names obtained in the first step and the graphic object in the page content description file, automatically format the certificate metadata content using graphic object attributes. Format the certificate metadata content according to the font, font size, and display area information used in the corresponding graphic object attributes. Generate the page content description file according to the OFD document standard. The graphic object corresponding to the ID card photo does not need to be modified.
[0156] Step 3: Add the page content description file and image files to the OFD electronic certificate template intermediate file to generate the electronic ID card certificate file.
[0157] Copy the OFD electronic certificate template intermediate file stream as the ID card electronic certificate file stream, without making direct changes to the original template file stream.
[0158] In accordance with the ZIP file standard, compress the page content description file and the ID card photo file, and add them to the electronic ID card file stream. The page description file is located at "\Doc_0\Pages\Page_0\Content.xml".
[0159] Based on the resource location information recorded in the resource files, add the ID card photo file and the ID card background image file. Place the image resource files in the "\Doc_0\Res\" directory of the electronic ID card file. Whether to add the ID card background image file to the electronic ID card file stream is determined based on the actual situation. Figure 8 As shown, the electronic ID card file stream at this point is already a complete electronic ID card file stream.
[0160] In this embodiment, the certificate page content description information can include only the description information of the certificate background image, but the certificate background image file data is not included in the OFD document resources. This effectively reduces the storage space of electronic certificate files and improves the generation speed of electronic certificates. When previewing and printing the certificate, the OFD electronic certificate dedicated reader can automatically supplement the background image according to the certificate type. When electronically signing, it is only necessary to write the file summary of the certificate background image into the signature file corresponding to the OFD document structure container before signing. When the electronic certificate file is transferred to other heterogeneous systems, it is only necessary to add the certificate background image to the resource file directory corresponding to the OFD document structure container, thereby quickly generating a large number of OFD electronic certificate files.
[0161] This invention provides an electronic certificate generation device, such as... Figure 9 The functional structure diagram shown indicates that the electronic certificate generation device includes:
[0162] The first parsing module 91 is used to parse the preset electronic certificate template to obtain an intermediate file. The intermediate file is stored in memory in the form of a data stream. The intermediate file includes the data item name and graphic object attribute information corresponding to the preset electronic certificate template.
[0163] The second parsing module 92 is used to obtain business metadata and parse the business metadata to obtain the data content corresponding to the data item name;
[0164] Layout module 93 is used to layout the data content according to the attribute information of the graphic object to obtain the page content description file;
[0165] Module 94 is used to add the page content description file to the intermediate file to generate the electronic certificate file.
[0166] In some embodiments, the first parsing module 91 is configured to:
[0167] The electronic certificate template file is parsed to obtain the size and location of the certificate background image, the name, size, location, and page size occupied by the certificate's metadata. Based on this information, an OFD (Optical Documentation) intermediate file stream of the electronic certificate template is generated, containing a custom index file, a template page file, and an OFD intermediate file stream that does not contain a specified page content description file. The OFD intermediate file is stored in memory as a data stream and is not written to the disk. The names of the custom index data items are consistent with the names of the certificate's metadata data items, and the index content ID corresponding to each custom index data item is the ID of the corresponding graphic object in the page content description file.
[0168] In some embodiments, a management module is also included to manage the OFD electronic certificate template information loaded in memory, and to perform operations such as adding, deleting, modifying, and querying the certificate template information. The certificate template information includes certificate template ID, OFD electronic certificate template source file stream, custom indexing data item information, graphic element object information, base map file stream, etc. All of the above template information is stored in memory in the form of data streams, and is not stored locally in the form of files.
[0169] OFD electronic certificate file data streams can be directly sent to the electronic certificate library, ensuring the certificates are not stored on the physical page and guaranteeing the security and confidentiality of the electronic certificate generation process. OFD electronic certificate files do not require the storage of the original certificate image file, resulting in a smaller file size. When external systems use OFD electronic certificate files, the typesetting module 103 inserts the original image into the OFD electronic certificate file resource directory; alternatively, when previewing or printing OFD electronic certificate files, a dedicated OFD electronic certificate file reader can be used to open the file. When displaying the OFD electronic certificate file, the reader automatically renders the corresponding certificate image built into the page background, ensuring the integrity of the preview.
[0170] The generation module 94 is used to compress and add the page content description file stream to the OFD electronic certificate template intermediate file to generate an OFD electronic certificate file without the certificate background image; depending on the usage scenario, the certificate background image file can be added to the OFD electronic certificate file to form a complete OFD electronic certificate file.
[0171] This invention can automatically format documents according to certificate templates, generating massive amounts of electronic certificate files at high speed. Simultaneously, by adding certificate background images on demand, it reduces the storage space required for electronic certificate files and further improves generation efficiency.
[0172] The second parsing module 92 obtains the metadata name of the electronic certificate style and the display attributes of the certificate image metadata items (such as the position and display size of the certificate background image, maximum bounding rectangle, font, font size, color, etc.). Based on the above information, it generates an OFD electronic certificate template intermediate file stream. The immutable metadata items in the certificate style are saved as template pages, while the variable metadata items are saved in the content description file of the specified page. The custom index data item name is consistent with the certificate style metadata name, and the index ID corresponding to the custom index data item is the corresponding graphic object ID in the page content description file. However, the page content description file is not packaged into the OFD electronic certificate template intermediate file.
[0173] The generation module 94 is also used to automatically format the certificate metadata content using the corresponding graphic object attributes based on the OFD electronic certificate template intermediate file, custom indexing information, graphic objects, and the correspondence between certificate metadata data item names provided by the management module. The formatted description information forms a page content description file stream. After compression, the page content description file stream is added to the OFD electronic certificate template intermediate file to generate the OFD electronic certificate file.
[0174] Specifically, the process for generating OFD electronic certificate documents includes:
[0175] Step 1: After the system starts, load the electronic certificate template file, or load a new certificate template file during the generation of OFD electronic certificates. Based on the certificate template information, generate the corresponding OFD electronic certificate template intermediate file;
[0176] Step 2: The certificate generation control module parses the metadata information of a certain type of certificate, including the key-value pairs of the passed-in certificate metadata:
[0177] Parse the key-value pairs of the certificate metadata to obtain the certificate metadata item name and certificate metadata content, where the correspondence between the certificate metadata item name and the certificate image metadata data item name is consistent.
[0178] Step 3: The OFD file processing module adds the compressed page content description file or base map file to the OFD electronic certificate template intermediate file to generate the OFD electronic certificate file.
[0179] In this embodiment, a first parsing module parses a preset electronic certificate template to obtain an intermediate file, which is stored in memory as a data stream. The intermediate file includes the data item names and graphic object attribute information corresponding to the preset electronic certificate template. A second parsing module obtains business metadata and parses it to obtain the data content corresponding to the data item names. A layout module layouts the data content according to the graphic object attribute information to obtain a page content description file. A generation module adds the page content description file to the intermediate file to generate an electronic certificate file. This allows for the repeated generation of a certain type of electronic certificate file, reducing space usage. Furthermore, all files are parsed and processed in memory, eliminating the need for multiple disk reads and writes. This not only improves the speed of electronic certificate generation but also ensures the security of the electronic certificate file generation process.
[0180] It is understood that the same or similar parts in the above embodiments can be referred to each other, and the contents not described in detail in some embodiments can be referred to the same or similar contents in other embodiments.
[0181] It should be noted that in the description of this application, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, in the description of this application, unless otherwise stated, "a plurality of" means at least two.
[0182] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the function involved, as will be understood by those skilled in the art to which embodiments of this application pertain.
[0183] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0184] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0185] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0186] The storage media mentioned above can be read-only memory, disk, or optical disk, etc.
[0187] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0188] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.
[0189] It should be noted that the present invention is not limited to the above-described preferred embodiments. Those skilled in the art can derive other forms of products under the guidance of the present invention. However, regardless of any changes made in their shape or structure, any technical solution that is the same as or similar to that of the present application falls within the protection scope of the present invention.
Claims
1. An electronic passport generation method characterized by comprising: The method comprises the following steps: performing one-time analysis on preset electronic certificate templates of the same type to obtain reusable intermediate files, wherein the intermediate files are saved in the form of data streams in the memory, and the intermediate files comprise data item names and graphic object attribute information corresponding to the preset electronic certificate templates; performing the following steps in the memory: obtaining business metadata, and performing analysis on the business metadata to obtain data contents corresponding to the data item names; performing layout on the data contents according to the graphic object attribute information to obtain a page content description file; adding the page content description file to the intermediate file to generate an electronic certificate file; the one-time analysis on the preset electronic certificate templates of the same type to obtain the reusable intermediate files comprises the following steps: performing analysis on the preset electronic certificate templates to obtain variable certificate surface metadata and unvariable certificate surface metadata, wherein the variable certificate surface metadata comprises at least one of variable text, variable photos and variable table contents, and the unvariable certificate surface metadata comprises at least one of certificate bottom maps, fixed certificate surface text and fixed tables; saving the unvariable certificate surface metadata items in a template page description file; saving the variable certificate surface metadata items in a content description file of a specified page; and obtaining the intermediate file according to the template page description file and the content description file of the specified page; the adding of the page content description file to the intermediate file to generate the electronic certificate file comprises the following steps: compressing the page content description file containing the laid-out graphic information by using a Deflate algorithm; adding the compressed page content description file to the intermediate file; and generating a bottom-map electronic certificate file or a no-bottom-map electronic certificate file according to the template page description file of the intermediate file and the content description file of the specified page containing the laid-out graphic information; the compression of the page content description file containing the laid-out graphic information by using the Deflate algorithm comprises the following steps: generating page content description compressed file data corresponding to a page and obtaining the length of the page content description compressed file data; according to a ZIP format standard, sequentially splicing file header identification, compression mode, file modification time, file size before compression, file size after compression, file name length and file name information to generate file header data; reversely searching a central directory end identification from the end of the intermediate file to obtain a central directory offset position; splitting the intermediate file from the central directory offset position to obtain a file data part of the intermediate file and a central directory part of the intermediate file; according to the ZIP format standard, sequentially splicing central directory identification, file size after compression, file size before compression, file name length, file header offset position and file name information to generate central directory data of compressed data; sequentially splicing the intermediate file data, the file header data, the page content description file compressed data, the central directory data of the compressed data and the central directory of the intermediate file; and modifying central directory parameter information to complete file compression.
2. The electronic passport generation method of claim 1, wherein, the template page description file further comprises: a text object for describing text information in the immutable metadata item, the text object including at least one of a bounding rectangle of a text box, a primitive transformation matrix, a text object ID, and font and font size information; an image object for describing image information in the immutable metadata item, the image object including at least one of a bounding rectangle of an image, a primitive transformation matrix, an image object ID, and a resource ID; a graphic object for describing graphic information in the immutable metadata item, the graphic object including at least one of a bounding rectangle of a graphic object, a primitive transformation matrix, whether to stroke, a stroke color, whether to fill, a graphic fill rule, and a fill color.
3. The electronic passport generation method of claim 1, wherein, The data item name corresponding to the preset electronic certificate template includes: a custom index data item name, which is consistent with the certificate surface style metadata name; an index ID corresponding to the custom index data item, which is an index object ID in the page content description file; The data content corresponding to the data item name is obtained by analyzing the business metadata, including: The business metadata is parsed into a certificate metadata name and data content, and the certificate metadata name and data content are stored in a key-value pair array structure, wherein the certificate metadata name corresponds to the certificate surface style metadata name; According to the key-value pair, the data content corresponding to the certificate metadata name is taken as the data content corresponding to the data item name.
4. The electronic passport generation method of claim 1, wherein, The data content is laid out according to the graphic object attribute information to obtain a page content description file, including: According to the corresponding graphic object attribute, the font, font size, and display area information are selected to lay out the data content of the business metadata; According to the OFD file standard, the laid-out graphic object information is saved in the page description file of the specified page.
5. The electronic passport generation method of claim 4, wherein, According to the corresponding graphic object attribute, the font, font size, and display area information are selected to lay out the data content of the business metadata, including: When the metadata content is a text graphic object, the required number of lines is calculated according to the text attribute and the display area bounding rectangle information; The required display height is calculated according to the calculated required number of lines and the text font size; If the calculated required display height is greater than the height of the display area, the font size is reduced by a preset number of pixels and recalculated until the text can be fully displayed.
6. The electronic passport generation method of claim 1, wherein, Further including: When reading or printing the electronic certificate, the certificate base map is added to the electronic certificate file; Or, Using an electronic certificate dedicated reader, using the base map file of each type of certificate embedded in the reader to render the electronic certificate containing the base map; Or, The certificate base map file digest is written into the signature file corresponding to the OFD document structure container to complete the electronic signature of the OFD electronic certificate file without the base map.
7. An electronic passport generating apparatus for performing the method according to any one of claims 1 to 6, characterized in that including: The first analysis module is configured to parse a preset electronic certificate template of the same type to obtain a reusable intermediate file, the intermediate file is saved in the form of a data stream in the memory, and the intermediate file includes data item names and graphic object attribute information corresponding to the preset electronic certificate template; The second analysis module is configured to obtain service metadata, and analyze the service metadata to obtain data content corresponding to the data item names; The layout module is configured to layout the data content according to the graphic object attribute information to obtain a page content description file; The generation module is configured to add the page content description file to the intermediate file to generate an electronic certificate file.
Citation Information
Patent Citations
Electronic license template manufacturing system and method
CN114254241A
Generation of persistent document object models
US20040133595A1