File format conversion method and device, equipment, storage medium and program product
Through thread parallel processing and template customization, XML files are automatically converted into PDF files, solving the problem of low manual conversion efficiency, improving conversion speed and supporting PDF generation of customized layouts and styles.
Patent Information
- Application Number
- CN202510362338.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-07-18
AI Technical Summary
Manually converting XML files to PDF files is less efficient, especially when processing large amounts of XML files.
By obtaining XML files and using at least one thread to read and write data in the template required by the user, the XML files are automatically converted into PDF files, supporting multi-threaded parallel processing and custom layout and styles, and generating PDF files that conform to the output format.
Improves file format conversion speed, reduces blocking time for input/output operations, produces PDF files with neat appearance, and supports custom layouts and styles.
Smart Images

Figure CN120336258A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing, and in particular, to a method, apparatus, device, storage medium, and program product for file format conversion. Background Art
[0002] Currently, in cases where XML (Extensible Markup Language) files contain structured data, making it difficult to view the original data, and the data needs to be stored in an uneditable format for a long time, it is necessary to convert XML files into PDF (Portable Document Format) files.
[0003] Currently, in related technologies, the conversion of XML files into PDF files is usually performed manually.
[0004] However, the inventors found that the related technologies have at least the following technical problems: When a large number of XML files need to be converted into PDF files, the efficiency of manual conversion operations is relatively low. Summary of the Invention
[0005] The file format conversion method, apparatus, device, storage medium, and program product provided by the embodiments of this application are used to solve the problem of relatively low efficiency of manual file format conversion operations.
[0006] In a first aspect, an embodiment of this application provides a file format conversion method, including: obtaining at least one Extensible Markup Language file. In response to detecting a template identifier input by a user, reading a conversion parameter template corresponding to the template identifier. Reading the data source and output format in the conversion parameter template. Using at least one thread to read the target data corresponding to the data source in the Extensible Markup Language file. Using the target data to generate a Portable Document Format file that conforms to the output format.
[0007] In a possible implementation, using at least one thread to read the target data corresponding to the data source in the Extensible Markup Language file includes: obtaining the number of Extensible Markup Language files. Using a thread greater than or equal to the number of Extensible Markup Language files to read the target data corresponding to the data source in the Extensible Markup Language file.
[0008] In a possible implementation, using at least one thread to read the target data corresponding to the data source in the Extensible Markup Language file includes: using at least one thread to map the Extensible Markup Language file to a target object. Reading the target data corresponding to the data source in the target object.
[0009] In a possible implementation, a Portable Document Format (PDF) file that conforms to an output format is generated using target data, including: if the target data includes text content, the text content is written into the PDF file. According to the output format, the format of the text content in the PDF file is set.
[0010] In a possible implementation, a PDF file that conforms to an output format is generated using target data, including: if the target data includes a picture, the size of the picture is obtained. The remaining space size of the PDF file is obtained. If the size of the picture is greater than the remaining space size, the size of the picture is reduced to obtain a reduced image. The reduced image is written into the PDF file.
[0011] In a possible implementation, after obtaining the remaining space size of the PDF file, it further includes: if the remaining space size is less than a preset space size, a new page is created in the PDF file, and the picture is written into the newly created page.
[0012] In a possible implementation, after generating a PDF file that conforms to an output format using target data, it further includes: adding a preset electronic seal picture to the PDF file.
[0013] In a second aspect, an embodiment of the present application provides a file format conversion device, including: a file acquisition module, configured to acquire at least one Extensible Markup Language (XML) file; a template reading module, configured to read a conversion parameter template corresponding to a template identifier in response to detecting a user input of the template identifier; a parameter reading module, configured to read a data source and an output format in the conversion parameter template; a data reading module, configured to read target data corresponding to the data source in the XML file using at least one thread; and a file generation module, configured to generate a PDF file that conforms to the output format using the target data.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the processor executes the first aspect and / or various possible implementation manners of the first aspect as above.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the first aspect and / or various possible implementation manners of the first aspect as above.
[0016] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which when executed by a processor, implements the first aspect and / or various possible implementation manners of the first aspect as described above.
[0017] The file format conversion method, device, equipment, storage medium and program product provided by the embodiments of the present application obtain an XML file, and use at least one thread to read and write data according to a template required by a user, automatically convert the XML file into a PDF file, increase the conversion speed, and since multiple threads can be used to perform format conversion simultaneously, reduce the blocking time of input / output operations, thus improving the format conversion speed. In addition, since the template can be custom-set by the user, supporting custom layout, style and content structure, the generated PDF has a neater appearance. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings herein are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0019] Figure 1 is a schematic diagram of the scenario of the file format conversion method provided by the present application;
[0020] Figure 2 is a schematic flowchart of the file format conversion method provided by an embodiment of the present application;
[0021] Figure 3 is a schematic structural diagram of the file format conversion device provided by an embodiment of the present application;
[0022] Figure 4 is a schematic structural diagram of the electronic device provided by an embodiment of the present application.
[0023] Through the above accompanying drawings, specific embodiments of the present application have been shown, and there will be more detailed descriptions hereinafter. These accompanying drawings and the written description are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0024] Here, the exemplary embodiments will be described in detail, and the examples are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different accompanying drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0025] When it is difficult to view the original data due to the XML file containing structured data, and the data needs to be stored in an uneditable format for a long time, it becomes necessary to convert the XML file into a PDF file.
[0026] Currently, in the related technical fields, the conversion operation from XML files to PDF files usually relies on manual work. However, this method is less efficient, especially when dealing with a large number of XML files, which requires a long time.
[0027] To address the above technical problems, the inventor proposed the following technical concept: By using the template selected by the user, read the corresponding data in the XML file according to the template content, and input the data into the PDF file in the format required by the template file to complete the conversion from the XML file to the PDF file.
[0028] This application is applied to the scenario of file format conversion. It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. And the collection, use, and processing of relevant data need to comply with relevant laws, regulations, and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0029] Figure 1 It is a schematic diagram of the scenario of the file format conversion method provided by this application. As Figure 1 , in this scenario, it includes: a terminal device 101.
[0030] In the specific implementation process, the terminal device 101 can include a computer, a server, a tablet, a mobile phone, a personal digital assistant (PDA), a notebook, etc. They can perform data input, file reading, downloading data from the network, and format conversion, etc.
[0031] The terminal device 101 is used to obtain the XML file from the local or network using at least one thread, and convert the XML file using the template required by the user to obtain a PDF file.
[0032] It can be understood that the scenario illustrated in the embodiments of this application does not constitute a specific limitation on the file format conversion method. In some other feasible embodiments of this application, the above scenario may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or different component arrangements, which can be specifically determined according to the actual application scenario and are not limited here. Figure 1 The shown scenario can be implemented by hardware, software, or a combination of software and hardware.
[0033] The technical solution of the present application and how the technical solution of the present application solves the above technical problems will be described in detail below with specific embodiments. The following several specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below with reference to the accompanying drawings.
[0034] Figure 2 It is a schematic flowchart of the file format conversion method provided by the embodiments of the present application. The execution subject of the embodiments of the present application can be Figure 1 the terminal device in, or a server, etc., and this embodiment does not make special restrictions on this. As Figure 2 shown, the method includes:
[0035] S201: Obtain at least one Extensible Markup Language file.
[0036] In this step, it may include reading the XML file from a preset position in the storage unit of the terminal device itself, or may include calling an interface to obtain the XML file returned by the interface, and may also include detecting the XML file selected by the user through dragging, selecting, etc.
[0037] S202: In response to detecting the template identifier input by the user, read the conversion parameter template corresponding to the template identifier.
[0038] In this step, it may include detecting the template identifier input by the user in the input box, or may include detecting the template file selected or chosen by the user.
[0039] Among them, the template identifier may include a template code, a template name, etc.
[0040] S203: Read the data source and output format in the conversion parameter template.
[0041] In this step, it may include reading the data within the preset tags to obtain the data source and output format, or may include reading the data after the data source field in the conversion parameter template to obtain the data source, and reading the content after each output format field to obtain the output format.
[0042] S204: Use at least one thread to read the target data corresponding to the data source in the Extensible Markup Language file.
[0043] In this step, the data source may include HTML (Hyper Text Markup Language) tags, and the target data is obtained by reading the content of the HTML tags.
[0044] S205: Generate a Portable Document Format file that conforms to the output format using the target data.
[0045] In this step, it includes writing the target data into a blank PDF file in the output format to obtain a Portable Document Format file that conforms to the output format.
[0046] As can be seen from the description of the above embodiments, the embodiments of the present disclosure obtain an XML file and use at least one thread to read and write data according to the template required by the user, automatically converting the XML file into a PDF file, increasing the conversion speed. And since multiple threads can be used to perform format conversion simultaneously, the blocking time of input / output operations is reduced, thus improving the format conversion speed. In addition, since the template can be customized by the user, supporting custom layout, style, and content structure, the generated PDF has a neater appearance.
[0047] In a possible implementation manner, in the above step S204, using at least one thread to read the target data corresponding to the data source in the Extensible Markup Language file includes: step S204A1 and step S204A2.
[0048] S204A1: Obtain the number of Extensible Markup Language files.
[0049] In this step, for example, if 3 Extensible Markup Language files are read from a preset location, the number of Extensible Markup Language files is 3. Another example is that when periodically obtaining XML files from a preset interface, 10 Extensible Markup Language files are obtained from the preset interface, then the number of Extensible Markup Language files is 10.
[0050] S204A2: Use a thread greater than or equal to the number of Extensible Markup Language files to read the target data corresponding to the data source in the Extensible Markup Language file.
[0051] In this step, for example, if the number of obtained Extensible Markup Language files is 3, then 3 or 6 threads are used to read the target data corresponding to the data source in the Extensible Markup Language file. Another example is that if the number of obtained Extensible Markup Language files is 5, then 5, 10, or 15 threads are used to read the target data corresponding to the data source in the Extensible Markup Language file.
[0052] As can be seen from the description of the above embodiments, the embodiments of the present disclosure read the data in the Extensible Markup Language file using a thread greater than or equal to the number of Extensible Markup Language files, realizing the simultaneous reading of the content in multiple XML files and increasing the file conversion speed.
[0053] In a possible implementation manner, in the above step S204, using at least one thread to read the target data corresponding to the data source in the Extensible Markup Language file includes: step S204B1 and step S204B2.
[0054] S204B1: Map the Extensible Markup Language file to a target object using at least one thread.
[0055] In this step, it may include mapping the Extensible Markup Language file to a target object using the same number of threads as the number of Extensible Markup Language files. Each thread can use the JAXB tool to map the Extensible Markup Language file to a target object.
[0056] Among them, the target object can be preset by the staff or user. For example, a Book object or any other preset object.
[0057] S204B2: Read the target data corresponding to the data source in the target object.
[0058] In this step, a preset parser can be used to parse the target object to obtain the target data corresponding to the data source in the target object.
[0059] Among them, the preset parser is, for example, a Jsoup parser. The target data can include text, images, etc.
[0060] As can be seen from the description of the above embodiments, the embodiments of the present disclosure map the XML file to a target object by using at least one thread, so as to be able to read the target data corresponding to the data source from the target object. Since multiple threads can be used for processing simultaneously, the data reading speed is increased. And since the XML is mapped to a target object, the subsequent processes of data reading and data processing are more convenient, the data processing speed is increased, and it is convenient for subsequent data reuse.
[0061] In a possible implementation manner, the above step S205 uses the target data to generate a Portable Document Format file that conforms to the output format, including: step S2051 and step S2052.
[0062] S2051: If the target data includes text content, write the text content into the Portable Document Format file.
[0063] In this step, it may include writing the text content into the Portable Document Format file line by line. If the text content is segmented, the text content can be written into the Portable Document Format file in segments.
[0064] S2052: Set the format of the text content in the Portable Document Format file according to the output format.
[0065] In this step, it may include setting the format of the Portable Document Format file according to the font, line spacing, font size, page margin, etc. required by the output format.
[0066] As can be seen from the description of the above embodiments, the embodiments of the present disclosure make the obtained PDF file meet the requirements of the parameter template by writing text content into the PDF file and adjusting the format to meet the requirements of the output format in the template.
[0067] In a possible implementation manner, in step S205 above, generating a portable file format file that meets the output format using the target data includes steps S2053 to S2056.
[0068] S2053: If the target data includes a picture, obtain the size of the picture.
[0069] In this step, obtaining the size of the picture includes obtaining the length and width of the picture.
[0070] Among them, the picture can be a picture in any format.
[0071] S2054: Obtain the remaining space size of the portable file format file.
[0072] In this step, the remaining space size of the portable file format file can be obtained by using a preset plug-in or program method.
[0073] S2055: If the size of the picture is greater than the remaining space size, reduce the size of the picture to obtain a reduced image.
[0074] In this step, the method of reducing the size of the picture can include dividing the remaining space size by the picture size to obtain a reduction ratio, and reducing both the length and width of the picture according to the reduction ratio to obtain a reduced image.
[0075] For example, if the length of the picture is 1200 and the remaining space size is 800, then reduce the length of the picture to 800 and reduce the width of the picture proportionally to obtain a reduced image. Another example, if the length of the picture is 1500 and the remaining space size is 500, then calculate the reduction ratio as one-third, and reduce both the length and width of the picture to one-third to obtain a reduced image.
[0076] S2056: Write the reduced image into the portable file format file.
[0077] In this step, it can include writing the reduced image into the remaining space of the portable file format file. It can also include converting the reduced image to a color space supported by PDF, adjusting the resolution of the reduced image according to the output format, compressing, creating a stream object in the PDF, and making a stream reference in the content stream of the PDF page.
[0078] As can be seen from the description of the above embodiments, when the remaining space size of the PDF page is not enough to write the picture, the picture is reduced and then written to ensure that the picture is not displayed on multiple pages and is not truncated.
[0079] In a possible implementation, after obtaining the remaining space size of the portable document format file in step S2054 above, the following is further included:
[0080] S2057: If the remaining space size is less than the preset space size, a new page is created in the portable document format file, and the picture is written to the newly created page.
[0081] In this step, a new page is created by at least one of creating a new page object, updating the page tree, creating a content stream, updating the page tree, and associating it with the PDF document root directory. The process of writing the picture to the newly created page is similar to step S2056 above and will not be elaborated here.
[0082] As can be seen from the description of the above embodiments, the embodiments of the present disclosure directly create a new page when the remaining space size is less than the preset space size, and write the picture to the newly created page, so as to avoid the picture being displayed on multiple pages or being truncated.
[0083] In a possible implementation, after generating a portable document format file that conforms to the output format using the target data in step S205 above, the following is further included:
[0084] S210: Add a preset electronic seal picture to the portable document format file.
[0085] In this step, it includes referring to the electronic seal picture in the page content stream and drawing the electronic seal picture to a preset position on the page or the position required by the parameter template.
[0086] As can be seen from the description of the above embodiments, the embodiments of the present disclosure add an electronic seal picture to the generated PDF file, thereby increasing the reliability of the PDF document.
[0087] Figure 3 This is a schematic structural diagram of the file format conversion device provided by the embodiments of the present application. As Figure 3 shown, the file format conversion device 300 includes: a file acquisition module 301, a template reading module 302, a parameter reading module 303, a data reading module 304, and a file generation module 305.
[0088] The file acquisition module 301 is used to acquire at least one extensible markup language file;
[0089] The template reading module 302 is used to read the conversion parameter template corresponding to the template identifier in response to detecting the template identifier input by the user;
[0090] A parameter reading module 303 is configured to read the data source and output format in the conversion parameter template.
[0091] A data reading module 304 is configured to read the target data corresponding to the data source in the extensible markup language file by using at least one thread.
[0092] A file generating module 305 is configured to generate a portable file format file that conforms to the output format by using the target data.
[0093] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. The implementation principle and technical effect are similar, and will not be elaborated here in this embodiment.
[0094] In a possible implementation manner, the data reading module 304 is configured to obtain the number of extensible markup language files; read the target data corresponding to the data source in the extensible markup language file by using threads whose number is greater than or equal to the number of extensible markup language files.
[0095] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. The implementation principle and technical effect are similar, and will not be elaborated here in this embodiment.
[0096] In a possible implementation manner, the data reading module 304 is configured to map the extensible markup language file to a target object by using at least one thread; read the target data corresponding to the data source in the target object.
[0097] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. The implementation principle and technical effect are similar, and will not be elaborated here in this embodiment.
[0098] In a possible implementation manner, if the target data includes text content, the file generating module 305 is configured to write the text content into the portable file format file; set the format of the text content in the portable file format file according to the output format.
[0099] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. The implementation principle and technical effect are similar, and will not be elaborated here in this embodiment.
[0100] In a possible implementation manner, if the target data includes a picture, the file generating module 305 is configured to obtain the size of the picture; obtain the remaining space size of the portable file format file; if the size of the picture is greater than the remaining space size, reduce the size of the picture to obtain a reduced image; write the reduced image into the portable file format file.
[0101] The device provided in this embodiment can be used to implement the technical solutions of the above method embodiment. The implementation principle and technical effects are similar, and will not be elaborated here in this embodiment.
[0102] In a possible implementation, the file format conversion device 300 further includes: a picture insertion module 306.
[0103] The picture insertion module 306 is configured to, if the remaining space size is less than the preset space size, create a new page in the portable document format file and write the picture into the newly created page.
[0104] The device provided in this embodiment can be used to implement the technical solutions of the above method embodiment. The implementation principle and technical effects are similar, and will not be elaborated here in this embodiment.
[0105] In a possible implementation, the file format conversion device 300 further includes: a seal adding module 307.
[0106] The seal adding module 307 is configured to add a preset electronic seal picture to the portable document format file.
[0107] The device provided in this embodiment can be used to implement the technical solutions of the above method embodiment. The implementation principle and technical effects are similar, and will not be elaborated here in this embodiment.
[0108] To implement the above embodiment, an electronic device is further provided in an embodiment of the present application.
[0109] Referring to Figure 4 , which shows a schematic structural diagram of an electronic device 400 suitable for implementing the embodiments of the present application. The electronic device 400 can be a terminal device or a server. Among them, the terminal device can include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (Personal Digital Assistant, abbreviated as PDA), tablet computers (Portable Android Device, abbreviated as PAD), portable multimedia players (Portable MediaPlayer, abbreviated as PMP), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The electronic device shown is only an example and should not impose any limitation on the functions and usage scope of the embodiments of the present application.
[0110] As Figure 4As shown, the electronic device 400 may include a processor (such as a central processing unit, a graphics processing unit, etc.) 401, and a memory 402 communicatively connected to the processor. It can perform various appropriate actions and processes according to the programs, computer-executable instructions stored in the memory 402, or the programs loaded from the storage device 408 into the random access memory (RAM) 403, and implement the file format conversion method in any of the above embodiments, where the memory may be a read only memory (ROM). In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, the memory 402, and the RAM 403 are connected to each other through a bus 404. The input / output (I / O) interface 405 is also connected to the bus 404.
[0111] Generally, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 can allow the electronic device 400 to communicate with other devices wirelessly or wirelessly to exchange data. Although Figure 4 the electronic device 400 with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. More or fewer devices may be implemented or had alternatively.
[0112] In particular, according to the embodiments of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments of the present application include a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program includes program codes for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the memory 402. When the computer program is executed by the processing device 401, the above functions defined in the method of the embodiments of the present application are executed.
[0113] It should be noted that the computer-readable storage medium described above in this application can be a computer-readable signal medium, a computer storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this application, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. And in this application, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable storage medium other than the computer-readable storage medium, and this computer-readable signal medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable storage medium can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0114] The above computer-readable storage medium can be included in the above electronic device; it can also exist separately and not be assembled into the electronic device.
[0115] The above computer-readable storage medium carries one or more programs. When the above one or more programs are executed by the electronic device, the electronic device is caused to execute the method shown in the above embodiments.
[0116] Computer program code for performing the operations of this application can be written in one or more programming languages or combinations thereof. The above-mentioned programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or it can be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).
[0117] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0118] The modules described in the embodiments of this application can be implemented in software or in hardware. Among them, the name of the unit does not constitute a limitation to the module itself in some cases. For example, the file acquisition module can also be described as the "XML file acquisition module".
[0119] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: Field Programmable Gate Arrays (FPGA), Application Specific Integrated Circuits (ASIC), Application Specific Standard Products (ASSP), System on Chip (SOC), Complex Programmable Logic Devices (CPLD), and so on.
[0120] The present application also provides a computer-readable storage medium storing computer-executable instructions. When a processor executes the computer-executable instructions, the technical solution of the file format conversion method in any of the above embodiments is implemented. The implementation principle and beneficial effects are similar to those of the file format conversion method. For details, refer to the implementation principle and beneficial effects of the file format conversion method, which will not be elaborated here.
[0121] In the context of the present application, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0122] The present application also provides a computer program product including a computer program. When the computer program is executed by a processor, the technical solution of the file format conversion method in any of the above embodiments is implemented. The implementation principle and beneficial effects are similar to those of the file format conversion method. For details, refer to the implementation principle and beneficial effects of the file format conversion method, which will not be elaborated here.
[0123] The above description is only a preferred embodiment of the present application and an explanation of the applied technical principle. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by the specific combination of the above technical features, but also covers other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, a technical solution formed by mutually replacing the above features with technical features having similar functions (but not limited to) disclosed in the present application.
[0124] Other embodiments of the present application will be readily apparent to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include known common knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and examples are only to be considered as exemplary, and the true scope and spirit of the present application are pointed out by the following claims.
[0125] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.
Claims
1. A file format conversion method, characterized in that, including: obtaining at least one Extensible Markup Language file; in response to detecting a template identifier input by a user, reading a conversion parameter template corresponding to the template identifier; reading a data source and an output format in the conversion parameter template; using at least one thread to read target data corresponding to the data source in the Extensible Markup Language file; using the target data to generate a Portable Document Format file that conforms to the output format.
2. The method according to claim 1, wherein The using at least one thread to read target data corresponding to the data source in the Extensible Markup Language file includes: obtaining the number of the Extensible Markup Language files; using a thread greater than or equal to the number of the Extensible Markup Language files to read target data corresponding to the data source in the Extensible Markup Language file.
3. The method according to claim 1, characterized in that, The using at least one thread to read target data corresponding to the data source in the Extensible Markup Language file includes: using at least one thread to map the Extensible Markup Language file to a target object; reading target data corresponding to the data source in the target object.
4. The method according to claim 1, wherein The using the target data to generate a Portable Document Format file that conforms to the output format includes: if the target data includes text content, writing the text content into the Portable Document Format file; setting a format of the text content in the Portable Document Format file according to the output format.
5. The method according to any one of claims 1 to 4, characterized in that The using the target data to generate a Portable Document Format file that conforms to the output format includes: if the target data includes a picture, obtaining a size of the picture; obtaining a remaining space size of the Portable Document Format file; if the size of the picture is greater than the remaining space size, shrinking the size of the picture to obtain a shrunk image; writing the shrunk image into the Portable Document Format file.
6. The method according to claim 5, wherein After the obtaining the remaining space size of the Portable Document Format file, further including: if the remaining space size is less than a preset space size, creating a new page in the Portable Document Format file and writing the picture into the new page.
7. The method according to any one of claims 1 to 4, characterized in that, After the using the target data to generate a Portable Document Format file that conforms to the output format, further including: adding a preset electronic seal picture to the Portable Document Format file.
8. A file format conversion device, characterized in that, including: a file obtaining module, configured to obtain at least one Extensible Markup Language file; a template reading module, configured to read a conversion parameter template corresponding to the template identifier in response to detecting a template identifier input by a user; a parameter reading module, configured to read a data source and an output format in the conversion parameter template; a data reading module, configured to use at least one thread to read target data corresponding to the data source in the Extensible Markup Language file; a file generating module, configured to use the target data to generate a Portable Document Format file that conforms to the output format.
9. An electronic device, characterized in that, including: a memory, a processor; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory, so that the processor executes the file format conversion method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which are used to implement the file format conversion method according to any one of claims 1 to 7 when executed by a processor.
11. A computer program product, characterized in that, It includes a computer program, which implements the file format conversion method according to any one of claims 1 to 7 when executed by a processor.