CN112836468A - Method and system for generating pdf document by virtue of front end and back end of server - Google Patents

Method and system for generating pdf document by virtue of front end and back end of server Download PDF

Info

Publication number
CN112836468A
CN112836468A CN202110100673.4A CN202110100673A CN112836468A CN 112836468 A CN112836468 A CN 112836468A CN 202110100673 A CN202110100673 A CN 202110100673A CN 112836468 A CN112836468 A CN 112836468A
Authority
CN
China
Prior art keywords
data
pdf
server
chart
back end
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110100673.4A
Other languages
Chinese (zh)
Inventor
盛北辰
黎文志
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Health Medical Big Data Co ltd
Original Assignee
Shandong Health Medical Big Data Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shandong Health Medical Big Data Co ltd filed Critical Shandong Health Medical Big Data Co ltd
Priority to CN202110100673.4A priority Critical patent/CN112836468A/en
Publication of CN112836468A publication Critical patent/CN112836468A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/109Font handling; Temporal or kinetic typography
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The invention discloses a method and a system for generating a pdf document by a front end and a back end of a server, which relate to the technical field of data conversion and comprise the following implementation contents: the front-end page acquires data from the server and converts the data into a corresponding chart by means of a visualization tool; the front-end page converts the chart into a canvas format by means of an html2canvas tool, then converts the chart into base64 and transmits the base64 back to the server back end; selecting and processing a pdf template by the rear end of the server based on the data length and the typesetting condition; and the back end of the server splices the processed pdf templates, outputs a finally required pdf template after splicing, and transmits the pdf template to a front-end page. The invention can realize the generation of the pdf document at the back end of the server by virtue of the front-end page, and solves the problem that the prior method can not generate the complex pdf document.

Description

Method and system for generating pdf document by virtue of front end and back end of server
Technical Field
The invention relates to the technical field of data conversion, in particular to a method and a system for generating a pdf document by a front end and a back end of a server.
Background
pdf is an electronic file format developed by Adobe corporation, and pdf files are currently recognized as standard transmission files in the world that are most suitable for internet applications. With the continuous development of social modernization and office paperless, pdf documents become preferred in some scenes due to the characteristics that the pdf documents cannot be edited, digital watermarks can be added, the display effect is consistent under different platforms, and the like.
The importance of pdf document application is self-evident, and it is also very important to study the way pdf documents are built to fit a particular situation. The current pdf document has a plurality of generation modes, the back end can generate through an iText library, and the front end can convert html into canvas, and then convert the canvas into pdf. But neither of these approaches is fully satisfactory when faced with the need to generate complex pdf documents.
Disclosure of Invention
Aiming at the requirements and the defects of the prior art development, the invention provides a method and a system for generating a pdf document by a front end and a back end of a server so as to meet the complex pdf generation requirement.
First, the present invention provides a method for generating pdf documents by using a front end and a back end of a server, and the technical solution adopted to solve the above technical problems is as follows:
a method for generating a pdf document by means of a server front-end and back-end, the implementation comprising:
step S1, the front-end page acquires data from the server and converts the data into a corresponding chart;
step S2, the front end page transmits the chart back to the back end of the server;
s3, selecting and processing a pdf template based on the data length and the typesetting condition at the back end of the server;
and step S4, splicing the processed pdf templates by the back end of the server, outputting a finally required pdf template after splicing, and transmitting the template to the front-end page.
When step S1 is executed, the front-end page transforms the data into a corresponding chart by means of a visualization tool.
In step S2, the front page converts the chart into canvas format by means of the html2canvas tool, and then converts the chart into base64, which is transmitted back to the back end.
When step S3 is executed, based on the data length and the layout condition, a pdf template is selected and processed, and the specific operations are as follows:
preparing pdf templates under different typesetting conditions for pages with uncertain data length and influence on typesetting;
and for the page with unfixed data length and fixed typesetting, preparing a picture with the same color as the background color, and changing the size of the picture according to the data length to cover blank data.
Secondly, the invention provides a system for generating pdf documents by the front end and the back end of a server, and the technical scheme adopted for solving the technical problems is as follows:
a system for generating a pdf document by means of a front end and a back end of a server comprises a front end page and a back end of the server, a data conversion module deployed on the front end page and a data processing module deployed on the back end;
the front-end page acquires data from the server and transmits the chart converted by the data conversion module to the back end;
the data conversion module converts the data into a corresponding chart;
the back end receives the chart transmitted by the front end page and transmits the chart to the data processing module;
the data processing module firstly selects and processes the pdf template based on the data length and the typesetting condition, then splices the processed pdf templates, outputs the finally required pdf template after splicing, and transmits the pdf template to a front-end page.
Specifically, the related data conversion module comprises a visualization tool, and the visualization tool converts the data into a corresponding chart.
Specifically, the data conversion module involved also includes an html2canvas tool, and the html2canvas tool converts the chart into canvas format, and then converts the chart into base 64.
Specifically, the related data processing module selects and processes the pdf template based on the data length and the typesetting condition, and specifically includes:
preparing pdf templates under different typesetting conditions for pages with uncertain data length and influence on typesetting;
and for the page with unfixed data length and fixed typesetting, preparing a picture with the same color as the background color, and changing the size of the picture according to the data length to cover blank data.
Compared with the prior art, the method and the system for generating the pdf document by the front end and the back end of the server have the following beneficial effects that:
the method converts the data into the chart by means of the front-end page, selects the pdf template by means of the back end, and selects and splices the pdf template to generate and output the pdf template meeting the requirement.
Drawings
FIG. 1 is a flow chart of a method according to a first embodiment of the present invention;
fig. 2 is a connection block diagram of the second embodiment of the present invention.
The reference information in the drawings indicates:
1. front end page 2, back end 3, data conversion module 4, data processing module.
Detailed Description
In order to make the technical scheme, the technical problems to be solved and the technical effects of the present invention more clearly apparent, the following technical scheme of the present invention is clearly and completely described with reference to the specific embodiments.
The first embodiment is as follows:
with reference to fig. 1, the embodiment proposes a method for generating a pdf document by a front end and a back end of a server, which includes:
and S1, the front-end page 1 acquires data from the server, and converts the data into a corresponding chart by means of a visualization tool.
Step S2, the front-end page 1 converts the chart into canvas format by means of html2canvas tool, and then converts the canvas format chart into base64, and returns it to the server back-end 2.
Step S3, the server backend 2 selects and processes the pdf template based on the data length and the layout condition, and the specific operations are as follows:
preparing pdf templates under different typesetting conditions for pages with uncertain data length and influence on typesetting;
and for the page with unfixed data length and fixed typesetting, preparing a picture with the same color as the background color, and changing the size of the picture according to the data length to cover blank data.
And step S4, the server back end 2 splices the processed pdf templates, outputs a finally required pdf template after splicing, and transmits the pdf template to the front end page 1.
Example two:
with reference to fig. 2, the embodiment provides a system for generating a pdf document by a front end and a back end of a server, which includes a front end page 1 and a back end 2 of the server, and further includes a data transformation module 3 deployed on the front end page 1 and a data processing module 4 deployed on the back end 2.
The front-end page 1 acquires data from the server and transmits the chart converted by the data conversion module 3 to the back end 2.
The data conversion module 3 comprises a visualization tool and an html2canvas tool, wherein the visualization tool converts data into corresponding charts, the html2canvas tool converts the charts into canvas format, and then converts the charts into base 64.
The back end 2 receives the chart transmitted by the front end page 1 and transmits the chart to the data processing module 4.
The data processing module 4 firstly selects and processes the pdf template based on the data length and the typesetting condition, then splices the processed pdf templates, outputs the finally required pdf template after splicing, and transmits the pdf template to the front-end page 1.
In this embodiment, the data processing module 4 selects and processes the pdf template based on the data length and the layout condition, and specifically includes:
preparing pdf templates under different typesetting conditions for pages with uncertain data length and influence on typesetting;
and for the page with unfixed data length and fixed typesetting, preparing a picture with the same color as the background color, and changing the size of the picture according to the data length to cover blank data.
In summary, the method and the system for generating the pdf document by the front end and the back end of the server of the present invention can realize the generation of the pdf document at the back end 2 of the server by the front end page 1, and solve the problem that the complex pdf document cannot be generated by the existing method.
The principles and embodiments of the present invention have been described in detail using specific examples, which are provided only to aid in understanding the core technical content of the present invention. Based on the above embodiments of the present invention, those skilled in the art should make any improvements and modifications to the present invention without departing from the principle of the present invention, and therefore, the present invention should fall into the protection scope of the present invention.

Claims (8)

1. A method for generating a pdf document by means of a server front end and a back end, the method comprising:
step S1, the front-end page acquires data from the server and converts the data into a corresponding chart;
step S2, the front end page transmits the chart back to the back end of the server;
s3, selecting and processing a pdf template based on the data length and the typesetting condition at the back end of the server;
and step S4, splicing the processed pdf templates by the back end of the server, outputting a finally required pdf template after splicing, and transmitting the template to the front-end page.
2. The method for generating a pdf document according to claim 1, wherein said step S1 is executed by the front end page converting the data into corresponding charts based on the visualization tool.
3. The method of claim 1, wherein step S2 is executed, wherein the front page converts the chart into canvas format by html2canvas tool, and then converts the canvas format chart into base64, and returns it to the back end.
4. The method of claim 1, wherein the step S3 is executed when the server backend selects and processes the pdf template according to the data length and the layout condition, and the method comprises:
preparing pdf templates under different typesetting conditions for pages with uncertain data length and influence on typesetting;
and for the page with unfixed data length and fixed typesetting, preparing a picture with the same color as the background color, and changing the size of the picture according to the data length to cover blank data.
5. A system for generating a pdf document by means of a front end and a back end of a server is characterized by comprising a front end page and a back end of the server, a data conversion module deployed on the front end page and a data processing module deployed on the back end;
the front-end page acquires data from a server and transmits the chart converted by the data conversion module to the back end;
the data conversion module converts the data into a corresponding chart;
the back end receives the chart transmitted by the front end page and transmits the chart to the data processing module;
the data processing module firstly selects and processes the pdf template based on the data length and the typesetting condition, then splices the processed pdf templates, outputs the finally required pdf template after splicing, and transmits the pdf template to a front-end page.
6. The system of claim 5, wherein the data transformation module comprises a visualization tool that transforms data into a corresponding graph.
7. The system of claim 6, wherein the data transformation module further comprises an html2canvas tool, the html2canvas tool converting the chart into canvas format, and then converting the canvas format chart into base 64.
8. The system of claim 6, wherein the data processing module selects and processes a pdf template based on data length and layout, and comprises:
preparing pdf templates under different typesetting conditions for pages with uncertain data length and influence on typesetting;
and for the page with unfixed data length and fixed typesetting, preparing a picture with the same color as the background color, and changing the size of the picture according to the data length to cover blank data.
CN202110100673.4A 2021-01-21 2021-01-21 Method and system for generating pdf document by virtue of front end and back end of server Pending CN112836468A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110100673.4A CN112836468A (en) 2021-01-21 2021-01-21 Method and system for generating pdf document by virtue of front end and back end of server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110100673.4A CN112836468A (en) 2021-01-21 2021-01-21 Method and system for generating pdf document by virtue of front end and back end of server

Publications (1)

Publication Number Publication Date
CN112836468A true CN112836468A (en) 2021-05-25

Family

ID=75931590

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110100673.4A Pending CN112836468A (en) 2021-01-21 2021-01-21 Method and system for generating pdf document by virtue of front end and back end of server

Country Status (1)

Country Link
CN (1) CN112836468A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2017151913A (en) * 2016-02-26 2017-08-31 株式会社スカイコム Pdf file management system, pdf file management server, pdf file data acquiring server, pdf file management method, pdf file data acquiring method, pdf file management program, and pdf file data acquiring program
CN107153636A (en) * 2017-04-18 2017-09-12 北京思特奇信息技术股份有限公司 It is a kind of to realize the method and system that business datum is quickly exported with PDF format
CN110008195A (en) * 2019-04-11 2019-07-12 重庆猪八戒知识产权服务有限公司 A kind of dynamic configuration html turns the method, apparatus and system of pdf
CN111045615A (en) * 2019-12-19 2020-04-21 厦门商集网络科技有限责任公司 Method and system for printing JS template customized at browser end

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2017151913A (en) * 2016-02-26 2017-08-31 株式会社スカイコム Pdf file management system, pdf file management server, pdf file data acquiring server, pdf file management method, pdf file data acquiring method, pdf file management program, and pdf file data acquiring program
CN107153636A (en) * 2017-04-18 2017-09-12 北京思特奇信息技术股份有限公司 It is a kind of to realize the method and system that business datum is quickly exported with PDF format
CN110008195A (en) * 2019-04-11 2019-07-12 重庆猪八戒知识产权服务有限公司 A kind of dynamic configuration html turns the method, apparatus and system of pdf
CN111045615A (en) * 2019-12-19 2020-04-21 厦门商集网络科技有限责任公司 Method and system for printing JS template customized at browser end

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
JINGXIAN: "将html页面保存成图片,图片写入pdf的实现方法", 《HTTPS://WWW.JB51.NET/ARTICLE/92730.HTM》 *

Similar Documents

Publication Publication Date Title
US20150046797A1 (en) Document format processing apparatus and document format processing method
CN109492199B (en) PDF file conversion method based on OCR pre-judgment
US7257771B2 (en) System and method for converting a page description file to a composite representation thereof for fast Web viewing
CN106126491B (en) A kind of paper form is converted to the method and system of web form
CN105824788B (en) A kind of method and system that PowerPoint file is converted to word document
EP1422632A2 (en) Method and apparatus to process portable document format data containing transparency
CN101393413B (en) Information processing apparatus and method
US8325368B2 (en) Print information conversion apparatus, printing apparatus, printing system, and computer readable medium
KR20150144073A (en) Method and apparatus for format conversion of document, and cloud server thereof
US20090037463A1 (en) Image processing apparatus, control method thereof, and storage medium that stores program thereof
US8656278B2 (en) Data converting apparatus and data converting program
US20150294203A1 (en) Image output system, image output method, document server, and non-transitory computer readable recording medium
US6331896B1 (en) Printing system and method for avoiding unnecessarily repetitive operations while preparing print data
JP2016177373A (en) Information processing apparatus, information processing program, and information processing system
CN101727588B (en) Image forming apparatus and method
US8484558B2 (en) Document generation method and document generation apparatus
JP2009223405A (en) Image forming apparatus, information processor, information processing program, and image processing system
CN112836468A (en) Method and system for generating pdf document by virtue of front end and back end of server
US8619284B2 (en) Method and apparatus for including converted drawing commands in a print data file
CN111913703B (en) Object editing method, device, electronic equipment and readable storage medium
US8970875B2 (en) Image forming apparatus and method for producing e-book contents
CN101853244A (en) Method and device for generating page file
JP2005170037A (en) Printer, printing system, printing method, and program
US20090287733A1 (en) Method for preparing prepress image data
CN103902235A (en) Digital printing and outputting method and device for PDF file

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210525