Method and system for exporting paging PDF (Portable Document Format) file

By a method of obtaining image data and determining paging lines according to the requirements of PDF pages, the export of paging PDF files is realized, solving the problems of high resource occupation and complexity in the existing technology, ensuring that the visual effect of the exported PDF files is consistent.

CN119940293APending Publication Date: 2025-05-06ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510113913.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-24
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

When implementing the export of paging PDF files, the existing technology needs to deploy node.js services, occupy server resources, and require developers to have node.js experience, and special processing of page elements, resulting in high cost and complexity.

Method used

By obtaining the export request, obtain the target image data of the area of ​​the PDF file to be exported, and determine the expected paging line according to the PDF page requirements. If there is no content in the expected paging line, it is used as the target paging line to export the paging PDF file.

Benefits of technology

There is no need to deploy node.js service to avoid server resource occupation, and ensure that the exported paging PDF file is exactly the same as the visual effects of the original page, including fonts, colors, layouts, etc.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119940293A_ABST
    Figure CN119940293A_ABST
Patent Text Reader

Abstract

The invention provides a paging PDF file exporting method and system, and the method comprises the steps: obtaining an exporting request which is used for requesting the exporting of the content of a to-be-exported PDF file region of a target page as a paging PDF file, obtaining the target image data of the to-be-exported PDF file region, and according to the PDF page demands, obtaining the content of the to-be-exported PDF file region from the target image data, and determining an expected paging line for exporting the paging PDF file, and if no content exists in the expected paging line, determining the expected paging line as a target paging line of the paging PDF file so as to obtain and export the paging PDF file. Node.js service does not need to be deployed, and occupation of server resources in the prior art can be avoided. And the export efficiency and accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and more particularly to a method and system for exporting a paginated PDF file. Background Art

[0002] With the development of computer technology and the further advancement of the digital age, Portable Document Format (PDF) has been widely used in all walks of life as a popular document format.

[0003] In the prior art, the export of paginated PDF files can be achieved by deploying a node.js service. For example, a backend service is built based on the node.js operating environment and the Express framework, and the Puppeteer technology is used to start a Chromium browser instance to achieve the effect of exporting PDF files.

[0004] However, the above solution not only requires the cost of part of the server, but also requires developers with node.js experience to develop additional functions, and also requires special processing of page elements.

[0005] It is worth noting that the contents of the above-mentioned related technologies are merely information known to the inventor personally, which does not mean that the above-mentioned information has entered the public domain before the filing date of this specification, nor does it mean that it can become the prior art of this specification. Summary of the invention

[0006] This specification provides a method and system for exporting a paginated PDF file to avoid at least one of the above technical problems.

[0007] In a first aspect, this specification provides a method for exporting a paginated PDF file, comprising:

[0008] Obtaining an export request, wherein the export request is used to request to export the content of the PDF file area to be exported on the target page into a paginated PDF file;

[0009] Obtain target image data of the area of ​​the PDF file to be exported;

[0010] Determining expected paging lines for exporting the paging PDF file from the target image data according to the PDF page requirements; and

[0011] If there is no content in the expected paging line, the expected paging line is determined as the target paging line of the paging PDF file, so as to obtain and export the paging PDF file.

[0012] In a second aspect, this specification provides a system for exporting paginated PDF files, including:

[0013] at least one storage medium storing at least one instruction set for exporting a paginated PDF file;

[0014] At least one processor is communicatively connected to the at least one storage medium, wherein when the at least one processor is running, it reads the at least one instruction set and executes the method as described in the first aspect according to the instructions of the at least one instruction set.

[0015] In a third aspect, the present specification provides a computer-readable non-temporary storage medium, wherein the computer-readable non-temporary storage medium stores at least one instruction set, and the at least one instruction set is executed by at least one processor to implement the method described in the first aspect.

[0016] It can be seen from the above technical solutions that the method and system for exporting paginated PDF files provided in this specification convert the PDF export of the content in the page into the PDF export of the target image data. Specifically, when there is no content in the expected pagination row, the expected pagination row is used as the target pagination row to complete the export of the paginated PDF file. There is no need to deploy the node.js service, which can avoid the occupation of server resources in the prior art. In addition, it can ensure that the visual effect of the exported paginated PDF file is completely consistent with the original page (i.e., the target page), including fonts, colors, layout, etc.

[0017] Other functions of the method and system for exporting paginated PDF files provided in this specification will be partially listed in the following description. The creative aspects of the method and system for exporting paginated PDF files provided in this specification can be fully explained by practicing or using the methods, systems and combinations described in the following detailed examples. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of this specification, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0019] Figure 1 A schematic diagram of an application scenario of the method for exporting a paginated PDF file provided in an embodiment of this specification;

[0020] Figure 2 A schematic diagram of the structure of a paginated PDF file export system provided in an embodiment of this specification;

[0021] Figure 3 A flowchart of a method for exporting a paginated PDF file provided in an embodiment of this specification;

[0022] Figure 4 A schematic diagram of the principle of the method for exporting a paginated PDF file provided in an embodiment of this specification;

[0023] Figure 5 A schematic diagram of the principle of determining binary image data provided in an embodiment of this specification;

[0024] Figure 6 A schematic diagram of the principle of the paging effect provided by an embodiment of this specification;

[0025] Figure 7 A schematic diagram comparing the effects of using the method for exporting a paginated PDF file provided in this manual and not using the method for exporting a paginated PDF file provided in this manual;

[0026] Figure 8 A schematic diagram of the principle of the paging effect provided by another embodiment of this specification;

[0027] Fig. 9 A schematic diagram of the principle of the paging effect provided by another embodiment of this specification;

[0028] Fig.10 A schematic diagram of the principle of determining a target paging row provided in an embodiment of this specification. DETAILED DESCRIPTION

[0029] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.

[0030] It should be understood that the terms "including" and "having" and any variations thereof in the embodiments of this specification are intended to cover but not exclude inclusion. For example, a product or device comprising a series of components is not necessarily limited to those components explicitly listed, but may include other components not explicitly listed or inherent to these products or devices.

[0031] In the embodiments of this specification, the term "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0032] The term "plurality" in the embodiments of the present specification refers to two or more than two, and other quantifiers are similar thereto.

[0033] The terms "first", "second", "third", etc. in this specification are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise indicated. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, for example, they can be implemented in an order other than those given in the diagrams or descriptions of the embodiments of this specification.

[0034] The term "unit / module" as used in this specification refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic or combination of hardware and / or software code that is capable of performing the functions associated with that element.

[0035] To facilitate readers' understanding of this specification, the application scenarios of this specification are now introduced.

[0036] The technical solution provided in this specification is applicable to the scenario where the content in the browser needs to be exported as a paginated PDF file. Exemplarily, the technical solution provided in this specification can be applicable to the scenario where web page content, forms, reports, etc. are exported as paginated PDF files.

[0037] For example, take the PDF export scenario of web page content as an example:

[0038] Through the technical solution provided in this manual, users can export web articles, news reports or blog posts of their interest as paginated PDF files for offline reading or archiving.

[0039] Figure 1 FIG. 1 is a schematic diagram of an application scenario of a method for exporting a paginated PDF file (hereinafter referred to as the export method) according to an embodiment of the present specification. The export method of the present specification can be applied to: Figure 1 The export scene 100 is shown. Figure 1 As shown, the export scenario 100 may include a target user 101 and a client 102. In some embodiments, as Figure 1 As shown, the export scenario 100 may further include a server 103 and a network 104 .

[0040] The target user 101 may be a user who triggers an export operation for exporting a paginated PDF file. For example, the target user 101 may perform a target operation on the client 102 to trigger the client 102 to export a paginated PDF file.

[0041] The client 102 may be an electronic device that provides an interactive function to the target user 101. For example, the client 102 may provide an interactive page to the target user 101, and the target user 101 may perform interactive operations in the interactive page.

[0042] In some embodiments, the client 102 executes the export method described in this specification in response to detecting the export operation triggered by the target user 101. At this time, the client 102 may store data or instructions for executing the export method described in this specification, and may execute or be used to execute the data or instructions. In some embodiments, the client 102 may include a hardware device with a data information processing function and a necessary program required to drive the hardware device to work, so as to execute the export method described in this specification.

[0043] In some embodiments, the client 102 may include a mobile device, a tablet computer, a laptop computer, a built-in device of a motor vehicle, or the like, or any combination thereof. In some embodiments, the mobile device may include a smart home device, a smart mobile device, a virtual reality device, an augmented reality device, or the like, or any combination thereof. In some embodiments, the smart home device may include a smart TV, a desktop computer, or the like, or any combination thereof. In some embodiments, the smart mobile device may include a smart phone, a personal digital assistant, a gaming device, a navigation device, or the like, or any combination thereof. In some embodiments, the built-in device in a motor vehicle may include an onboard computer, an onboard TV, or the like. In some embodiments, the client 102 may include a collection device for collecting export operations triggered by the target user 101.

[0044] In some embodiments, the client 102 may be installed with one or more applications (Application, APP). APP can provide the target user 101 with the ability and interface to interact with the outside world through the network 104. APP includes but is not limited to: web browser APP programs, search APP programs, chat APP programs, shopping APP programs, video APP programs, financial management APP programs, instant messaging tools, email clients, social platform software, etc. In some embodiments, the client 102 may be installed with a target APP. The target APP can collect and export operations for the client 102.

[0045] Exemplarily, the client 102 is installed with a web browser APP program. The target user 101 can view web articles through the web browser APP program. For the web articles that the target user 101 is interested in, the target user 101 can initiate a request to export the web articles that the target user 101 is interested in as paginated PDF files through the interactive page. Accordingly, the client 102 can execute the export method provided in this specification to export the web articles that the target user 101 is interested in as paginated PDF files.

[0046] like Figure 1As shown, the client 102 can be connected to the server 103 for communication. The server 103 can be connected to one client 102 for communication, or can be connected to multiple clients 102 for communication. In some embodiments, the client 102 can interact with the server 103 through the network 104 to receive or send messages, etc.

[0047] The server 103 may be a server that provides various services. For example, the server 103 may be a cloud server or a local server. The server 103 may be connected to a client 102 for communication and receive data sent by the client 102, or may be connected to multiple clients 102 for communication and receive data sent by each client 102.

[0048] In some embodiments, the export method described in this specification may be executed on the server 103. In this case, the server 103 may store data or instructions for executing the export method described in this specification, and may execute or be used to execute the data or instructions. The server 103 may include a hardware device with a data information processing function and a necessary program required to drive the hardware device to work.

[0049] For example, in combination with the above example, the client 102 sends a request to the server 103 that the target user 101 can initiate through the interactive page to export the web page article that the target user 101 is interested in as a paginated PDF file. Accordingly, the server 103 receives the request forwarded by the client 102, and executes the export method provided in this specification to export the web page article that the target user 101 is interested in as a paginated PDF file, and outputs it to the target user 101 through the client 102.

[0050] The network 104 is a medium for providing a communication connection between the client 102 and the server 103. The network 104 can facilitate the exchange of information or data. Figure 1 As shown, the client 102 and the server 103 can be connected to the network 104 respectively, and transmit information or data to each other through the network 104.

[0051] In some embodiments, the network 104 may be any type of wired or wireless network, or a combination thereof. For example, the network 104 may include a cable network, a wired network, a fiber optic network, a telecommunications network, an intranet, the Internet, a local area network (LAN), a wide area network (WAN), a wireless local area network (WLAN), a metropolitan area network (MAN), a public switched telephone network (PSTN), a Bluetooth network TM, a short-range wireless network (ZigBee TM), a near field communication (NFC) network, or a similar network.

[0052] In some embodiments, the network 104 may include one or more network access points. For example, the network 104 may include a wired or wireless network access point, such as a base station or an Internet exchange point, through which one or more components of the client 102 and the server 103 can connect to the network 104 to exchange data or information.

[0053] It is worth mentioning that Figure 1 The number of clients 102, servers 103 and networks 104 in the embodiment is only illustrative. Any number of clients 102, servers 103 and networks 104 may be provided as required.

[0054] In addition, the export method provided in this specification can be completely executed on the client 102 without occupying server resources. Alternatively, it can also be completely executed on the server 103. Alternatively, it can also be partially executed on the client 102 and partially executed on the server 103.

[0055] That is to say, the above examples are only used to illustrate the application scenarios to which the export method of this specification may be applicable, and cannot be understood as a limitation on the application scenarios.

[0056] Figure 2The hardware structure diagram of an export system 200 (hereinafter referred to as the export system 200) for paginated PDF files provided according to an embodiment of the present specification is shown. The export system 200 can execute the export method described in the present specification. The export method is introduced in other parts of the present specification. When the export method is executed on the client 102, the export system 200 can be the client 102. When the export method is executed on the server 103, the export system 200 can be the server 103. When the export method is partially executed on the client 102 and partially executed on the server 103, the export system 200 can be a system including the client 102 and the server 103.

[0057] like Figure 2 As shown, the export system 200 may include at least one storage medium 203 and at least one processor 202. In some embodiments, the export system 200 may further include a communication port 204 and an internal communication bus 201. The export system 200 may further include an I / O component 205.

[0058] The internal communication bus 201 can connect different system components. For example, the internal communication bus 201 can connect the storage medium 203, the processor 202, the communication port 204 and the I / O component 205.

[0059] I / O component 205 supports input / output between export system 200 and other components.

[0060] The communication port 204 is used for data communication between the export system 200 and the outside world. For example, the communication port 204 can be used for data communication between the query system 200 and the network 104. The communication port 204 can be a wired communication port or a wireless communication port.

[0061] The storage medium 203 may include a data storage device. The data storage device may be a non-temporary storage medium or a temporary storage medium. For example, the data storage device may include one or more of a disk 2031, a read-only storage medium (ROM) 2032, or a random access storage medium (RAM) 2033. The storage medium 203 also includes at least one instruction set stored in the data storage device. The instruction set includes computer program code, and the computer program code may include a program, a routine, an object, a component, a data structure, a process, a module, etc. that executes the export method provided in this specification.

[0062] At least one processor 202 may be connected in communication with at least one storage medium 203. At least one processor 202 is used to execute the above-mentioned at least one instruction set. When the export system 200 is running, at least one processor 202 reads the at least one instruction set and executes the export method provided in this specification according to the instructions of the at least one instruction set. The processor 202 may execute all the steps included in the export method. The processor 202 may be in the form of one or more processors. In some embodiments, the processor 202 may include one or more hardware processors, such as a microcontroller, a microprocessor, a reduced instruction set computer (RISC), an application-specific integrated circuit (ASIC), an application-specific instruction set processor (ASIP), a central processing unit (CPU), a graphics processing unit (GPU), a physical processing unit (PPU), a microcontroller unit, a digital signal processor (DSP), a field programmable gate array (FPGA), an advanced RISC machine (ARM), a programmable logic device (PLD), any circuit or processor capable of performing one or more functions, etc., or any combination thereof.

[0063] For illustration purposes only, only one processor 202 is shown in the export system 200 in the accompanying drawings. However, it should be noted that the export system 200 in this specification may also include multiple processors, and therefore, the operations and / or method steps disclosed in this specification may be performed by one processor or by multiple processors in combination. For example, if the processor 202 of the export system 200 is described in this specification as performing steps A and B, it should be understood that steps A and B may also be performed jointly or separately by two different processors 202 (e.g., the first processor performs step A, the second processor performs step B, or the first and second processors perform steps A and B together).

[0064] See also Figure 3 , Figure 3 This is a flow chart of the export method provided in the embodiment of this specification. Figure 3 As shown, the method includes the following S301 to S304:

[0065] S301: Obtain an export request, wherein the export request is used to request to export the content of the PDF file area to be exported on the target page into a paginated PDF file.

[0066] The target page can be understood as a page to which a PDF file needs to be exported. For example, in conjunction with the above example, in a PDF export scenario of web page content, the target page can be a web page including articles that the target user is interested in.

[0067] The PDF file area to be exported can be understood as the area where the PDF file needs to be exported. Continuing with the above example, the webpage may include a lot of content, and the target user may be interested in at least part of the content in the webpage, and the area corresponding to the at least part of the content is the PDF file area to be exported.

[0068] Combination Figure 1 In the application scenarios and the above examples shown, the target user 101 may interact with the client 102 , such as the target user 101 may initiate an export request to the client 102 .

[0069] In some embodiments, the target user 101 can drag a selection box or select a coordinate range in the interactive page output by the client 102 to determine the content he is interested in. Accordingly, the area corresponding to the selection box or the coordinate range dragged by the target user 101 is the area of ​​the PDF file to be exported.

[0070] S302: Obtain target image data of the area of ​​the PDF file to be exported.

[0071] In this embodiment, the export system obtains the target image data of the export PDF file area. For example, the export system obtains the image of the article that the target user is interested in to obtain the corresponding target image data. The target image data can be understood as image data that characterizes the information in the export PDF file area.

[0072] In some embodiments, S302 may include the following S21 to S23:

[0073] S21: Obtaining, from the target page, image data to be processed in the area of ​​the PDF file to be exported.

[0074] The image data to be processed can be understood as Canvas image data of the area to be exported as a PDF file.

[0075] S22: If the image data to be processed is smaller than a preset safety pixel threshold, the image data to be processed is determined as target image data.

[0076] The safe pixel threshold can be understood as the number of pixels carried in the image data to be processed does not exceed the maximum safe pixel of the Canvas element of the browser of the output target page.

[0077] For example, the export system may determine the relationship between the number of pixels carried by the image data to be processed and the safety pixel threshold (ie, the maximum safety pixel).

[0078] If the image data to be processed is less than a preset safety pixel threshold, that is, the image data to be processed does not reach the maximum safety pixel, the export system may determine the image data to be processed as the target image data.

[0079] S23: If the image data to be processed reaches the safe pixel threshold, the image data to be processed is processed in slices to obtain target image data.

[0080] Combined with the above analysis, the image data to be processed may be greater than or equal to the preset safe pixel threshold, that is, the image data to be processed reaches the maximum safe pixel. Then the export system can perform segmentation processing on the image data to be processed to obtain the target image data.

[0081] Exemplary, combined Figure 4 It can be seen that, first, the export system can obtain the HTML content of the area of ​​the PDF file to be exported. Then, the export system can convert the HTML content into target image data based on html2canvas. For example, the export system can convert the HTML content into Canvas image data (i.e., target image data) of preset width and height based on html2canvas.

[0082] For example, the export system may first convert HTML content into Canvas image data based on html2canvas, that is, obtain the image data to be processed. Then, the export system may determine the target image data based on whether the Canvas image data meets the maximum safe pixel.

[0083] Specifically, the export system can obtain the pixel information of the corresponding Canvas element based on canvas.getContext('2d').getImageData() to obtain the Canvas image data. The Canvas image data is presented in a one-dimensional array, and each four items of the array complete the color description of a pixel from the color red (R), green (G), blue (B) and transparency (A). That is, the Canvas image data obtained by the export system is an array of pixel information described based on R, G, B, and A.

[0084] Combined with the above analysis of S21 to S23, it can be seen that in this embodiment, the export system determines the image data to be processed that does not reach the safety pixel threshold as the target image data. That is, for smaller image data to be processed, the export system can perform subsequent processing to maintain the integrity and high quality of the image data to be processed, while reducing unnecessary processing steps and improving export efficiency. The export system performs slicing processing on the image data to be processed that reaches the safety pixel threshold. It can effectively avoid performance problems and file size problems caused by excessively large target image data, such as ensuring the balance between the quality of the target image data and the file size, while improving processing efficiency and security. Moreover, slicing processing can improve processing efficiency and reduce memory usage.

[0085] S303: Determine expected paging lines for exporting the paging PDF file from the target image data according to the PDF page requirement.

[0086] The PDF page requirement can be understood as a single-page PDF requirement in a paginated PDF file, such as a size requirement. For example, the PDF page requirement can represent that the size of a PDF page is A4 paper size.

[0087] This embodiment does not limit the way in which the export system obtains the PDF page requirement. For example, the export system can determine it based on its interaction with the target user, historical records, experiments, etc.

[0088] For example, the export system determines the PDF page requirements based on the interaction with the target user: the export system can output an interactive interface, which includes configuration information options of the PDF page, such as A4, suitable for printing, etc. The target user can select A4 in the configuration information options.

[0089] Correspondingly, the expected page break line can be understood as a page break line (or page break line, cutoff point) determined based on the size of the PDF file to be exported on demand.

[0090] Correspondingly, this step can be understood as that after obtaining the target image data, the export system can determine the page lines of the PDF file to which the target image data needs to be exported.

[0091] In some embodiments, the export system may determine the expected paging line based on the user's export requirements. For example, if the target user expects the size of the exported PDF file to be A4, that is, the paper size is A4, then the expected paging line is the line in the target image data that is located at the A4 size.

[0092] In some embodiments, S303 may include the following S31 and S32:

[0093] S31: Determine the binarized image data of the target image data.

[0094] Binarization of image data can be understood as the conversion of pixels in the target image data into black and white values, that is, simplifying the target image data into black and white values.

[0095] Among them, the export system can determine the binary image data based on a global threshold method, a local threshold method, etc.

[0096] It is worth noting that the binary image data only contains black and white. Therefore, in this embodiment, the export system can improve the export efficiency and accuracy by converting the target image data into the binary image data so as to subsequently export the paginated PDF file based on the binary image data.

[0097] In some embodiments, after the export system determines the binary image data, a denoising process may be performed, which includes but is not limited to morphological operations (such as erosion and dilation) or connected domain analysis.

[0098] In comparison, noise points (such as isolated white values ​​and / or black values) in the binary image data can be avoided through denoising processing.

[0099] It is worth noting that the target image data may be color image data or black and white image data, and in most cases it is color image data.

[0100] In some embodiments, when the target image data is color image data, S31 may include the following S311 and S312:

[0101] S311: Perform grayscale processing on the target image data to obtain grayscale image data.

[0102] Grayscale processing can be understood as converting color image data (usually in RGB format) into grayscale image data. In color image data, each pixel is represented by three channels: red (R), green (G), and blue (B). Grayscale image data is represented by one channel, such as brightness or intensity.

[0103] like Figure 4 As shown, after obtaining the target image data, the export system can perform grayscale processing on the target image data to obtain grayscale image data. Figure 5 It can be seen that the export system can perform grayscale processing on the target image data based on the grayscale algorithm to obtain grayscale image data.

[0104] The export system can process the target image data in grayscale by grayscale algorithms such as weighted average method, simple average method, maximum method, minimum method, etc. For example, the grayscale algorithm can be implemented by Y=0.2989·R+0.5870·G+0.1140·B, where Y is the grayscale value.

[0105] S312: Binarize the grayscale image data to obtain binary image data.

[0106] Binarization can be understood as the process of further simplifying grayscale image data into binary data (i.e. black and white image data, also known as binary image data). For example, the export system can simplify the grayscale value of each pixel of the grayscale image data into two possible values: 0 (black) or 255 (white).

[0107] Continue reading Figure 4 After obtaining the grayscale image data, the export system can perform binarization processing on the grayscale image data to obtain binary image data. Figure 5 It can be seen that the export system can perform binarization processing on the grayscale image data based on the threshold comparison method to obtain binary image data.

[0108] For example, after obtaining the grayscale image data, the export system can use a preset color threshold (such as the color threshold provided by the target user) as a comparison benchmark to complete the binarization processing of each pixel through size comparison. The color threshold is recorded in RGBA format.

[0109] Specifically, if the color threshold is X, then for pixels whose grayscale value reaches X, it will be set to white; for pixels whose grayscale value is less than X, it will be set to black.

[0110] Based on the above analysis of S311 and S312, it can be seen that through grayscale processing, storage space and computing costs can be reduced, and the light and dark areas are more obvious, which is conducive to binarization processing. In addition, through binarization processing, pixels can be simplified into black and white states, eliminating the intermediate grayscale transition, making the structure of the binary image data clearer, and improving the accuracy and reliability of exporting paginated PDF files.

[0111] In order to enable readers to further understand the principle of the export system determining the binary image data of the target image data, a detailed explanation is now given taking the row image data of the target image data in the expected paging row as an example.

[0112] Exemplarily, S311 may include: for the row image data of the target image data in the expected paging row, traversing and performing grayscale processing on each pixel information in the row image data to obtain row grayscale image data corresponding to the row image data.

[0113] In combination with the above example, each pixel in the row image data is represented by three channels (red, green, and blue). Each pixel in the row image data is traversed to obtain its RGB value. The grayscale value of the pixel is calculated based on the RGB value. Finally, the row grayscale image data is obtained.

[0114] Accordingly, S312 may include: performing binarization processing on the line grayscale image data to obtain expected page-by-page binarized image data corresponding to the line grayscale image data.

[0115] Continuing with the above example, for pixels in the row grayscale image data, the grayscale value thereof is compared with the preset grayscale threshold value to obtain the expected paged binary image data. For example, for a certain pixel, if the grayscale value of the pixel is less than or equal to the preset grayscale threshold value, the pixel is determined to be black; otherwise, if the grayscale value of the pixel is greater than the preset grayscale threshold value, the pixel is determined to be white.

[0116] S32: Determine expected paging lines from the binary image data according to the PDF page requirements.

[0117] For example, combined with Figure 6 In the PDF export scenario of the web page content, the target user expects the size of the exported PDF file to be A4, that is, the paper size is A4. The export system can determine the row at the A4 size based on the binary image data, and determine the row as the expected paging row.

[0118] Combining the above analysis of S31 and S32, it can be seen that in the embodiment, the export system can improve the accuracy and reliability of determining the expected paging row by first determining the binary image data and then determining the expected paging row.

[0119] S304: If there is no content in the expected paging line, the expected paging line is determined as a target paging line of the paging PDF file, so as to obtain and export the paging PDF file.

[0120] Exemplarily, the export system can determine whether there is content in the expected paging line. If not, that is, the expected paging line is a blank line, the export system can use the expected paging line as the paging line (i.e., the target paging line) of the final exported paging PDF file. Moreover, the export system can export the paging PDF file based on the target paging line.

[0121] Combined with the above analysis of S301 to S304, it can be known that in the embodiment, the PDF export of the content in the page is converted into the PDF export of the target image data. Specifically, when there is no content in the expected paging row, the expected paging row is used as the target paging row to complete the export of the paging PDF file. There is no need to deploy the node.js service, which can avoid the occupation of server resources in the prior art. In addition, it can be ensured that the visual effect of the exported paging PDF file is completely consistent with the original page (i.e., the target page), including fonts, colors, layout, etc.

[0122] Based on the above analysis, the binary image data includes: the expected paging binary data of the target image data at the expected paging line. In some embodiments, the export method provided in this specification may also include S305: determining whether there is content in the expected paging line according to the expected paging binary image data.

[0123] Exemplarily, after obtaining the expected paging binary image data, the export system may determine whether there is text, picture or other content in the expected paging row based on the expected paging binary image data.

[0124] In some embodiments, S305 may include the following steps 1 and 2:

[0125] Step 1: In the expected paging line, determine the horizontal projection data of the expected paging binary image data, wherein the horizontal projection data is the accumulated value of the foreground pixels of the expected paging line in the horizontal direction.

[0126] In combination with the above example, during the binarization process, the export system can use the color threshold as a comparison benchmark to perform binarization on the grayscale image data. For example, the export system can mark the binarization value of pixels above the color threshold as 1 (corresponding to white), and mark the binarization value of pixels below the color threshold as 0 (corresponding to black), so as to obtain the expected paging binary image data.

[0127] In this step, the export system can count the cumulative value of the foreground pixels in the expected paging binary image data, that is, the total number of foreground pixels in the horizontal direction of the expected paging line. For example, if the foreground pixel is 1 and the background pixel is 0, the horizontal projection data is the cumulative value of the pixel being 1 in the expected paging binary image data.

[0128] Step 2: Determine whether there is content in the expected paging row according to the horizontal projection data of the expected paging binary image data.

[0129] That is, in this embodiment, the export system can determine whether there is content in the expected paging line based on the horizontal projection data, so as to perform paging processing on the target image data based on the horizontal projection data. Figure 4 As shown, after the binarization process, the export system can perform paging process on the target image data based on the horizontal projection data.

[0130] Combining the above analysis of step 1 and step 2, it can be seen that in this embodiment, the export system can intuitively reflect the distribution of white pixels in the expected paging line by calculating the horizontal projection data. Therefore, the export system determines whether there is content in the expected paging line through the horizontal projection data to paging the target image data, which can improve the accuracy and reliability of paging.

[0131] In some embodiments, step 2 may include the following two situations:

[0132] Case 1: If the proportion of the accumulated value in the expected paging row in the horizontal direction reaches a preset proportion threshold, it is determined that there is content in the expected paging row.

[0133] Case 2: If the proportion of the accumulated value in the expected paging row in the horizontal direction is less than the preset proportion threshold, it is determined that there is no content in the expected paging row.

[0134] Exemplarily, in this embodiment, the export system can compare the proportion of the accumulated value with a preset proportion threshold to determine whether the proportion of the accumulated value is relatively large or relatively small. If it is relatively large, it is the above situation 1; otherwise, if it is relatively small, it is the above situation 2.

[0135] For example, if the proportion of elements marked as 1 in the horizontal direction of the expected paging row is higher than the preset proportion threshold given by the target user, the export system records the expected paging row as 'the current row is not blank'; otherwise, the export system records the expected paging row as 'the current row is blank'.

[0136] In this embodiment, through the above two situations, the export system can effectively and accurately distinguish whether the expected paging is a non-blank line or a blank line, thereby improving the accuracy and reliability of paging.

[0137] It is worth noting that in the above example, the export system counts the cumulative values ​​of foreground pixels. In other embodiments, the export system may also count the cumulative values ​​of background pixels. For example, in the case of counting the cumulative values ​​of background pixels, the export system may determine that there is no content in the expected page if the cumulative value accounts for a large proportion; and determine that there is content in the expected page if the cumulative value accounts for a small proportion.

[0138] Correspondingly, if there is no content in the expected paging line, the expected paging line is determined as the target paging line of the paging PDF file, so as to obtain and export the paging PDF file.

[0139] For example, as a possible case, it is expected that there is no text, picture or other content in the paging line. In this case, if Figure 6 As shown, the export system can determine the expected paging line as the target paging line of the paginated PDF file to obtain and export the paginated PDF file.

[0140] Based on the above analysis of S305, it can be seen that in this embodiment, the export system determines that there is no content in the expected paging line, and determines the expected paging line as the target paging line of the paging PDF file to obtain and export the paging PDF file. Figure 7 As shown, by comparing (VS) without and with the export method provided in this manual, it can be seen that the export method provided in this manual can avoid truncating the exported content where there is content, that is, avoid the exported paginated PDF file from being truncated where there is content, which can improve the accuracy and reliability of pagination, thereby improving the user's export and reading experience.

[0141] As another possible situation, the expected paging line contains text, pictures and other contents. In this case, the export method provided in this specification may also include: if there is content in the expected paging line, taking the expected paging line as a reference, shifting upward by preset pixel steps in sequence until a target paging line of the paging PDF file that meets the preset conditions is determined, so as to obtain and export the paging PDF file, and taking the browsing perspective of browsing the target page as a reference upward.

[0142] The preset conditions include: there is no content in the target paging row, and the distance between the target paging row and the expected paging row is less than a preset safety threshold.

[0143] That is to say, when there is content in the expected paging line, the export system can determine the target paging line of the paging PDF file that meets the preset conditions based on the preset pixel step in a line smaller than the expected paging line to obtain and export the paging PDF file.

[0144] Exemplarily, in the case where there is content in the expected paging line, the export system may further determine a target paging line without content, so as to page the target image data and export the paging PDF file.

[0145] The preset pixel stepping can be understood as the step length used to determine the page line without content, such as the number of pixels moved each time. This embodiment does not limit the size of the preset pixel stepping, which can be determined by the export system based on demand, historical records, experiments, etc. For example, the preset pixel stepping can be a quarter of the root font size of the target page (generally 4 pixels px).

[0146] The preset conditions can be understood as the criteria for determining whether a suitable paging row is found, which mainly include the criteria in the following two dimensions.

[0147] Dimension 1: There is no content in the paging line. That is, there is no obvious text, image or other content in the detected paging line area. Combined with the above analysis, it can be seen that dimension 1 can be achieved by analyzing the binary image data of the paging line.

[0148] Dimension 2: The distance between the paging line and the expected paging line is less than the preset safety threshold. That is, the vertical distance between the detected paging line and the expected paging line must be less than a preset safety threshold. The size of this safety threshold can be adjusted according to the page layout and content density, usually to ensure that the target paging line is not too close to other content to avoid false detection.

[0149] Combination Figure 8 It can be seen that if there is content in the expected paging line, the preset pixel step is moved upward on the basis of the expected paging line to determine whether the line has content. If not, the line is used as the target paging line to obtain and export the paging PDF file.

[0150] On the contrary, if there is, the preset pixel step is continued to be moved upward based on the row to determine whether the row to be determined again has content. This process is repeated until a row without content is obtained, and the distance between the row without content and the expected paging row is less than the preset safety threshold.

[0151] For example, when the preset pixel step is moved upward on the basis of the expected paging line for the third time, a line without content is obtained, and the distance between the line and the expected paging line is still within the range of the preset safety threshold. Then, the line without content obtained by the third movement is determined as the target paging line of the paging PDF file, so as to obtain and export the paging PDF file.

[0152] That is, the export system can determine a preset safety interval based on the preset safety threshold based on the expected paging behavior. The distance between any row in the preset safety interval and the expected paging row is less than the preset safety threshold. The export system can move up the preset pixel steps in sequence within the preset safety interval based on the expected paging behavior to take the first row without content as the target paging row.

[0153] Combined with the above analysis, it can be known that in this embodiment, the detection range is gradually narrowed by combining the preset pixel step to obtain a target paging row without content, and the distance between the detected target paging row and the expected paging row is within the preset safety interval. It can effectively avoid mistaking other rows in the page as target paging rows. It is ensured that the detected target paging row is a blank area, which improves the accuracy and reliability of determining the paging row. Moreover, it can be ensured that the distance between the determined target paging row and the expected paging row is not too large, which helps to maintain the overall aesthetics and readability of the page, thereby improving the user experience.

[0154] According to the above analysis, the target paging row determined based on the preset pixel step has no content, and the distance between the target paging row and the expected paging row is less than the preset safety interval.

[0155] However, in another possible situation, the export system fails to detect a line without content within a preset safety interval based on the expected paging line. In view of this situation, the export method provided in this specification also includes: if the distance between the line corresponding to the nth upward offset by the preset pixel step and the expected paging line reaches a preset safety threshold when the nth upward offset by the preset pixel step reaches a preset safety threshold, then the expected paging line is determined as the paging line of the paging PDF file to obtain and export the paging PDF file, where n is an integer greater than 1.

[0156] For example, Fig. 9As shown in the figure, there is content in the expected paging line, and when the number of preset pixel steps is moved up based on the expected paging line reaches 4 times, the paging line without content is still not determined. When moving up again, it has exceeded the preset safety interval of the expected paging line (that is, the distance from the expected paging line exceeds the preset safety threshold). Then the export system determines the expected paging line as the target paging line. This avoids inserting paging lines too frequently in the exported paging PDF file, resulting in excessive paging. And the overall structure and logical integrity of the target page content can be maintained.

[0157] In some embodiments, for this situation, the export system can adjust the preset pixel stepping based on the actual situation of the application scenario. For example, the export system can reduce the preset pixel stepping based on the actual content to be exported to obtain a better effect.

[0158] Alternatively, the export system may interact with the target users to obtain the adjusted preset pixel stepping determined by the target users through interaction. For example, the target users may select to appropriately reduce the pixel stepping through the interactive page output by the client to determine the pixel stepping equivalent to the actual content.

[0159] Combined with the above analysis, we can see that the principle of the export system determining the target paging row can be found in Fig.10 .like Fig.10 As shown, the export system determines whether there is content in the expected page break line. If there is no content in the expected page break line, the export system determines the expected page break line as the target page break line to obtain and export the paginated PDF file.

[0160] On the contrary, if there is content in the expected paging line, the export system offsets the expected paging line upward by a preset pixel step, such as offsetting x pixels upward. On this basis, the export system determines whether the distance between the offset line and the expected paging line exceeds a preset safety threshold. If it exceeds the preset safety threshold, the export system determines the expected paging line as the target paging line to obtain and export the paging PDF file.

[0161] On the contrary, if the preset safety threshold is not exceeded, the export system determines whether the offset row has content. If there is no content in the offset row, the export system determines the offset row as the target paging row to obtain and export the paging PDF file.

[0162] Conversely, if there is content in the offset line, the export system continues to offset x pixels upward on the offset line.

[0163] And so on, until the target paging row is obtained, so as to obtain and export the paginated PDF file.

[0164] It is worth noting that, combined with the above analysis, it can be seen that there may be content or no content in the expected paging line. If there is no content in the expected paging line, the export system can determine the expected paging line as the target paging to obtain and export the paging PDF file. On the contrary, if there is content in the expected paging line, it is necessary to determine the target paging in combination with the preset pixel step and the preset safety interval to obtain and export the paging PDF file. Whether there is content in the expected paging line or the offset line is determined based on its binary image data.

[0165] Therefore, in some embodiments, when determining the binarized image data corresponding to the target image data, the export system may binarize the target image data that may require the binarized image data.

[0166] That is to say, when determining the binarized image data, the export system can determine the global binarized image data, that is, the binarized image data corresponding to each row of image data in the target image data; it can also determine the local binarized image data, that is, the binarized image data corresponding to the row image data of the target paging row within a preset safety interval.

[0167] Relatively speaking, the export system can save resources and corresponding performance and improve export efficiency by obtaining local binary image data.

[0168] It is worth noting that the above examples are only used to illustrate the possible implementation methods of the derivation method of this specification, and cannot be understood as limiting the implementation methods of the derivation method of this specification. For example, based on the above technical concept, some of the above technical features can be combined to obtain a new embodiment; new technical features can be added on the basis of the above examples to obtain a new embodiment; some technical features can be reduced on the basis of the above examples to obtain a new embodiment; some technical features in the above examples can be replaced with other technical features; some technical features and the order of the above examples can be adjusted to obtain a new embodiment, etc., which will not be listed here one by one.

[0169] Based on the above technical concept, this specification also provides a computer-readable non-temporary storage medium, which stores at least one instruction set. When the at least one instruction set is executed by a processor, the steps of the export method described in this specification are implemented.

[0170] In some possible implementations, various aspects of this specification may also be implemented in the form of a program product, which includes a program code. When the program product is run on the export system 200, the program code is used to make the export system 200 perform the steps of the export method described in this specification. The program product for implementing the above method may include program code using a portable compact disk read-only memory (CD-ROM) and may be run on the export system 200. However, the program product of this specification is not limited to this, and in this specification, a readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system or used in combination with it. The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples of readable storage media include: an electrical connection with one or more conductors, a portable 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. The computer-readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above. Program code for performing the operations of the present specification may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the export system 200, partially on the export system 200, as a stand-alone software package, partially on the export system 200 and partially on a remote export system, or entirely on a remote export system 200.

[0171] The above is a description of a specific embodiment of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require a specific order or a continuous order to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0172] In summary, after reading this detailed disclosure, those skilled in the art will appreciate that the foregoing detailed disclosure may be presented only by way of example and may not be limiting. Although not explicitly stated herein, those skilled in the art will appreciate that this specification requires various reasonable changes, improvements and modifications to the embodiments. These changes, improvements and modifications are intended to be proposed by this specification and are within the spirit and scope of the exemplary embodiments of this specification.

[0173] In addition, certain terms in this specification have been used to describe embodiments of this specification. For example, "one embodiment", "an embodiment" and / or "some embodiments" mean that a particular feature, structure or characteristic described in conjunction with the embodiment may be included in at least one embodiment of this specification. Therefore, it can be emphasized and should be understood that two or more references to "an embodiment" or "one embodiment" or "an alternative embodiment" in various parts of this specification do not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics may be appropriately combined in one or more embodiments of this specification.

[0174] It should be understood that in the foregoing description of the embodiments of this specification, in order to help understand a feature and for the purpose of simplifying this specification, this specification combines various features in a single embodiment, figure or its description. However, this does not mean that the combination of these features is necessary. When reading this specification, it is entirely possible for a person skilled in the art to mark out some of the devices as separate embodiments. In other words, the embodiments in this specification can also be understood as the integration of multiple secondary embodiments. And the content of each secondary embodiment is also valid when it is less than all the features of a single aforementioned disclosed embodiment.

[0175] Each patent, patent application, patent application publication, and other material, such as articles, books, specifications, publications, documents, literature, etc., cited herein (excluding any historical review documents related thereto) is hereby incorporated by reference for all purposes relevant to this document, such as in the specification and claims herein. However, if there is any inconsistency or conflict between the descriptions, definitions, and / or terminology of the aforementioned materials and the descriptions, definitions, and / or terminology used herein, the descriptions, definitions, and / or terminology used herein shall prevail.

[0176] Finally, it should be understood that the embodiments of the application disclosed herein are explanations of the principles of the embodiments of this specification. Other modified embodiments are also within the scope of this specification. Therefore, the embodiments disclosed in this specification are only used as examples and not as limitations. Those skilled in the art can adopt alternative configurations according to the embodiments in this specification to implement the applications in this specification. Therefore, the embodiments of this specification are not limited to the embodiments accurately described in the application.

Claims

1. A method for exporting a paginated PDF file, comprising: Obtaining an export request, wherein the export request is used to request to export the content of the PDF file area to be exported on the target page into a paginated PDF file; Obtain target image data of the area of ​​the PDF file to be exported; Determining expected paging lines for exporting the paging PDF file from the target image data according to the PDF page requirements; and If there is no content in the expected paging line, the expected paging line is determined as the target paging line of the paging PDF file, so as to obtain and export the paging PDF file.

2. The method according to claim 1, wherein: The step of determining, from the target image data according to the PDF page requirement, an expected paging row for exporting the paging PDF file comprises: Determining binarized image data of the target image data; and The expected paging line is determined from the binarized image data according to the PDF page requirement.

3. The method according to claim 2, wherein: The binary image data includes: the expected paging binary image data of the target image data at the expected paging line; the method further includes: According to the expected paging binary image data, it is determined whether there is content in the expected paging row.

4. The method according to claim 3, wherein: The step of determining whether there is content in the expected paging row according to the expected paging binary image data comprises: In the expected paging line, determining horizontal projection data of the expected paging binary image data, wherein the horizontal projection data is an accumulated value of foreground pixels in the expected paging line in a horizontal direction; and It is determined whether there is content in the expected paging row according to the horizontal projection data of the expected paging binary image data.

5. The method according to claim 4, wherein: The determining, according to the horizontal projection data of the expected paging binary image data, whether there is content in the expected paging row comprises: If the proportion of the accumulated value in the horizontal direction of the expected paging row reaches a preset proportion threshold, it is determined that there is content in the expected paging row; If the proportion of the accumulated value in the horizontal direction of the expected paging row is less than a preset proportion threshold, it is determined that there is no content in the expected paging row.

6. The method according to claim 3, wherein: The method further comprises: If there is content in the expected paging line, the expected paging line is used as a reference, and the preset pixel steps are shifted upward in sequence until a target paging line of the paging PDF file that meets the preset conditions is determined, so as to obtain and export the paging PDF file, and the browsing angle of browsing the target page is used as a reference upward; The preset conditions include: there is no content in the determined target paging row, and the distance between the determined target paging row and the expected paging row is less than a preset safety threshold.

7. The method according to claim 6, wherein: The method further comprises: If, when the preset pixel step is shifted upward for the nth time, the distance between the row corresponding to the preset pixel step shifted upward for the nth time and the expected paging row reaches the preset safety threshold, the expected paging row is determined as the target paging row of the paging PDF file to obtain and export the paging PDF file, wherein n is an integer greater than 1.

8. The method according to any one of claims 2 to 7, wherein: The target image data is color image data; and the step of determining the binary image data of the target image data comprises: Performing grayscale processing on the target image data to obtain grayscale image data; and The grayscale image data is binarized to obtain the binarized image data.

9. The method according to claim 8, wherein: The grayscale processing of the target image data to obtain grayscale image data includes: For the row image data of the target image data at the expected paging row, traverse and perform grayscale processing on each pixel information in the row image data to obtain row grayscale image data corresponding to the row image data; Furthermore, the binarization processing of the grayscale image data to obtain the binarized image data includes: binarization processing of the row grayscale image data to obtain expected paged binarized image data corresponding to the row grayscale image data.

10. The method according to any one of claims 1 to 7, wherein: The step of obtaining target image data of the area of ​​the PDF file to be exported comprises: Obtaining, from the target page, image data to be processed in the area of ​​the PDF file to be exported; and If the image data to be processed is smaller than a preset safety pixel threshold, determining the image data to be processed as the target image data; If the image data to be processed reaches the safety pixel threshold, the image data to be processed is processed in slices to obtain the target image data.

11. A paginated PDF file export system, comprising: at least one storage medium storing at least one instruction set for exporting a paginated PDF file; At least one processor is communicatively connected to the at least one storage medium, wherein when the at least one processor is running, the at least one instruction set is read, and the method as described in any one of claims 1 to 10 is executed according to the instructions of the at least one instruction set.