Method and device for generating OFD format page based on XML template

文档序号:1087372 发布日期:2020-10-20 浏览:4次 中文

阅读说明:本技术 一种基于xml模板生成ofd版式页面的方法和装置 (Method and device for generating OFD format page based on XML template ) 是由 薛军超 于 2020-05-18 设计创作,主要内容包括:本发明提出了一种基于XML模板生成OFD版式页面的方法,包括以下步骤:获取XML模板,所述XML模板包括一系列元数据;依次读取所述元数据;按照所述元数据的类型将其转换为符合标准的OFD文件;输出所述OFD文件。本发明通过XML模板生成OFD版式页面,具有方便、灵活、统一化的优点,帮助应用者批量生成具有相同版面显示效果的OFD文件。(The invention provides a method for generating an OFD format page based on an XML template, which comprises the following steps: acquiring an XML template, wherein the XML template comprises a series of metadata; sequentially reading the metadata; converting the metadata into an OFD file meeting the standard according to the type of the metadata; and outputting the OFD file. The invention generates the OFD layout page through the XML template, has the advantages of convenience, flexibility and unification, and helps an application to generate OFD files with the same layout display effect in batch.)

1. A method for generating an OFD format page based on an XML template is characterized by comprising the following steps:

acquiring an XML template, wherein the XML template comprises a series of metadata;

sequentially reading the metadata;

converting the metadata into an OFD file meeting the standard according to the type of the metadata;

and outputting the OFD file.

2. The method for generating an OFD layout page based on the XML template according to claim 1, further comprising generating the XML template before the obtaining the XML template, the specific steps being:

acquiring original data;

respectively converting the original data into metadata according to the types of the original data;

and combining a plurality of metadata in sequence to generate an XML template.

3. The method for generating an OFD layout page based on an XML template according to claim 1, wherein each of the metadata includes one or more of the following information: metadata name, metadata value, metadata type, metadata location, and metadata attributes.

4. The method for generating an OFD layout page based on the XML template according to claim 3, wherein the converting the metadata into the standard-compliant OFD file according to the type of the metadata specifically comprises:

when the metadata is of a character type, typesetting the characters in the metadata, acquiring the position information of each character and then outputting the position information in an OFD (office format description) form;

and when the metadata is of a picture type, the pictures in the metadata are output in an OFD form after the scaling and the rotation coefficient are calculated.

5. The method for generating an OFD layout page based on the XML template of claim 1, further comprising embedding a font, adding a specified font to the OFD file.

6. The method for generating OFD layout pages based on XML templates according to claim 1, wherein the method is further applicable to generating PDF layout pages.

7. An apparatus for generating an OFD layout page based on an XML template, comprising:

an obtaining module, configured to obtain an XML template, where the XML template includes a series of metadata;

the reading module is used for sequentially reading the metadata;

the conversion module is used for converting the metadata into an OFD file meeting the standard according to the type of the metadata;

and the output module is used for outputting the OFD file.

8. The apparatus for generating an OFD layout page based on the XML template of claim 7, further comprising a generating module, wherein the generating module is configured to obtain original data, convert the original data into metadata according to types of the original data, and sequentially combine a plurality of metadata to generate the XML template.

9. The apparatus for generating an OFD layout page based on the XML template of claim 7, wherein the conversion module comprises a text conversion module and a picture conversion module;

the character conversion module is used for typesetting the characters in the metadata, acquiring the position information of each character and outputting the position information in an OFD (office file format);

and the picture conversion module is used for outputting the pictures in the metadata in an OFD form after calculating the scaling and the rotation coefficient.

10. The apparatus for generating an OFD layout page based on the XML template of claim 7, further comprising an embedding module, wherein the embedding module is configured to add a specified font to the OFD file.

Technical Field

The invention relates to the technical field of computers, in particular to a method and a device for generating an OFD format page based on an XML template.

Background

The OFD (Open file-layout Document, abbreviation: OFD) is the format of the format Document of our country defined by the national standard GB/T33190-2016 electronic file storage and exchange format Document of our country. The OFD meets the requirement of informatization construction in China, and is becoming one of the basic standards of informatization application of various industries in China. By the layout document, the page content described by the layout document has fixed appearance information such as position, size, color and the like, and the display effect of the page content on all terminals is completely fixed and consistent.

The OFD is a compressed package file in the ZIP compressed format with a file suffix ". OFD", so that the OFD is essentially a ZIP compressed package. According to the standard definition, the OFD contains two types of data files: a is the file and page information stored in XML format, it defines the basic information of the format file; and the other is resource information stored in other formats, such as a resource file in a font, an image, multimedia, and the like.

XML, Extensible Markup Language (XML), is an international popular universal data description Language format, and has many advantages such as simplicity, easy understanding, and easy application. The OFD adopts the basic information description format as a format document, and can be said to be the core data format of the OFD.

There is currently an important need in OFD format applications: it is necessary to generate files in a fixed layout format in batch, where the fixed layout format is the same but different in data content. In practical application, a large number of application scenarios exist, such as electronic invoices or electronic certificates, which are characterized in that the layout format is completely fixed, only the contents of the invoices or the certificates are different, and the applications need to be generated in a large number and for a long time. The existing solution is to directly generate the OFD full page data through a computer program, which needs to redesign and regenerate the computer program every time, and has complex application process and low execution efficiency.

Disclosure of Invention

In view of the above problems, the present invention provides a method and apparatus for generating an OFD layout page based on an XML template.

In order to solve the technical problems, the invention adopts the technical scheme that: a method for generating an OFD format page based on an XML template comprises the following steps: acquiring an XML template, wherein the XML template comprises a series of metadata; sequentially reading the metadata; converting the metadata into an OFD file meeting the standard according to the type of the metadata; and outputting the OFD file.

As a preferred scheme, before the obtaining of the XML template, generating the XML template further includes: acquiring original data; respectively converting the original data into metadata according to the types of the original data; and combining a plurality of metadata in sequence to generate an XML template.

Preferably, each of said metadata includes one or more of the following information: metadata name, metadata value, metadata type, metadata location, and metadata attributes.

As a preferred scheme, the converting the metadata into an OFD file meeting the standard according to the type of the metadata specifically includes: when the metadata is of a character type, typesetting the characters in the metadata, acquiring the position information of each character and then outputting the position information in an OFD (office format description) form; and when the metadata is of a picture type, the pictures in the metadata are output in an OFD form after the scaling and the rotation coefficient are calculated.

Preferably, the method further comprises embedding the font, and adding the specified font into the OFD file.

Preferably, the method can also be applied to generating a PDF layout page.

The invention also discloses a device for generating the OFD layout page based on the XML template, which comprises the following steps: an obtaining module, configured to obtain an XML template, where the XML template includes a series of metadata; the reading module is used for sequentially reading the metadata; the conversion module is used for converting the metadata into an OFD file meeting the standard according to the type of the metadata; and the output module is used for outputting the OFD file.

As a preferred scheme, the system further comprises a generating module, wherein the generating module is used for acquiring original data, respectively converting the original data into metadata according to the type of the original data, and sequentially combining a plurality of metadata to generate the XML template.

As a preferred scheme, the conversion module comprises a character conversion module and an image conversion module; the character conversion module is used for typesetting the characters in the metadata, acquiring the position information of each character and outputting the position information in an OFD (office file format); and the picture conversion module is used for outputting the pictures in the metadata in an OFD form after calculating the scaling and the rotation coefficient.

Preferably, the OFD file system further comprises an embedding module, wherein the embedding module is used for adding the specified font to the OFD file.

Compared with the prior art, the invention has the beneficial effects that: the method comprises the steps of templating a layout page, making the layout page content of a fixed part into an OFD page template, supplementing variable content to an OFD layout page, separating layout design through the templating of the layout page, designing layout through a template designer, namely expressing the content of the fixed layout, and defining the position, size and other presentation effects of the variable content part, so that simplified application and execution efficiency are improved in batch generation.

Drawings

The disclosure of the present invention is illustrated with reference to the accompanying drawings. It is to be understood that the drawings are designed solely for the purposes of illustration and not as a definition of the limits of the invention. In the drawings, like reference numerals are used to refer to like parts. Wherein:

fig. 1 is a flowchart of a method for generating an OFD layout page based on an XML template in an embodiment of the present invention;

FIG. 2 is a flow chart of a method for generating an XML template according to an embodiment of the present invention;

fig. 3 is a structural diagram of an apparatus for generating an OFD format based on an XML template according to an embodiment of the present invention;

fig. 4 is a structural diagram of a conversion module in an embodiment of the present invention.

Detailed Description

It is easily understood that according to the technical solution of the present invention, a person skilled in the art can propose various alternative structures and implementation ways without changing the spirit of the present invention. Therefore, the following detailed description and the accompanying drawings are merely illustrative of the technical aspects of the present invention, and should not be construed as all of the present invention or as limitations or limitations on the technical aspects of the present invention.

An embodiment according to the present invention is shown in connection with fig. 1. A method for generating an OFD format page based on an XML template comprises the following steps:

s110: an XML template is obtained, the XML template including a series of metadata.

Specifically, each metadata includes the following information:

metadata names, each metadata name must be unique and readable character string.

Metadata values refer to data values defined by metadata.

The metadata type, which refers to a metadata value type, can be extended, such as text (i.e., character string), image, date, and the like.

Metadata positioning, which specifies the location and size (width, height) of metadata values within the layout page.

The metadata attribute is related to the metadata type, different types of attributes are set differently, for example, the metadata attribute of the text type has a font, a font size, a character color, a font style (bold, italic) and the like, and the data attribute of the image type can have a transparency or a rotation angle and the like.

As shown in fig. 2, before obtaining the XML template, the method further includes generating the XML template, and the specific steps are as follows:

and S210, acquiring original data.

And S220, respectively converting the original data into metadata according to the type of the original data. For the type of the original data being binary, the code conversion is needed to be performed, and the original data is converted into a data expression form conforming to the XML format standard, and the common code conversion is BASE-64, for example, the code conversion is needed for the data value of the image or the two-dimensional code type.

And S230, combining the plurality of metadata in sequence to generate the XML template.

In this embodiment, examples of the XML template metadata are as follows:

Figure BDA0002496131300000041

Figure BDA0002496131300000051

s120: the metadata is read in sequence, starting with the first piece of metadata of the XML template, one piece of metadata is read in sequence each time.

S130: and converting the metadata into an OFD file meeting the standard according to the type of the metadata, wherein the OFD file is required to be typeset, for example, the character type, then the position information of each character is acquired and output in an OFD form, and the image is output in the OFD form after the scaling and the rotation coefficient are calculated.

If the XML template contains data of a plurality of pages, processing of the next page is continued after one page is processed until the end.

S140: and outputting the OFD file.

According to the OFD standard, embedded fonts should be used for the archived OFD files to ensure that the OFD files are displayed identically on all platforms, so embedded fonts are used for files whose metadata type is text. The embedded font is to add character font data used in a designated font to the OFD file. The detailed processing procedure of the embedded font does not belong to the protection scope of the patent, and is not described herein.

It should be understood that the invention discloses a method for generating an OFD layout page based on an XML template, which helps an application person generate OFD files with the same layout display effect in batch. In batch generation, each piece of XML template metadata defines an OFD file, and the same generation process is executed, and the process is circulated until all the OFD files are generated. The XML template metadata may come from a database, from a network, or a combination of both or other data environments. The method can also be applied to format pages in PDF (Portable document Format) and other formats based on XML (extensive Makeup language) templates.

As shown in fig. 3 and fig. 4, the present invention also discloses a device for generating an OFD layout page based on an XML template, which includes:

an obtaining module 110, configured to obtain an XML template, where the XML template includes a series of metadata;

a reading module 120, configured to read the metadata in sequence;

the conversion module 130 is used for converting the metadata into an OFD file meeting the standard according to the type of the metadata, and the conversion module 130 comprises a character conversion module 1301 and an image conversion module 1302; the text conversion module 1301 is used for typesetting the characters in the metadata, acquiring the position information of each character and outputting the position information;

the picture conversion module 1302 is configured to calculate a scaling factor and a rotation factor of a picture in the metadata and then output the picture.

And an output module 140, configured to output the OFD file.

In this embodiment, the apparatus further includes a generating module 100, where the generating module 100 is configured to obtain the original data, respectively convert the original data into metadata according to the type of the original data, and sequentially combine the metadata to generate an XML template.

An embedding module 150 is also included, the embedding module 150 being configured to add the specified font to the OFD file.

It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.

The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention essentially or partially contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.

The technical scope of the present invention is not limited to the above description, and those skilled in the art can make various changes and modifications to the above-described embodiments without departing from the technical spirit of the present invention, and such changes and modifications should fall within the protective scope of the present invention.

9页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种可扩展标记语言XML文档的压缩、解压方法和装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!