A method for realizing detection report printing applied to an Android system
By using the JNI library to classify and transform data in the Android system, and directly outputting PS format files to the printer, the problem of the Android system not being able to directly access the printer is solved, enabling convenient printing of test reports and reducing costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHONGSHAN CHUANGYI BIOCHEM ENG
- Filing Date
- 2022-11-29
- Publication Date
- 2026-06-19
AI Technical Summary
The inability of Android systems to directly access printers limits system options, increases printing costs, and creates obstacles for industrial design.
By using the JNI library to classify and transform data in the Android system, and directly output PS format files to the printer, direct printing from the Android system can be achieved.
The test report can be printed without the need for conversion through the Windows system, reducing printing costs and providing convenience for industrial design.
Smart Images

Figure CN115729488B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of printing technology, and in particular relates to a method for printing test reports using an Android system. Background Technology
[0002] Android is a free and open-source operating system based on the Linux kernel. It is primarily used in mobile devices, but it is also increasingly being used in various fields, such as industrial automation. As Android is still in its early stages, many related applications are not yet fully developed. One such application is connecting to a printer using Android to print documents. Currently, printer drivers are designed for Windows systems, and Android cannot directly access printers. To enable direct printing, users are forced to use the original Windows system, which significantly limits system options and creates obstacles for industrial design. Summary of the Invention
[0003] (I) Purpose of the Invention
[0004] To overcome the above shortcomings, the purpose of this invention is to provide a method for printing test reports using an Android system, in order to solve the technical problems that existing Android systems cannot directly call printers, which limits system selection and creates obstacles for industrial design, or that Android systems can only use other methods to achieve the printing purpose, which greatly increases the printing cost.
[0005] (II) Technical Solution
[0006] To achieve the above objectives, the technical solution provided in this application is as follows:
[0007] A method for printing test reports on an Android system includes:
[0008] Received a print command sent by the client;
[0009] Extract the test report data to be printed from the client's database and send the test report data to the JNI library;
[0010] Based on the JNI library, the various data in the detection report are classified by type, including: title data, content data, and chart data;
[0011] Based on the JNI library, the categorized title data, content data, and chart data are inserted into the corresponding positions in the corresponding print templates.
[0012] The JNI library was used to convert the printed template with inserted data into a PS format file.
[0013] The JNI library is used to output PS format files to the printer, and the printer eventually prints out the test report.
[0014] The JNI library allows Java code to interact with code written in other languages. This application uses the JNI library to classify test report data written in Java code, insert the classified data into the corresponding positions of the corresponding print templates, convert the print templates with inserted data into PS format files, and finally interact with the PS format files with a printer driven by C language to print the test report. This application can achieve direct printing on Android systems without requiring the use of Windows systems, bringing convenience to industrial design.
[0015] In some embodiments, before inserting the categorized title data, content data, and chart data into their respective positions in the corresponding print templates based on the JNI library, the method further includes: selecting the corresponding print template based on the title data.
[0016] In some embodiments, before classifying the various data in the test report data according to categories based on the JNI library and inserting the classified title data and content data into the corresponding positions of the corresponding print template, the method further includes: converting the title data and content data into Chinese character format using the Ghostscript software tool.
[0017] In some embodiments, before classifying the various data in the test report data by type based on the JNI library and inserting the classified chart data into the corresponding position of the corresponding print template, the method further includes: converting the chart data from jps format to eps format using the jpeg2ps software tool. Attached Figure Description
[0018] Figure 1 This is a flowchart of the method for printing test reports in the Android system according to the present invention. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments and the accompanying drawings. It should be understood that these descriptions are merely exemplary and not intended to limit the scope of the invention. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concept of the invention.
[0020] This invention provides a method for printing test reports in an Android system, comprising:
[0021] A method for printing test reports on an Android system includes:
[0022] Receives a print command sent by the client (triggers a print event);
[0023] Extract the test report data to be printed from the client's database and send the test report data to the JNI library;
[0024] Based on the JNI library, the various data in the detection report are classified by type, including: title data, content data, and chart data;
[0025] Based on the JNI library, the categorized title data, content data, and chart data are inserted into the corresponding positions in the corresponding print templates.
[0026] The JNI library was used to convert the printed template with inserted data into a PS format file.
[0027] The JNI library is used to output PS format files to the printer, and the printer eventually prints out the test report.
[0028] Specifically, the JNI library refers to a file program written in C language. It is mainly used when upper-layer applications (Android system) cannot directly call the underlying content (printer driver). The JNI library can indirectly call the underlying content.
[0029] Specifically, each print template has multiple versions, including portrait printing, landscape printing, and single-sided printing, etc. Each print template has a fixed title position, a fixed content number position, and a fixed chart position.
[0030] Specifically, the title data could be "XXX Current Test Report";
[0031] Specifically, the content data can be the content of the test report, which includes text and numbers, etc.
[0032] Specifically, chart data can be line graphs or scatter plots derived from content data, etc.
[0033] Specifically, the client can select a print template, which is then mapped to the title data. The JNI library can retrieve the corresponding print template from the title data and then insert the different types of data into the corresponding positions of the print template.
[0034] Specifically, since the Android system uses Java, the generated reports are also Java code and cannot directly output Chinese characters. Therefore, before inserting the categorized title and content data into the corresponding positions in the corresponding print template, it is necessary to use the Ghostscript software tool to guide the font library and convert the title and content data into Chinese characters to avoid garbled characters.
[0035] Specifically, since the Android system does not come with a built-in jpeg2ps tool, it cannot insert chart data into the corresponding print template. Therefore, before inserting the categorized chart data into the corresponding position in the print template, it also includes: converting the chart data from jps format to eps format using the jpeg2ps software tool.
[0036] It should be understood that the specific embodiments described above are merely illustrative or explanatory of the principles of the invention and do not constitute a limitation thereof. Therefore, any modifications, equivalent substitutions, improvements, etc., made without departing from the spirit and scope of the invention should be included within the protection scope of the invention. Furthermore, the appended claims are intended to cover all variations and modifications falling within the scope and boundaries of the appended claims, or equivalent forms of such scope and boundaries.
Claims
1. A method for printing a detection report on an Android system, characterized in that, include: Received a print command sent by the client; Extract the test report data to be printed from the client's database and send the test report data to the JNI library; Based on the JNI library, the various data in the detection report are classified by type, including: title data, content data, and chart data; Based on the JNI library, the categorized title data, content data, and chart data are inserted into the corresponding positions in the corresponding print templates. The JNI library was used to convert the printed template with inserted data into a PS format file. The JNI library is used to output PS format files to the printer, and the printer eventually prints out the test report. Before classifying the various data in the test report data according to categories based on the JNI library and inserting the classified title data and content data into the corresponding positions of the corresponding print template, the method further includes: converting the title data and content data into Chinese character format using the Ghostscript software tool; Before classifying the various data in the test report data according to categories based on the JNI library and inserting the classified chart data into the corresponding positions of the corresponding print template, the method further includes: converting the chart data from jps format to eps format using the jpeg2ps software tool; The JNI library allows Java code to interact with code written in other languages. Based on the JNI library, the test report data written in Java code is classified, and the classified data is inserted into the corresponding positions of the corresponding print template. The print template with inserted data is converted into a PS format file. Finally, the PS format file interacts with the printer driven by C language to print the test report. It can print directly on Android systems without requiring the use of Windows systems.
2. The method for printing test reports in an Android system according to claim 1, before inserting the categorized title data, content data, and chart data into their respective positions in the corresponding print template based on the JNI library, further includes: Select the corresponding print template based on the title data.