Printing method and system compatible with full page and full display of various browsers
By loading a unified printing style sheet and processing web page content on the server side, the problem of inconsistent printing of web pages in different browsers is solved, and the web page printing effect with neat format and complete content is achieved.
Patent Information
- Application Number
- CN202411848118.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-04-15
AI Technical Summary
The prior art cannot uniformly print web pages with neat formatting and complete content in different browsers, especially the entire web page, content displayed by mouse hovering, and multi-tab content.
Through the browser, the browser calls the printing service on the server side, obtains the URL address of the web page, converts it into the printed URL address, and loads a unified printing style sheet to process the web page content, generates a print layout, and finally saves the processed content in PDF format and returns it to the user.
Ensure that no matter which browser you use, you can print web pages with consistent format and complete content, which solves the problems encountered in traditional printing methods.
Smart Images

Figure CN119828987A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of web page printing, and in particular to a printing method and system compatible with full page display of various browsers. Background Art
[0002] In modern office environments, users often need to print web page content as a record or as a basis for contract signing. However, existing browser printing functions have many limitations, such as the inability to print the entire web page, the inability to print the content displayed when the mouse is hovering, and the inability to print the content of multiple tabs at once. When printing a web page, the printing effects of different browsers may be inconsistent, some content (such as the content displayed when the mouse is hovering) cannot be printed, the content of multiple tabs cannot be fully displayed, and the table display is incomplete. The existing technology cannot uniformly print web pages with neat formatting and complete content in different browsers. Summary of the invention
[0003] The purpose of the present invention is to provide a printing method and system that is compatible with various browsers and can display the entire page, aiming to solve the problem that the prior art cannot uniformly print out web pages with neat formatting and complete content in different browsers.
[0004] To achieve the above object, on the one hand, the present invention provides a printing method compatible with full-page full display of various browsers, the method comprising the following steps:
[0005] The browser side calls the print service on the server side, and the print service obtains the URL address of the current web page and converts it into a print URL address;
[0006] The printing service loads a unified printing style sheet, processes the webpage content, and generates a printing layout;
[0007] The server-side printing service saves the processed web page content in PDF format and returns it to the user.
[0008] Preferably, in the printing method, the printing service loads a unified printing style sheet, and processing the web page includes: displaying all the content that needs to be displayed when the mouse is hovered.
[0009] Preferably, in the printing method, the full display of the mouse hovering content is achieved by modifying the style of the print style sheet or the JavaScript code.
[0010] Preferably, in the printing method, the printing service loads a unified printing style sheet, and processing the web page includes: displaying all the contents displayed by the web page in tabs in a tiled manner.
[0011] Preferably, in the printing method, the flat display of all the contents displayed in the tabs of the web page is achieved through dynamic rendering by a server-side script.
[0012] Preferably, in the printing method, the printing service loads a unified printing style sheet, and the processing of the web page includes displaying all the incomplete contents in the table in a line-wrapped form.
[0013] Preferably, in the printing method, the line break display of the content in the table is achieved by adjusting the style of the print style sheet on the server side.
[0014] Preferably, in the printing method, in the process of processing the web page content, it is necessary to obtain a web page access interface, and determine whether the page content has been loaded according to the configuration of the web page access interface to ensure that the printed content is complete.
[0015] In addition, in another aspect of the present invention, a web page printing system compatible with various browsers is provided, and the web page printing system includes:
[0016] The printing service module is used to obtain the URL address of the web page currently browsed by the user;
[0017] A layout conversion module, used to convert the URL address into a print layout;
[0018] Content display module, used to process mouse hover content, tab page content and table content so that they can be fully displayed in the print layout;
[0019] The PDF conversion module is used to save the print layout in PDF format and return it to the user.
[0020] Preferably, the web page printing system further includes a status judgment module for judging the status of the web page request interface to ensure that the page content is loaded completely.
[0021] Compared with the prior art, the present invention has at least the following technical effects:
[0022] The present invention provides a printing method and system that is compatible with full-page display of various browsers. Printing is performed by calling a back-end server, and a unified printing style sheet is loaded through a server-side printing service to process the web page content. This ensures that no matter which browser is used, a web page with consistent format and complete content can be printed, thereby solving the problems encountered in traditional printing methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 A flow chart of a printing method compatible with full-page display of various browsers in one embodiment of the present invention;
[0024] Figure 2 The present invention is a detailed flow chart of a printing method that is compatible with full-page display of various browsers in one embodiment of the present invention. DETAILED DESCRIPTION
[0025] The following will be described in more detail with reference to the schematic diagram of a printing method and system compatible with full page display of various browsers of the present invention, wherein the preferred embodiment of the present invention is shown, and it should be understood that those skilled in the art can modify the present invention described herein, while still achieving the advantageous effects of the present invention. Therefore, the following description should be understood as being widely known to those skilled in the art, and not as a limitation of the present invention.
[0026] For the sake of clarity, not all features of the actual embodiments are described. In the following description, well-known functions and structures are not described in detail because they would clutter the invention with unnecessary detail. It should be recognized that in the development of any actual embodiment, a large number of implementation details must be made to achieve the developer's specific goals, such as changing from one embodiment to another according to the limitations of the relevant system or the relevant business. In addition, it should be recognized that such development work may be complex and time-consuming, but it is just a routine task for those skilled in the art.
[0027] The present invention is described in more detail in the following paragraphs by way of example with reference to the accompanying drawings. The advantages and features of the present invention will become more apparent from the following description. It should be noted that the accompanying drawings are in very simplified form and are not in exact proportions, and are only used to facilitate and clearly assist in illustrating the purpose of the embodiments of the present invention.
[0028] like Figure 1 and Figure 2 As shown, the present invention provides a printing method compatible with full page display of various browsers, and the method comprises the following steps:
[0029] The browser side calls the print service on the server side, and the print service first obtains the URL address of the current web page and converts it into a print URL address;
[0030] Then, a unified printing style sheet is loaded through the printing service, the webpage content is processed, and a printing layout is generated;
[0031] The server-side printing service saves the processed web page content in PDF format and returns it to the user.
[0032] Specifically, when the user clicks the print button, the browser sends a request to the backend server to call the server-side print service. After receiving the request, the server-side print service first obtains the URL address of the current web page, which points to the page that the user wants to print. The print service converts the obtained URL address into a print URL address. After that, the print service loads a unified print style sheet, processes the web page, and generates a print layout to ensure that the web page content can be displayed as expected when printed.
[0033] In this embodiment, in normal web browsing, some content (such as tooltips, drop-down menus, etc.) will only be displayed when the user hovers the mouse over a specific element. The print service needs to identify these contents and make them all visible in the print layout, rather than only when hovering. This is usually achieved by modifying the print style sheet so that these contents are always visible when printing.
[0034] Specifically, the process of processing a web page by loading a unified print style sheet through the print service involves applying a unified print style sheet (CSS). In this process, the print style sheet will intervene and redefine the interactive visual effects defined by the CSS :hover pseudo-class in the web page elements, that is, those contents that are triggered to display only when the user hovers the mouse over the element. Specifically, the print style sheet will overwrite the original mouse hover effect, so that all hidden content that depends on the :hover pseudo-class is visible by default in the print layout and can be fully displayed without any mouse interaction. This step can ensure the integrity of the print output, so that the printed document can provide the same amount of information as the screen browsing, while avoiding information omissions.
[0035] In this embodiment, the printing service loads a unified printing style sheet, and the processing of the web page includes: realizing the flat display of all the contents displayed by the web page with tabs through dynamic rendering of the server-side script. For a web page with multiple tabs, the user needs to click on different tab pages to view the corresponding content when browsing. The printing service will expand all the contents of these tab pages and display them in the print layout in a top-to-bottom arrangement, so that the user can see the contents of all tab pages when printing, without having to click one by one as in the browser.
[0036] Specifically, the process includes the following steps: For the content displayed through the tab mechanism in the web page, the print style sheet will overwrite the original display properties so that all tab contents are expanded and displayed continuously by default in the print layout, rather than only displaying the content of the currently activated tab. Use server-side scripts to achieve dynamic rendering of tab contents. This process involves executing JavaScript or other client-side scripts on the server to ensure that when the print layout is generated, the content of all tabs is rendered and included in the final print output.
[0037] In this embodiment, the printing service loads a unified printing style sheet, and the processing of the web page includes: displaying the incomplete content in the table in a line-wrapped form, and the line-wrapped display of the content in the table is achieved by adjusting the style of the printing style sheet on the server side.
[0038] Tables on web pages may not be fully displayed in the browser due to their length, and some of their contents may be hidden or truncated. The printing service will adjust the style of these tables, using automatic line breaks or adjusting column widths to ensure that all table contents can be fully displayed when printed without being truncated or hidden.
[0039] Specifically, in the prior art, in a cell of a webpage table, if the text content exceeds the preset display limit, the exceeding part will be omitted and marked with an ellipsis (...). In order to meet the printing requirements, the style sheet of the print style sheet must be modified so that the text in the cell can automatically wrap when the display limit is reached, thereby ensuring that all text content can be fully displayed on the print medium to avoid information loss and misunderstanding.
[0040] It should be noted that if Figure 2 As shown, in the process of processing the web page content, it is necessary to obtain the web page access interface, and determine whether the page content has been loaded according to the configuration of the web page access interface to ensure that the printed content is complete. Specifically, it is necessary to read the relevant configuration content of the web page access interface. If the configuration content does not require waiting for the interface to be completed, then the current state of the web page can be directly saved as a picture without waiting for the interface to be loaded. If the configuration content indicates that you must wait for the interface to be completed to ensure that the page content is loaded, then the following operations will be performed:
[0041] Check whether the web page access interface has been loaded. If the interface has been loaded, save the web page in image format for subsequent printing operations. If the interface has not been loaded, it is necessary to re-acquire the web page access interface and determine whether the page content has been loaded based on the interface again.
[0042] Through the above steps, it can be ensured that when printing web page content, the printed content is as complete as possible, whether the interface has been loaded or there is no need to wait for the interface to be completed. The above method helps to improve the integrity and reliability of web page content printing.
[0043] Finally, the server-side printing service saves the processed web page content as an image, converts the image into a PDF file and returns it to the user, ensuring that the layout and format of the web page processed uniformly by the print style sheet are not destroyed, thereby printing a web page with consistent format and complete content.
[0044] In another aspect of the present invention, a web page printing system compatible with various browsers is provided, the web page printing system comprising:
[0045] The printing service module is used to obtain the URL address of the web page currently browsed by the user;
[0046] A layout conversion module, used to convert the URL address into a print layout;
[0047] Content display module, used to process mouse hover content, tab page content and table content so that they can be fully displayed in the print layout;
[0048] The PDF conversion module is used to save the print layout in PDF format and return it to the user.
[0049] Preferably, the web page printing system further includes a status judgment module for judging the status of the web page request interface to ensure that the page content is loaded completely.
[0050] In summary, in a printing method that is compatible with full-page display of various browsers provided in an embodiment of the present invention, printing is performed by calling a back-end server, and a unified printing style sheet is loaded through the server-side printing service to process the web page content. This can ensure that no matter which browser is used, a web page with consistent format and complete content can be printed, thereby solving the problems encountered in traditional printing methods.
[0051] The above is only a preferred embodiment of the present invention and does not limit the present invention in any way. Any technician in the relevant technical field, without departing from the scope of the technical solution of the present invention, makes any form of equivalent replacement or modification to the technical solution and technical content disclosed in the present invention, which does not depart from the content of the technical solution of the present invention and still falls within the protection scope of the present invention.
Claims
1. A web page printing method compatible with various browsers, characterized in that: The method comprises the following steps: The browser side calls the print service on the server side, and the print service obtains the URL address of the current web page and converts it into a print URL address; The printing service loads a unified printing style sheet, processes the webpage content, and generates a printing layout; The server-side printing service saves the processed web page content in PDF format and returns it to the user.
2. The method according to claim 1, characterized in that The printing service loads a unified printing style sheet, and processes the web page including: displaying all the content that needs to be displayed when the mouse is hovered.
3. The method according to claim 2, characterized in that By modifying the print style sheet or JavaScript code, you can display all the content when the mouse is hovering.
4. The method according to claim 1, characterized in that The printing service loads a unified printing style sheet, and processes the web page including: displaying all the contents displayed by the tabs of the web page in a tiled manner.
5. The method according to claim 4, characterized in that The content displayed by the tabs of the web page is displayed in a tiled manner through dynamic rendering of the server-side script.
6. The method according to claim 1, characterized in that The printing service loads a unified printing style sheet, and processes the web page, including displaying all the incomplete contents in the table in a line-wrapped form.
7. The method according to claim 6, characterized in that The line break display of the content in the table is achieved by adjusting the style of the print style sheet on the server side.
8. The method according to claim 1, characterized in that In the process of processing the web page content, it is necessary to obtain the web page access interface, and determine whether the page content is loaded according to the configuration of the web page access interface to ensure that the printed content is complete.
9. A web page printing system compatible with various browsers, characterized in that: include: The printing service module is used to obtain the URL address of the web page currently browsed by the user; A layout conversion module, used to convert the URL address into a print layout; Content display module, used to process mouse hover content, tab content and table content so that they can be fully displayed in the print layout; The PDF conversion module is used to save the print layout in PDF format and return it to the user.
10. The system according to claim 9, characterized in that It also includes a status judgment module for judging the status of the web page request interface to ensure that the page content is loaded completely.