CN110674437A - Method and device for converting webpage data into PDF (Portable document Format) attachment - Google Patents

Method and device for converting webpage data into PDF (Portable document Format) attachment Download PDF

Info

Publication number
CN110674437A
CN110674437A CN201910739182.7A CN201910739182A CN110674437A CN 110674437 A CN110674437 A CN 110674437A CN 201910739182 A CN201910739182 A CN 201910739182A CN 110674437 A CN110674437 A CN 110674437A
Authority
CN
China
Prior art keywords
canvas
pdf
converting
attachment
webpage
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
CN201910739182.7A
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.)
Shenzhen Dianmao Technology Co Ltd
Original Assignee
Shenzhen Dianmao Technology 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 Shenzhen Dianmao Technology Co Ltd filed Critical Shenzhen Dianmao Technology Co Ltd
Priority to CN201910739182.7A priority Critical patent/CN110674437A/en
Publication of CN110674437A publication Critical patent/CN110674437A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a method and a device for converting webpage data into PDF (Portable document Format) accessories, wherein the method for converting the webpage data into the PDF accessories comprises the following steps: judging whether a signal that a user triggers a conversion button is received, and entering an operation program for converting webpage data into a PDF (Portable document Format) attachment after the conversion button is triggered; if so, generating a Canvas on the webpage, and drawing the webpage data into the Canvas to form a first Canvas; and converting the first Canvas into a target PDF attachment, and exporting and saving the target PDF attachment. The invention solves the problem that in the prior art, students can only use a browser to access teaching resources, and the operations such as local storage, labeling and the like of the teaching resources are inconvenient.

Description

Method and device for converting webpage data into PDF (Portable document Format) attachment
Technical Field
The invention relates to the technical field of webpage processing application, in particular to a method and a device for converting webpage data into PDF (Portable document Format) attachments.
Background
At present, most of teaching resources in many education and training companies are displayed to students in a webpage form. However, the form of the web page has certain limitation, namely, under the condition of network disconnection, students are very inconvenient to access teaching resources. In addition, as the students can only use the browser to access the teaching resources (no matter at a computer end or a mobile phone end), the students are inconvenient to locally store the teaching resources and do operations similar to labeling and the like. In many educational systems, only the PDF attachment format is supported for distributing or reading material.
Disclosure of Invention
The embodiment of the invention provides a method and a device for converting webpage data into a PDF (Portable document Format) attachment, which are used for solving the problems that in the prior art, students can only use a browser to access teaching resources, and the operations such as local storage, labeling and the like of the teaching resources are inconvenient.
In order to solve the above technical problem, a first technical solution adopted in the embodiments of the present invention is as follows:
a method for converting web page data into a PDF attachment, comprising: judging whether a signal that a user triggers a conversion button is received, and entering an operation program for converting webpage data into a PDF (Portable document Format) attachment after the conversion button is triggered; if so, generating a Canvas on the webpage, and drawing the webpage data into the Canvas to form a first Canvas; and converting the first Canvas into a target PDF attachment, and exporting and saving the target PDF attachment.
Optionally, the generating a Canvas on a webpage page includes: the Canvas is generated on the Html webpage page using JavaScript code.
Optionally, the converting the first Canvas to the target PDF attachment includes: cutting the first Canvas into a plurality of second Canvas with the same block size; converting all of the second Canvas into the target PDF attachment using a JavaScript language.
Optionally, the cutting the first Canvas into a plurality of second Canvas with the same block size includes: and cutting the first Canvas into a plurality of second Canvas with the same block size according to the size of the specified paper, wherein each second Canvas has the same size as each specified paper.
Optionally, after the cutting the first Canvas into a plurality of second Canvas with the same block size, the method further includes: inserting page numbers on all of the second Canvas.
Optionally, the inserting page numbers on all of the second Canvas comprises: sequencing all the second Canvas according to the content sequence of the webpage data; and inserting page numbers corresponding to the ranking numbers of the second Canvas on each block according to the ranking of all the second Canvas canvases.
Optionally, the exporting and saving the target PDF attachment includes: and saving the target PDF attachment to a local database, and sending the saved address of the target PDF attachment to a designated administrator.
In order to solve the above technical problem, a second technical solution adopted in the embodiments of the present invention is as follows:
an apparatus for converting web page data into a PDF attachment, comprising: the system comprises a trigger judging module, a PDF attachment converting module and a display module, wherein the trigger judging module is used for judging whether a signal that a user triggers a conversion button is received or not, and the conversion button enters an operation program for converting webpage data into the PDF attachment after being triggered; the generation drawing module is used for generating Canvas on a webpage when a signal that a user triggers a conversion button is received, and drawing webpage data into the Canvas to form a first Canvas; and the conversion storage module is used for converting the first Canvas into the target PDF attachment and exporting and storing the target PDF attachment.
In order to solve the above technical problem, a third technical solution adopted in the embodiments of the present invention is as follows:
a computer-readable storage medium, on which a computer program is stored, which, when executed, implements a method of converting webpage page data into a PDF attachment as described above.
In order to solve the above technical problem, a fourth technical solution adopted in the embodiments of the present invention is as follows:
a computer device comprising a processor, a memory and a computer program stored on the memory and executable on the processor, the processor implementing the method for converting web page data into PDF attachments as described above when executing the computer program.
The embodiment of the invention has the beneficial effects that: different from the situation in the prior art, the embodiment of the invention generates the Canvas on the webpage, draws the webpage data into the Canvas to form the first Canvas, converts the first Canvas into the target PDF attachment, and finally exports and stores the target PDF attachment, thereby solving the problems that in the prior art, students can only use browsers to access teaching resources, and the operations such as local storage, labeling and the like of the teaching resources are inconvenient.
Drawings
Fig. 1 is a flowchart illustrating an implementation of an embodiment of a method for converting webpage data into a PDF attachment according to a first embodiment of the present invention;
FIG. 2 is a partial structural frame diagram of an embodiment of a device for converting webpage data into PDF attachments according to a second embodiment of the present invention;
FIG. 3 is a partial structural framework diagram of an embodiment of a computer-readable storage medium according to a third embodiment of the present invention;
fig. 4 is a partial structural framework diagram of an embodiment of a computer device according to a fourth embodiment of the present invention.
Detailed Description
Example one
Referring to fig. 1, fig. 1 is a flowchart of an implementation of a method for converting webpage data into a PDF attachment according to an embodiment of the present invention, which can be obtained by combining fig. 1, and the method for converting webpage data into a PDF attachment according to the present invention includes:
step S101: and judging whether a signal that a user triggers a conversion button is received, wherein the conversion button enters an operation program for converting webpage data into PDF (Portable document Format) attachments after being triggered. In this step, before receiving a signal that the user triggers the conversion button, the programmer has written a processing code corresponding to a conversion event for converting the netpage page data into the PDF attachment, forming a corresponding conversion button, and the user can click the conversion button on the corresponding netpage to trigger a subsequent procedure for converting the Html netpage data into the PDF attachment.
Step S102: and if a signal that a user triggers a conversion button is received, generating a Canvas on a webpage, and drawing webpage data into the Canvas to form a first Canvas. In this step, if a signal that the user triggers the conversion button is not received, the Canvas is not generated on the webpage.
Step S103: and converting the first Canvas into a target PDF attachment, and exporting and saving the target PDF attachment. PDF (short for Portable Document Format) is a file Format developed by file exchange in a manner independent of an application program, an operating system, and hardware. The PDF file can guarantee accurate colors and accurate printing effect regardless of the printer on which it is printed, i.e., PDF faithfully reproduces each character, color, and image of an original.
In this embodiment, optionally, the generating a Canvas on a webpage includes: the Canvas is generated on the Html webpage page using JavaScript code. Html, i.e. hypertext markup language, an application under the standard universal markup language. "hypertext" means that a page may contain pictures, links, and even non-textual elements such as music, programs, etc. The structure of the hypertext markup language includes a "Head" part (english: Head) that provides information about a web page, and a "Body" part (english: Body) that provides specific contents of the web page. The Canvas Chinese name is a "Canvas," which is a "container" of all UI components (user interface components) in the game. In one scenario, the existence of multiple Canvas objects may be allowed, and "nested" usage between the Canvas may also be allowed. Any UI object in the scene must be a "child level" of a Canvas object. The Canvas tag is used to render images (via script, usually JavaScript). However, the Canvas element itself has no drawing capability (it is merely a container for graphics) and must use scripts to accomplish the actual drawing task.
In this embodiment, optionally, the converting the first Canvas into the target PDF attachment includes: cutting the first Canvas into a plurality of second Canvas with the same block size; converting all of the second Canvas into the target PDF attachment using a JavaScript language. The Canvas element itself has no drawing capability and all drawing work must be done inside JavaScript. JavaScript is an transliterated script language, which is a dynamic type, weak type, prototype-based language and a built-in support type. Its interpreter, called JavaScript engine, is a part of the browser, a scripting language widely used on clients, and was originally used on Html (an application under the standard universal markup language) web pages to add dynamic functionality to the Html web pages.
In this embodiment, optionally, the cutting the first Canvas into a plurality of second Canvas with the same block size includes: and cutting the first Canvas into a plurality of second Canvas with the same block size according to the size of the specified paper, wherein each second Canvas has the same size as each specified paper.
In this embodiment, optionally, after the cutting the first Canvas into a plurality of second Canvas with the same block size, the method further includes: inserting page numbers on all of the second Canvas.
In this embodiment, optionally, the inserting page numbers on all of the second Canvas includes: sequencing all the second Canvas according to the content sequence of the webpage data; and inserting page numbers corresponding to the ranking numbers of the second Canvas on each block according to the ranking of all the second Canvas canvases.
In this embodiment, optionally, the exporting and saving the target PDF attachment includes: and saving the target PDF attachment to a local database, and sending the saved address of the target PDF attachment to a designated administrator.
According to the embodiment of the invention, the Canvas is generated on the webpage, the webpage data is drawn into the Canvas to form the first Canvas, the first Canvas is converted into the target PDF accessory, and finally the target PDF accessory is exported and stored, so that the problem that in the prior art, students can only use a browser to access teaching resources, and the operations such as local storage, labeling and the like of the teaching resources are inconvenient is solved. The scheme of the invention realizes the conversion from the webpage data to the PDF data, and can convert some templated webpages into PDF for distribution under the condition of network disconnection. If the contents are the same, the PDF is exported for distribution by using the scheme of the invention, so that the user does not need to repeatedly visit the please-teach webpage, and the server load and the expense of the company are reduced. Compared with a network link form, the content distribution is carried out by using PDF, and the safety degree is relatively high.
Example two
Referring to fig. 2, fig. 2 is a partial structural frame diagram of an embodiment of a device for converting webpage data into a PDF attachment according to the present invention, which can be obtained by referring to fig. 2, and the device 100 for converting webpage data into a PDF attachment according to the present invention includes:
the triggering judgment module 110 is configured to judge whether a signal that a user triggers a conversion button is received, where the conversion button enters an operation procedure of converting webpage data into a PDF attachment after being triggered.
The generating and drawing module 120 is configured to generate a Canvas on a webpage when a signal that a user triggers a conversion button is received, and draw the webpage data into the Canvas to form a first Canvas.
A conversion and storage module 130, configured to convert the first Canvas into a target PDF attachment, and export and store the target PDF attachment.
According to the embodiment of the invention, the Canvas is generated on the webpage, the webpage data is drawn into the Canvas to form the first Canvas, the first Canvas is converted into the target PDF accessory, and finally the target PDF accessory is exported and stored, so that the problem that in the prior art, students can only use a browser to access teaching resources, and the operations such as local storage, labeling and the like of the teaching resources are inconvenient is solved.
EXAMPLE III
Referring to fig. 3, a computer-readable storage medium 10 according to an embodiment of the present invention is shown, for example: ROM/RAM, magnetic disk, optical disk, etc., on which a computer program 11 is stored, the computer program 11 when executed implementing the method for converting web page data into PDF attachments according to an embodiment. Since the method for converting the webpage data into the PDF attachment is described in detail in the first embodiment, the description is not repeated here.
According to the method for converting the webpage data into the PDF accessory, the Canvas is generated on the webpage, the webpage data is drawn into the Canvas to form the first Canvas, the first Canvas is converted into the target PDF accessory, and finally the target PDF accessory is exported and stored, so that the problems that in the prior art, students can only use a browser to access teaching resources, and operations such as local storage and labeling of the teaching resources are inconvenient are solved.
Example four
Referring to fig. 4, a computer device 20 according to an embodiment of the present invention includes a processor 21, a memory 22, and a computer program 221 stored in the memory 22 and executable on the processor 21, wherein the processor 21 executes the computer program 221 to implement the method for converting webpage data into PDF attachments according to an embodiment. Since the method for converting the webpage data into the PDF attachment is described in detail in the first embodiment, the description is not repeated here.
According to the method for converting the webpage data into the PDF accessory, the Canvas is generated on the webpage, the webpage data is drawn into the Canvas to form the first Canvas, the first Canvas is converted into the target PDF accessory, and finally the target PDF accessory is exported and stored, so that the problems that in the prior art, students can only use a browser to access teaching resources, and operations such as local storage and labeling of the teaching resources are inconvenient are solved.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes performed by the present specification and drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A method for converting web page data into a PDF attachment, comprising:
judging whether a signal that a user triggers a conversion button is received, and entering an operation program for converting webpage data into a PDF (Portable document Format) attachment after the conversion button is triggered;
if so, generating a Canvas on the webpage, and drawing the webpage data into the Canvas to form a first Canvas;
and converting the first Canvas into a target PDF attachment, and exporting and saving the target PDF attachment.
2. The method for converting webpage data into PDF attachments according to claim 1, wherein the generating a Canvas on the webpage comprises:
the Canvas is generated on the Html webpage page using JavaScript code.
3. The method for converting webpage data into a PDF attachment according to claim 1, wherein the converting the first Canvas into a target PDF attachment comprises:
cutting the first Canvas into a plurality of second Canvas with the same block size;
converting all of the second Canvas into the target PDF attachment using a JavaScript language.
4. The method for converting webpage data into PDF attachments according to claim 3, wherein the cropping the first Canvas into a plurality of second Canvas with the same block size comprises:
and cutting the first Canvas into a plurality of second Canvas with the same block size according to the size of the specified paper, wherein each second Canvas has the same size as each specified paper.
5. The method for converting webpage data into PDF attachments according to claim 3, wherein the cutting the first Canvas into several second Canvas with the same block size further comprises:
inserting page numbers on all of the second Canvas.
6. The method for converting webpage data into PDF attachments according to claim 5, wherein the inserting page numbers on all of the second Canvas comprises:
sequencing all the second Canvas according to the content sequence of the webpage data;
and inserting page numbers corresponding to the ranking numbers of the second Canvas on each block according to the ranking of all the second Canvas canvases.
7. The method for converting webpage data into PDF attachments according to claim 1, wherein the exporting and saving of the target PDF attachment comprises:
and saving the target PDF attachment to a local database, and sending the saved address of the target PDF attachment to a designated administrator.
8. An apparatus for converting web page data into PDF attachments, comprising:
the system comprises a trigger judging module, a PDF attachment converting module and a display module, wherein the trigger judging module is used for judging whether a signal that a user triggers a conversion button is received or not, and the conversion button enters an operation program for converting webpage data into the PDF attachment after being triggered;
the generation drawing module is used for generating Canvas on a webpage when a signal that a user triggers a conversion button is received, and drawing webpage data into the Canvas to form a first Canvas;
and the conversion storage module is used for converting the first Canvas into the target PDF attachment and exporting and storing the target PDF attachment.
9. A computer-readable storage medium, having stored thereon a computer program which, when executed, implements a method of converting webpage data according to any one of claims 1 to 7 into a PDF attachment.
10. A computer device comprising a processor, a memory and a computer program stored on the memory and executable on the processor, wherein the processor executes the computer program to implement the method of converting webpage page data into PDF attachments according to any one of claims 1 to 7.
CN201910739182.7A 2019-08-12 2019-08-12 Method and device for converting webpage data into PDF (Portable document Format) attachment Pending CN110674437A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910739182.7A CN110674437A (en) 2019-08-12 2019-08-12 Method and device for converting webpage data into PDF (Portable document Format) attachment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910739182.7A CN110674437A (en) 2019-08-12 2019-08-12 Method and device for converting webpage data into PDF (Portable document Format) attachment

Publications (1)

Publication Number Publication Date
CN110674437A true CN110674437A (en) 2020-01-10

Family

ID=69068568

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910739182.7A Pending CN110674437A (en) 2019-08-12 2019-08-12 Method and device for converting webpage data into PDF (Portable document Format) attachment

Country Status (1)

Country Link
CN (1) CN110674437A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111581564A (en) * 2020-05-10 2020-08-25 青岛希望鸟科技有限公司 Webpage synchronous communication method realized by applying Canvas
CN111639288A (en) * 2020-05-29 2020-09-08 小船出海教育科技(北京)有限公司 Method and device for exporting files from webpage courseware, electronic equipment and storage medium
CN111859865A (en) * 2020-06-30 2020-10-30 深圳市中农易讯信息技术有限公司 Method, device, terminal and medium for converting PDF document

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106354700A (en) * 2016-08-11 2017-01-25 广州爱九游信息技术有限公司 Page text conversion method and system
CN107766359A (en) * 2016-08-17 2018-03-06 广州市动景计算机科技有限公司 A kind of method, apparatus and computing device that content of pages is converted to picture
CN109740087A (en) * 2018-11-23 2019-05-10 量子云未来(北京)信息科技有限公司 A kind of picture rendering method, apparatus and system
CN109815451A (en) * 2018-12-13 2019-05-28 方正璞华软件(武汉)股份有限公司 A kind of PDF generation method, device and equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106354700A (en) * 2016-08-11 2017-01-25 广州爱九游信息技术有限公司 Page text conversion method and system
CN107766359A (en) * 2016-08-17 2018-03-06 广州市动景计算机科技有限公司 A kind of method, apparatus and computing device that content of pages is converted to picture
CN109740087A (en) * 2018-11-23 2019-05-10 量子云未来(北京)信息科技有限公司 A kind of picture rendering method, apparatus and system
CN109815451A (en) * 2018-12-13 2019-05-28 方正璞华软件(武汉)股份有限公司 A kind of PDF generation method, device and equipment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111581564A (en) * 2020-05-10 2020-08-25 青岛希望鸟科技有限公司 Webpage synchronous communication method realized by applying Canvas
CN111581564B (en) * 2020-05-10 2023-12-12 青岛希望鸟科技有限公司 Webpage synchronous communication method implemented by Canvas
CN111639288A (en) * 2020-05-29 2020-09-08 小船出海教育科技(北京)有限公司 Method and device for exporting files from webpage courseware, electronic equipment and storage medium
CN111859865A (en) * 2020-06-30 2020-10-30 深圳市中农易讯信息技术有限公司 Method, device, terminal and medium for converting PDF document

Similar Documents

Publication Publication Date Title
US10282410B2 (en) Assistive technology for the impaired
CN107885848B (en) Webpage screen capturing method based on web technology
CN109815451B (en) PDF (Portable document Format) generation method, device and equipment
CN110674437A (en) Method and device for converting webpage data into PDF (Portable document Format) attachment
CN107153636A (en) It is a kind of to realize the method and system that business datum is quickly exported with PDF format
CN104050238A (en) Map labeling method and map labeling device
CN107301046B (en) Icon processing method and device, computer equipment and storage medium
US9117314B2 (en) Information output apparatus, method, and recording medium for displaying information on a video display
US20140344669A1 (en) Document conversion apparatus
CN104050185A (en) Zoom-display processing method and device for page contents
CN115543238B (en) Browser page printing method, device, equipment and storage medium
US8194269B2 (en) Image forming method and system using XHTML-print data
CN113419729A (en) Front-end page building method, device, equipment and storage medium based on modularization
CN114791988A (en) Browser-based PDF file analysis method, system and storage medium
CN110647695A (en) Method and device for converting webpage data into picture attachment
CN117093386A (en) Page screenshot method, device, computer equipment and storage medium
CN112596688A (en) Web end custom printing method based on TinyMCE rich text
CN103034990A (en) Method and device for checking publications
US20140240757A1 (en) Retrieval of electronic document using hardcopy document
US20100017708A1 (en) Information output apparatus, information output method, and recording medium
CN102637290A (en) Operating system based on browser and compiling method
CN110309455B (en) Method, device and equipment for displaying OLE vector diagram
US10606928B2 (en) Assistive technology for the impaired
CN113703699B (en) Real-time output method and device for electronic file
CN110516183A (en) The generation method and device of static Web page

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: 20200110