Method and device for verifying PDF document and electronic equipment
By directly verifying the PDF document generated by the HTML fragment of CSS style debugging in the PDF document, the problem of low verification efficiency in the existing technology is solved, and fast and efficient style verification is achieved.
Patent Information
- Application Number
- CN202410009151.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-02
- Publication Date
- 2024-10-18
AI Technical Summary
In the existing technology, the efficiency of verifying CSS style debugging in PDF documents is low, and each part for debugging needs to be found from the entire document, resulting in long rendering time and difficulty in verification.
Determine the HTML fragments in the HTML document through preset CSS expressions, and generate corresponding PDF documents based on these fragments for style debugging and verification, directly verifying N PDF documents without searching from the PDF full-text document, improving verification efficiency.
It improves the verification efficiency of CSS style debugging, saves performance resources, simplifies the verification process, and enables users to quickly view and adjust style effects.
Smart Images

Figure CN118798169A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a PDF document verification method, device and electronic equipment. Background Art
[0002] At present, in the process of generating a portable document format (PDF) document from a Hyper Text Markup Language (HTML) document, Cascading Style Sheets (CSS) can usually be used to debug the style of the HTML document, thereby debugging the style of the PDF document generated from the HTML document. In the process of debugging the style of the PDF document, it is necessary to verify whether the style debugging result of the PDF document meets expectations, specifically, to find each part of the PDF document that involves CSS style debugging, and then verify the style debugging result of each part.
[0003] In the prior art, each part involved in CSS style debugging in a PDF document is searched, and then the style debugging results of each part are verified, resulting in low verification efficiency. Summary of the invention
[0004] The embodiments of the present invention provide a PDF document verification method, device and electronic device to solve the technical problem in the prior art that it is necessary to search for each part involved in CSS style debugging in the PDF document and then verify the style debugging results of each part, resulting in low verification efficiency.
[0005] To solve the above technical problems, the present invention is achieved as follows:
[0006] In a first aspect, an embodiment of the present invention provides a method for verifying a PDF document, the method comprising:
[0007] According to a preset first cascading style sheet (CSS) expression, determine N HTML fragments in a hypertext markup language (HTML) document, wherein a tag of each HTML fragment in the N HTML fragments matches a selector content included in the first CSS expression, and N is a positive integer;
[0008] Generate, according to the first CSS expression and the N HTML fragments, N first PDF documents corresponding to the N HTML fragments one by one respectively;
[0009] A verification result of each of the N first PDF documents is received respectively.
[0010] Optionally, the determining, according to a preset first cascading style sheet (CSS) expression, N HTML fragments in a hypertext markup language (HTML) document comprises:
[0011] According to the first CSS expression, searching for an HTML fragment in the HTML document;
[0012] When it is found that the tag of the Nth HTML fragment matches the selector content included in the first CSS expression, the Nth object in the object set is determined according to the format of the objects in the preset object set, and the Nth object includes the Nth HTML fragment and the first CSS expression.
[0013] Optionally, when it is found that the tag of the Nth HTML fragment matches the selector content included in the first CSS expression, determining the Nth object in the object set according to the format of the objects in the preset object set includes:
[0014] When it is found that the tag of the first HTML fragment matches the selector content included in the first CSS expression, determine the first object in the object set according to a preset format of the object in the object set, wherein the first object includes the first HTML fragment and the first CSS expression;
[0015] According to the first CSS expression, the remaining HTML fragments in the HTML document are searched until the full text of the HTML document is searched.
[0016] Optionally, after generating N first PDF documents corresponding to the N HTML fragments one by one according to the first CSS expression and the N HTML fragments, the method further includes:
[0017] The first PDF document corresponding to the Nth HTML fragment is updated to the Nth object.
[0018] Optionally, the method further comprises:
[0019] In the case that there is a verification failure in the verification results of each of the first PDF documents, determining M HTML fragments in the HTML document according to a preset second CSS expression, wherein the selector content included in the second CSS expression matches a tag of each HTML fragment in the M HTML fragments, and the selector content included in the second CSS expression also matches a tag of a target HTML fragment, the target HTML fragment is an HTML fragment corresponding to the first PDF document that failed the verification, and M is a positive integer;
[0020] Generate, according to the second CSS expression and the M HTML fragments, M second PDF documents corresponding to the M HTML fragments one by one respectively;
[0021] A verification result of each of the M second PDF documents is received respectively.
[0022] Optionally, the method further comprises:
[0023] When the verification result of each of the first PDF documents is successful, the CSS file is updated according to the first CSS expression.
[0024] In a second aspect, an embodiment of the present invention provides a PDF document verification device, including:
[0025] A hypertext markup language HTML finder, used for determining N HTML fragments in an HTML document according to a preset first cascading style sheet CSS expression, wherein a tag of each HTML fragment in the N HTML fragments matches a selector content included in the first CSS expression, and N is a positive integer;
[0026] A PDF renderer, configured to generate N first PDF documents corresponding to the N HTML fragments according to the first CSS expression and the N HTML fragments;
[0027] The PDF verifier is used to receive the verification result of each first PDF document in the N first PDF documents respectively.
[0028] Optionally, the HTML finder is specifically used for:
[0029] According to the first CSS expression, searching for an HTML fragment in the HTML document;
[0030] When it is found that the tag of the Nth HTML fragment matches the selector content included in the first CSS expression, the Nth object in the object set is determined according to the format of the objects in the preset object set, and the Nth object includes the Nth HTML fragment and the first CSS expression.
[0031] Optionally, the HTML finder is specifically used for:
[0032] When it is found that the tag of the first HTML fragment matches the selector content included in the first CSS expression, determine the first object in the object set according to a preset format of the object in the object set, wherein the first object includes the first HTML fragment and the first CSS expression;
[0033] According to the first CSS expression, the remaining HTML fragments in the HTML document are searched until the full text of the HTML document is searched.
[0034] Optionally, the HTML finder is also used to:
[0035] The first PDF document corresponding to the Nth HTML fragment is updated to the Nth object.
[0036] Optionally, the HTML finder is further used to, when there is a verification failure in the verification result of each of the first PDF documents, determine M HTML fragments in the HTML document according to a preset second CSS expression, the selector content included in the second CSS expression matches the tag of each HTML fragment in the M HTML fragments, and the selector content included in the second CSS expression also matches the tag of a target HTML fragment, the target HTML fragment is the HTML fragment corresponding to the first PDF document that failed the verification, and M is a positive integer;
[0037] The PDF renderer is further configured to generate, according to the second CSS expression and the M HTML fragments, M second PDF documents corresponding to the M HTML fragments one by one;
[0038] The PDF verifier is further configured to receive a verification result of each of the M second PDF documents respectively.
[0039] Optionally, the device further comprises:
[0040] The CSS merger is used to update the CSS file according to the first CSS expression when the verification result of each of the first PDF documents is successful.
[0041] In a third aspect, an embodiment of the present invention further provides a PDF document verification device, including:
[0042] A first determining module is used to determine N HTML fragments in a hypertext markup language HTML document according to a preset first cascading style sheet CSS expression, wherein a tag of each HTML fragment in the N HTML fragments matches a selector content included in the first CSS expression, and N is a positive integer;
[0043] A first generating module, configured to generate N first PDF documents corresponding to the N HTML fragments according to the first CSS expression and the N HTML fragments;
[0044] The first receiving module is used to receive the verification result of each first PDF document in the N first PDF documents respectively.
[0045] Optionally, the first determining module is specifically configured to:
[0046] According to the first CSS expression, searching for an HTML fragment in the HTML document;
[0047] When it is found that the tag of the Nth HTML fragment matches the selector content included in the first CSS expression, the Nth object in the object set is determined according to the format of the objects in the preset object set, and the Nth object includes the Nth HTML fragment and the first CSS expression.
[0048] Optionally, the first determining module is specifically configured to:
[0049] When it is found that the tag of the first HTML fragment matches the selector content included in the first CSS expression, determine the first object in the object set according to a preset format of the object in the object set, wherein the first object includes the first HTML fragment and the first CSS expression;
[0050] According to the first CSS expression, the remaining HTML fragments in the HTML document are searched until the full text of the HTML document is searched.
[0051] Optionally, the device further comprises:
[0052] The first updating module is used to update the first PDF document corresponding to the Nth HTML fragment to the Nth object.
[0053] Optionally, the device further comprises:
[0054] A second determining module is configured to determine, when there is a verification failure in the verification result of each of the first PDF documents, M HTML fragments in the HTML document according to a preset second CSS expression, wherein the selector content included in the second CSS expression matches the tag of each HTML fragment in the M HTML fragments, and the selector content included in the second CSS expression also matches the tag of a target HTML fragment, the target HTML fragment is an HTML fragment corresponding to the first PDF document that failed the verification, and M is a positive integer;
[0055] A second generating module, configured to generate, according to the second CSS expression and the M HTML fragments, M second PDF documents corresponding to the M HTML fragments one by one;
[0056] The second receiving module is used to receive the verification result of each second PDF document in the M second PDF documents respectively.
[0057] Optionally, the device further comprises:
[0058] The second updating module is used to update the CSS file according to the first CSS expression when the verification result of each of the first PDF documents is successful.
[0059] In a fourth aspect, an embodiment of the present invention provides an electronic device, including a transceiver and a processor.
[0060] The processor is used to determine N HTML fragments in a hypertext markup language HTML document according to a preset first cascading style sheet CSS expression, wherein a tag of each HTML fragment in the N HTML fragments matches a selector content included in the first CSS expression, and N is a positive integer;
[0061] The processor is further configured to generate N first PDF documents corresponding to the N HTML fragments one by one, respectively, according to the first CSS expression and the N HTML fragments;
[0062] The transceiver is used to receive the verification result of each of the N first PDF documents respectively.
[0063] Optionally, the processor is specifically configured to:
[0064] According to the first CSS expression, searching for an HTML fragment in the HTML document;
[0065] When it is found that the tag of the Nth HTML fragment matches the selector content included in the first CSS expression, the Nth object in the object set is determined according to the format of the objects in the preset object set, and the Nth object includes the Nth HTML fragment and the first CSS expression.
[0066] Optionally, the processor is specifically configured to:
[0067] When it is found that the tag of the first HTML fragment matches the selector content included in the first CSS expression, determine the first object in the object set according to a preset format of the object in the object set, wherein the first object includes the first HTML fragment and the first CSS expression;
[0068] According to the first CSS expression, the remaining HTML fragments in the HTML document are searched until the full text of the HTML document is searched.
[0069] Optionally, the processor is specifically configured to:
[0070] The first PDF document corresponding to the Nth HTML fragment is updated to the Nth object.
[0071] Optionally, the processor is further configured to, when there is a verification failure in the verification result of each of the first PDF documents, determine, according to a preset second CSS expression, M HTML fragments in the HTML document, wherein selector content included in the second CSS expression matches a tag of each HTML fragment in the M HTML fragments, and the selector content included in the second CSS expression also matches a tag of a target HTML fragment, the target HTML fragment being an HTML fragment corresponding to the first PDF document that failed verification, and M is a positive integer;
[0072] The processor is further configured to generate, according to the second CSS expression and the M HTML fragments, M second PDF documents corresponding to the M HTML fragments one by one;
[0073] The transceiver is further configured to respectively receive a verification result of each of the M second PDF documents.
[0074] Optionally, the processor is further configured to update the CSS file according to the first CSS expression when the verification result of each first PDF document is successful.
[0075] In a fifth aspect, an embodiment of the present invention provides an electronic device, comprising: a processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the steps of the PDF document verification method as described in the first aspect are implemented.
[0076] In a sixth aspect, an embodiment of the present invention provides a computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the PDF document verification method described in the first aspect are implemented.
[0077] In the embodiment of the present invention, N HTML fragments to be debugged by CSS style in an HTML document are determined by CSS expressions, and corresponding N PDF documents are generated based on the N HTML fragments and CSS expressions. The N PDF documents are the parts that have been debugged by CSS style. The effect of CSS style debugging can be verified by verifying the N PDF documents. Compared with the prior art of generating a PDF full-text document by using the full text of an HTML document and CSS expressions, and then searching for the parts involved in CSS style debugging from the PDF full-text document, the embodiment of the present invention does not need to search from the PDF full-text document. The embodiment of the present invention directly verifies the styles of N PDF documents, which is conducive to improving verification efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0079] Figure 1 This is a flow chart of adjusting the style of an existing PDF document provided by an embodiment of the present invention;
[0080] Figure 2 This is one of the flow charts of a PDF document verification method provided by an embodiment of the present invention;
[0081] Figure 3 This is a second flowchart of a PDF document verification method provided by an embodiment of the present invention;
[0082] Figure 4 This is one of the structural diagrams of a PDF document verification device provided by an embodiment of the present invention;
[0083] Figure 5 This is a second structural diagram of a PDF document verification device provided by an embodiment of the present invention;
[0084] Figure 6 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0085] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0086] For ease of understanding, the relevant contents involved in the present invention are first described below.
[0087] Darwin Information Typing Architecture (DITA) is a universal standard in the field of technical writing. Based on this universal standard, DITA files can be generated, and documents in various formats can be generated based on DITA files. When using DITA files to generate PDF documents, Cascading Style Sheets (CSS) can be used to enrich the style of PDF documents to achieve a layout effect that is consistent with traditional desktop publishing software. In the process of generating PDF documents from DITA files, the editor will first parse the DITA file into an HTML file, match the selected CSS file, and finally generate a PDF document that meets the user's expectations through the combination of this HTML+CSS document structure + style file rendering. In the process of generating the expected PDF document, adjustment and verification of the PDF document style are inevitable steps.
[0088] The following combination Figure 1 Provides specific instructions on how to adjust and verify the style of a PDF document.
[0089] like Figure 1 As shown in the figure, a. the user selects the HTML code snippet that needs to be debugged in the HTML document; b. the CSS expression is matched according to the HTML code snippet, and the CSS debugger completes the CSS debugging of the HTML document according to the CSS expression, and previews the debugged HTML document; c. the HTML document is generated into an overall PDF document; d. the parts that have been debugged in CSS style are searched from the overall PDF document. If an error occurs, repeat step b and manually adjust the CSS expression; e. the overall PDF document is generated, and the task is completed.
[0090] In the above process, the HTML document is generated into a whole PDF document, and then the parts that have been debugged with CSS style are searched from the whole PDF document to verify the CSS style debugging effect of the PDF. If the HTML document is large, the resulting PDF document will be large in size and take a long time to render. It will be very difficult to view all the document fragments related to the current CSS style modification, resulting in low PDF document verification efficiency.
[0091] In the embodiment of the present invention, a PDF document verification method, device and electronic device are proposed to solve the technical problem that the existing verification efficiency is low, which is caused by searching for each part of the PDF document involving CSS style debugging and then verifying the style debugging results of each part.
[0092] See 2, Figure 2 is a flowchart of a PDF document verification method provided by an embodiment of the present invention, such as Figure 2 As shown, the method comprises the following steps:
[0093] Step 101: According to a preset first CSS expression, determine N HTML fragments in an HTML document, wherein a tag of each HTML fragment in the N HTML fragments matches a selector content included in the first CSS expression, and N is a positive integer;
[0094] Step 102: Generate N first PDF documents corresponding to the N HTML fragments one by one, respectively, according to the first CSS expression and the N HTML fragments;
[0095] Step 103: Receive verification results of each of the N first PDF documents respectively.
[0096] It should be noted that the method in the embodiment of the present invention can be applied to a verification device for a PDF document or to an electronic device. For ease of understanding, the verification method for a PDF document in the embodiment of the present invention is described below using a verification device for a PDF document (hereinafter referred to as a verification device) as an example.
[0097] In step 101, the preset first CSS expression is an expression preset based on the HTML fragment to be debugged. Figure 3 Before step 101, an input of an HTML fragment to be debugged in an HTML document is received. This fragment may be an HTML fragment to be debugged directly selected by a user in the HTML document, or may be an HTML fragment that fails style verification. Specifically, an HTML fragment that fails verification means that a PDF document generated by the HTML fragment fails in the last style verification. In the case of verification failure, the input of the HTML fragment that fails verification may be received again to redetermine the CSS expression to perform style debugging on the HTML fragment that fails verification. If the input is an HTML fragment that fails style verification, the full text of the HTML document may be searched and the position of the fragment in the full text may be located for the user to view.
[0098] After receiving an input of an HTML fragment to be debugged in an HTML document, a CSS expression whose selector content can match a tag of the HTML fragment can be searched in a CSS file.
[0099] When found in the CSS file, in some embodiments, the CSS expression can be directly determined as the first CSS expression; in other embodiments, the above-mentioned preset first CSS expression can be formed after debugging at least one of the selector content, attributes and attribute values of the CSS expression according to the requirements of style debugging. It should be noted that under normal circumstances, the selector content of the debugged first CSS expression still needs to match the tag of the above-mentioned HTML fragment to be debugged.
[0100] If the code is not found in the CSS file, a first CSS expression may be directly preset, and the selector content of the first CSS expression matches the tag of the HTML fragment to be debugged input above.
[0101] After determining the first CSS expression through the above steps, the first CSS expression is sent to the verification device in the embodiment of the present invention. In addition, the HTML fragment to be debugged can also be sent to the verification device in the embodiment of the present invention. In step 101, the verification device determines N HTML fragments in the HTML document based on the selector content of the first CSS expression, and the tag of each HTML fragment in the N HTML fragments matches the selector content of the first CSS expression. The N HTML fragments are objects for style debugging based on the first CSS expression.
[0102] In step 102, the verification device generates N first PDF documents corresponding to the N HTML fragments according to the first CSS expression and the N HTML fragments. The N HTML fragments are the parts of the HTML document that are style-debugged based on the first CSS expression, so the N first PDF documents are also the parts of the HTML document that are style-debugged based on the first CSS expression. Based on this, in the process of style debugging through CSS expressions, the embodiment of the present invention does not directly generate the full text of the PDF document according to the full text of the HTML document, but renders the parts of the HTML document that will be debugged into separate PDF documents, so that there is no need to render the parts that are not style-debugged, which is conducive to saving performance resources.
[0103] In step 103, the verification device can display N PDF documents to the user, provide the user with a verification interface, and receive the verification results of each of the N first PDF documents respectively. The user verifies the N PDF documents, so that the user can quickly view the effectiveness of the current CSS expression in the full text and make adjustments in time. The user can verify the debugging results of the N PDF documents in strips, and the verification device receives the verification results fed back by the user.
[0104] In the embodiment of the present invention, in the process of style debugging through CSS expressions, the full text of the PDF document is not directly generated according to the full text of the HTML document, but the parts of the HTML document that will be debugged based on the CSS expression are rendered into separate PDF documents respectively. In this way, there is no need to search for the parts based on CSS style debugging from the full-text PDF document. The embodiment of the present invention directly verifies N PDF documents, which is conducive to improving verification efficiency.
[0105] Optionally, determining N HTML fragments in the HTML document according to a preset first cascading style sheet (CSS) expression includes:
[0106] According to the first CSS expression, searching for an HTML fragment in the HTML document;
[0107] When it is found that the tag of the Nth HTML fragment matches the selector content included in the first CSS expression, the Nth object in the object set is determined according to the format of the objects in the preset object set, and the Nth object includes the Nth HTML fragment and the first CSS expression.
[0108] In this implementation, the preset object set can be expressed as [{style(CSS expression):"",html(HTML fragment):""}], wherein {style(CSS expression):"",html(HTML fragment):""} is the format of the objects in the preset object set. When it is found that the tag of the Nth HTML fragment matches the selector content included in the first CSS expression, the Nth object in the object set is determined according to the format of the objects in the preset object set: {style:"first CSS expression",html:"Nth HTML fragment"}. After determining the Nth object, the object set can be expressed as [{style:"first CSS expression",html:"Nth HTML fragment"}].
[0109] In an embodiment of the present invention, N HTML fragments are directly extracted from an HTML document and stored in an object set, which includes CSS expressions and HTML fragments to be rendered, so that the HTML fragments can be rendered into corresponding PDF documents according to the object set.
[0110] Optionally, when it is found that the tag of the Nth HTML fragment matches the selector content included in the first CSS expression, determining the Nth object in the object set according to the format of the objects in the preset object set includes:
[0111] When it is found that the tag of the first HTML fragment matches the selector content included in the first CSS expression, determine the first object in the object set according to a preset format of the object in the object set, wherein the first object includes the first HTML fragment and the first CSS expression;
[0112] According to the first CSS expression, the remaining HTML fragments in the HTML document are searched until the full text of the HTML document is searched.
[0113] In this implementation, when the tag of the first HTML fragment is found to match the selector content included in the first CSS expression, the first object is determined according to the format of the objects in the preset object set. The first object can be expressed as {style: "first CSS expression", html: "first HTML fragment"}.
[0114] According to the first CSS expression, search for the remaining HTML fragments in the HTML document until the full text of the HTML document is searched. Whenever an HTML fragment that meets the matching requirements is found, add the corresponding object to the object set. For example, when the tag of the second HTML fragment is found to match the selector content included in the first CSS expression, the second object is determined to be: {style: "first CSS expression", html: "second HTML fragment"}, and the object set is: [{style: "first CSS expression", html: "first HTML fragment"}, {style: "first CSS expression", html: "second HTML fragment"}].
[0115] In the embodiment of the present invention, the full text of the HTML document is traversed, so that all HTML fragments that meet the matching requirements in the full HTML text can be found, that is, all HTML fragments to be styled based on CSS can be found, thereby improving the accuracy of the currently modified style.
[0116] Optionally, after generating N first PDF documents corresponding to the N HTML fragments one by one according to the first CSS expression and the N HTML fragments, the method further includes:
[0117] The first PDF document corresponding to the Nth HTML fragment is updated to the Nth object.
[0118] In this implementation, the format of the objects in the preset object set may be: {style (CSS expression): "", html (HTML fragment): "", pdf (PDF fragment, empty by default): null}. Before the PDF document corresponding to the Nth HTML fragment is generated, the Nth object may be represented as: {style: "first CSS expression", html: "Nth HTML fragment", pdf: null}; after the PDF document corresponding to the Nth HTML fragment is generated, the PDF document corresponding to the Nth HTML fragment is updated to the Nth object. At this time, the Nth object may be represented as: {style: "first CSS expression", html: "Nth HTML fragment", pdf: object}.
[0119] In the embodiment of the present invention, each object includes a CSS expression, an HTML fragment and a corresponding PDF document. Subsequently, the PDF document in each object can be directly extracted and displayed to the user so that the user can verify the PDF document. In addition, by setting the object to include a CSS expression, an HTML fragment and a corresponding PDF document, an association relationship between the three is established. In the case that any document in the above N PDF documents fails to be verified, the HTML fragment corresponding to the PDF document that failed to be verified can be determined, so that the user can debug the CSS expression based on the HTML fragment that failed to be verified.
[0120] In some embodiments, the format of the object in the preset object set may also be {id (serial number, automatically generated according to the input order): X, style (CSS expression): "", html (HTML fragment): "", pdf (PDF fragment, empty by default): null}. To facilitate understanding of the rules of id in the object, it is explained below in combination with different HTML fragment search rules.
[0121] Example 1: Search from the first position of the HTML document to the end of the HTML document, and then search from the beginning of the HTML document to the first position of the HTML document, so as to achieve the search of the entire HTML document. The first CSS expression is determined according to the HTML fragment to be debugged, and the first position refers to the position of the HTML fragment to be debugged. Since the selector content of the first CSS expression matches the tag of the HTML fragment to be debugged, the first HTML fragment found in the HTML document that meets the matching conditions is the HTML fragment to be debugged.
[0122] The HTML fragment to be debugged is <h2> XXXXX< / h2>For example, the selector content of the first CSS expression is h2, which matches the tag h2 of the HTML fragment to be debugged. The HTML fragment to be debugged is found from the first position of the HTML document. <h2> XXXXX< / h2> , determine the first object in the object set. At this time, the object set is in the form of [{id:1, style:"First CSS expression", html:" <h2> XXXXX< / h2> ",pdf:null}]. Continue to search for the remaining fragments of the HTML document and find <h2> AAAAA< / h2> Matches the first CSS expression and determines the second object in the object set. At this time, the object set is updated to [{id:1, style:"First CSS expression", html:" <h2> XXXXX< / h2> ",pdf:null},{id:2,style:"First CSS expression",html:" <h2> AAAAA< / h2> ",pdf:null}].
[0123] Example 2: Start searching from the beginning of an HTML document until the entire text of the HTML document is searched. Start searching from the beginning of an HTML document, find the first HTML fragment that meets the matching criteria, and then determine the first object in the object set. <h2> BBBBB< / h2> For example, after determining the first object in the object set, the object set is in the form of [{id:1,style:"First CSS expression",html:" <h2> BBBBB< / h2> ",pdf:null}].
[0124] Optionally, when there is a verification failure in the verification results of each of the first PDF documents, M HTML fragments in the HTML document are determined according to a preset second CSS expression, the selector content included in the second CSS expression matches a tag of each HTML fragment in the M HTML fragments, and the selector content included in the second CSS expression also matches a tag of a target HTML fragment, the target HTML fragment is an HTML fragment corresponding to the first PDF document that failed verification, and M is a positive integer;
[0125] Generate, according to the second CSS expression and the M HTML fragments, M second PDF documents corresponding to the M HTML fragments one by one respectively;
[0126] A verification result of each of the M second PDF documents is received respectively.
[0127] The verification device receives the verification result of each first PDF document. When the user determines that a PDF document does not pass the verification (i.e., the verification fails), the verification device will receive "false". In the case of any first PDF document failing to verify, it proves that the current first CSS expression may not be accurate enough. Based on this, all objects in the current object set can be cleared, and the target HTML fragment can be re-entered as the HTML fragment to be debugged (the target HTML document is the HTML fragment corresponding to the PDF document that failed the verification). Figure 3 After inputting the target HTML fragment, the second CSS expression can be determined according to the target HTML.
[0128] After determining the second CSS expression, the embodiment of the present invention re-determines M HTML fragments according to the selector content of the second CSS expression, and the tag of each HTML fragment in the M HTML fragments matches the selector content of the second CSS expression. Based on the second CSS expression + M HTML fragments, M second PDF documents are generated, and based on the verification result of each second PDF document, it can be verified whether the style debugging result corresponding to the second CSS expression meets expectations.
[0129] In an embodiment of the present invention, when the verification of the first PDF document fails, a second CSS expression matching the target HTML document is re-determined, and M HTML fragments are determined based on the second CSS expression. M PDF documents are rendered and generated according to the M HTML fragments and the second CSS expression, which is beneficial to improving the verification accuracy of the current style debugging result (i.e., the style debugging result corresponding to the second CSS expression).
[0130] Optionally, the method further comprises:
[0131] Step 104: When the verification result of each of the first PDF documents is successful, update the CSS file according to the first CSS expression.
[0132] When the user determines that each first PDF document has passed the acceptance, the verification device will receive "true". In the case of receiving "true", it is proved that the first CSS expression is more in line with expectations, and the CSS file can be updated according to the first CSS expression. Among them, updating the CSS file includes the following two situations.
[0133] Case 1: If a CSS expression with the same selector content as the first CSS expression can be found in the CSS file, the above CSS expression is directly updated based on the attribute name and attribute value of the first CSS expression.
[0134] Case 2: If a CSS expression with the same selector content as the first CSS expression cannot be found in the CSS file, the first CSS expression is newly inserted at the end of the CSS file.
[0135] In the embodiment of the present invention, when each first PDF document passes the acceptance, the CSS file is updated according to the first CSS expression, so as to generate a PDF document full text that meets expectations based on the updated CSS file and the HTML document.
[0136] See also Figure 4 , Figure 4 2 is a schematic diagram of a PDF document verification device provided by an embodiment of the present invention. The verification device 200 includes:
[0137] A hypertext markup language HTML finder 201, used for determining N HTML fragments in an HTML document according to a preset first cascading style sheet CSS expression, wherein a tag of each HTML fragment in the N HTML fragments matches a selector content included in the first CSS expression, and N is a positive integer;
[0138] The PDF renderer 202 is configured to generate N first PDF documents corresponding to the N HTML fragments according to the first CSS expression and the N HTML fragments;
[0139] The PDF verifier 203 is configured to receive a verification result of each of the N first PDF documents.
[0140] Optionally, the HTML finder 201 is specifically used for:
[0141] According to the first CSS expression, searching for an HTML fragment in the HTML document;
[0142] When it is found that the tag of the Nth HTML fragment matches the selector content included in the first CSS expression, the Nth object in the object set is determined according to the format of the objects in the preset object set, and the Nth object includes the Nth HTML fragment and the first CSS expression.
[0143] Optionally, the HTML finder 201 is specifically used for:
[0144] When it is found that the tag of the first HTML fragment matches the selector content included in the first CSS expression, determine the first object in the object set according to a preset format of the object in the object set, wherein the first object includes the first HTML fragment and the first CSS expression;
[0145] According to the first CSS expression, the remaining HTML fragments in the HTML document are searched until the full text of the HTML document is searched.
[0146] Optionally, the HTML finder 201 is further used for:
[0147] The first PDF document corresponding to the Nth HTML fragment is updated to the Nth object.
[0148] Optionally, the HTML finder 201 is further configured to, when there is a verification failure in the verification result of each of the first PDF documents, determine M HTML fragments in the HTML document according to a preset second CSS expression, wherein the selector content included in the second CSS expression matches a tag of each HTML fragment in the M HTML fragments, and the selector content included in the second CSS expression also matches a tag of a target HTML fragment, the target HTML fragment is an HTML fragment corresponding to the first PDF document that failed verification, and M is a positive integer;
[0149] The PDF renderer 202 is further configured to generate, according to the second CSS expression and the M HTML fragments, M second PDF documents corresponding to the M HTML fragments one by one;
[0150] The PDF verifier 203 is further configured to receive a verification result of each of the M second PDF documents.
[0151] Optionally, the device 200 further includes:
[0152] The CSS merger 204 is configured to update the CSS file according to the first CSS expression when the verification result of each of the first PDF documents is successful.
[0153] It should be noted that the device 200 of this embodiment can implement each process of the above-mentioned PDF document verification method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described here.
[0154] See also Figure 5 , Figure 5 is a schematic diagram of the structure of a PDF document verification device provided by an embodiment of the present invention, such as Figure 5 As shown, the device 300 includes:
[0155] A first determining module 301 is used to determine N HTML fragments in a hypertext markup language HTML document according to a preset first cascading style sheet CSS expression, wherein a tag of each HTML fragment in the N HTML fragments matches a selector content included in the first CSS expression, and N is a positive integer;
[0156] A first generating module 302, configured to generate N first PDF documents corresponding to the N HTML fragments according to the first CSS expression and the N HTML fragments;
[0157] The first receiving module 303 is configured to receive a verification result of each of the N first PDF documents respectively.
[0158] Optionally, the first determining module 301 is specifically configured to:
[0159] According to the first CSS expression, searching for an HTML fragment in the HTML document;
[0160] When it is found that the tag of the Nth HTML fragment matches the selector content included in the first CSS expression, the Nth object in the object set is determined according to the format of the objects in the preset object set, and the Nth object includes the Nth HTML fragment and the first CSS expression.
[0161] Optionally, the first determining module 301 is specifically configured to:
[0162] When it is found that the tag of the first HTML fragment matches the selector content included in the first CSS expression, determine the first object in the object set according to a preset format of the object in the object set, wherein the first object includes the first HTML fragment and the first CSS expression;
[0163] According to the first CSS expression, the remaining HTML fragments in the HTML document are searched until the full text of the HTML document is searched.
[0164] Optionally, the device further comprises:
[0165] The first updating module is used to update the first PDF document corresponding to the Nth HTML fragment to the Nth object.
[0166] Optionally, the device 300 further includes:
[0167] A second determining module is configured to determine, when there is a verification failure in the verification result of each of the first PDF documents, M HTML fragments in the HTML document according to a preset second CSS expression, wherein the selector content included in the second CSS expression matches the tag of each HTML fragment in the M HTML fragments, and the selector content included in the second CSS expression also matches the tag of a target HTML fragment, the target HTML fragment is an HTML fragment corresponding to the first PDF document that failed the verification, and M is a positive integer;
[0168] A second generating module, configured to generate, according to the second CSS expression and the M HTML fragments, M second PDF documents corresponding to the M HTML fragments one by one;
[0169] The second receiving module is used to receive the verification result of each second PDF document in the M second PDF documents respectively.
[0170] Optionally, the device 300 further includes:
[0171] The second updating module is used to update the CSS file according to the first CSS expression when the verification result of each of the first PDF documents is successful.
[0172] It should be noted that the device 300 of this embodiment can implement each process of the above-mentioned PDF document verification method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described here.
[0173] An embodiment of the present invention further provides an electronic device, comprising: a processor, a memory, and a program stored in the memory and executable on the processor. When the program is executed by the processor, the various processes of the above-mentioned PDF document verification method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0174] For details, see Figure 6 As shown, an embodiment of the present invention further provides an electronic device, including a bus 401 , a transceiver 402 , an antenna 403 , a bus interface 404 , a processor 405 and a memory 406 .
[0175] The processor 405 is configured to determine, according to a preset first cascading style sheet (CSS) expression, N HTML fragments in a hypertext markup language (HTML) document, wherein a tag of each HTML fragment in the N HTML fragments matches a selector content included in the first CSS expression, where N is a positive integer;
[0176] The processor 405 is further configured to generate N first PDF documents corresponding to the N HTML fragments according to the first CSS expression and the N HTML fragments;
[0177] The transceiver 402 is used to receive the verification result of each of the N first PDF documents respectively.
[0178] Optionally, the processor 405 is specifically configured to:
[0179] According to the first CSS expression, searching for an HTML fragment in the HTML document;
[0180] When it is found that the tag of the Nth HTML fragment matches the selector content included in the first CSS expression, the Nth object in the object set is determined according to the format of the objects in the preset object set, and the Nth object includes the Nth HTML fragment and the first CSS expression.
[0181] Optionally, the processor 405 is specifically configured to:
[0182] When it is found that the tag of the first HTML fragment matches the selector content included in the first CSS expression, determine the first object in the object set according to a preset format of the object in the object set, wherein the first object includes the first HTML fragment and the first CSS expression;
[0183] According to the first CSS expression, the remaining HTML fragments in the HTML document are searched until the full text of the HTML document is searched.
[0184] Optionally, the processor 405 is specifically configured to:
[0185] The first PDF document corresponding to the Nth HTML fragment is updated to the Nth object.
[0186] Optionally, the processor 405 is further configured to, when there is a verification failure in the verification result of each of the first PDF documents, determine, according to a preset second CSS expression, M HTML fragments in the HTML document, wherein the selector content included in the second CSS expression matches a tag of each HTML fragment in the M HTML fragments, and the selector content included in the second CSS expression also matches a tag of a target HTML fragment, the target HTML fragment is an HTML fragment corresponding to the first PDF document that failed the verification, and M is a positive integer;
[0187] The processor 405 is further configured to generate, according to the second CSS expression and the M HTML fragments, M second PDF documents corresponding to the M HTML fragments one by one;
[0188] The transceiver 402 is further configured to receive a verification result of each of the M second PDF documents.
[0189] Optionally, the processor 405 is further configured to update the CSS file according to the first CSS expression when the verification result of each first PDF document is successful.
[0190] exist Figure 6 In the embodiment, a bus architecture (represented by bus 401) is shown, bus 401 may include any number of interconnected buses and bridges, bus 401 links various circuits including one or more processors represented by processor 405 and memory represented by memory 406. Bus 401 may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. Bus interface 404 provides an interface between bus 401 and transceiver 402. Transceiver 402 may be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. Data processed by processor 405 is transmitted on a wireless medium via antenna 403, and further, antenna 403 also receives data and transmits the data to processor 405.
[0191] Processor 405 is responsible for managing bus 401 and general processing, and may also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory 406 may be used to store data used by processor 405 when performing operations.
[0192] Optionally, the processor 405 may be a CPU, an ASIC, an FPGA or a CPLD.
[0193] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned PDF document verification method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0194] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0195] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0196] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
Claims
1. A PDF document verification method, characterized in that: The method comprises: According to a preset first cascading style sheet (CSS) expression, determine N HTML fragments in a hypertext markup language (HTML) document, wherein a tag of each HTML fragment in the N HTML fragments matches a selector content included in the first CSS expression, and N is a positive integer; Generate, according to the first CSS expression and the N HTML fragments, N first PDF documents corresponding to the N HTML fragments one by one respectively; A verification result of each of the N first PDF documents is received respectively.
2. The method according to claim 1, characterized in that: The determining of N HTML fragments in a hypertext markup language HTML document according to a preset first cascading style sheet CSS expression comprises: searching for HTML fragments in the HTML document according to the first CSS expression; When it is found that the tag of the Nth HTML fragment matches the selector content included in the first CSS expression, the Nth object in the object set is determined according to the format of the objects in the preset object set, and the Nth object includes the Nth HTML fragment and the first CSS expression.
3. The method according to claim 2, characterized in that In the case where the tag of the Nth HTML fragment is found to match the selector content included in the first CSS expression, determining the Nth object in the object set according to the format of the object in the preset object set includes: In the case that the tag of the first HTML fragment matches the selector content included in the first CSS expression, determining the first object in the object set according to the format of the objects in the preset object set, the first object including the first HTML fragment and the first CSS expression; According to the first CSS expression, the remaining HTML fragments in the HTML document are searched until the full text of the HTML document is searched.
4. The method according to claim 2, characterized in that: After generating N first PDF documents corresponding to the N HTML fragments one by one according to the first CSS expression and the N HTML fragments, the method further includes: The first PDF document corresponding to the Nth HTML fragment is updated to the Nth object.
5. The method according to claim 1, characterized in that The method further comprises: In the case that there is a verification failure in the verification results of each of the first PDF documents, determining M HTML fragments in the HTML document according to a preset second CSS expression, wherein the selector content included in the second CSS expression matches a tag of each HTML fragment in the M HTML fragments, and the selector content included in the second CSS expression also matches a tag of a target HTML fragment, the target HTML fragment is an HTML fragment corresponding to the first PDF document that failed the verification, and M is a positive integer; Generate, according to the second CSS expression and the M HTML fragments, M second PDF documents corresponding to the M HTML fragments one by one respectively; A verification result of each of the M second PDF documents is received respectively.
6. The method according to claim 1, characterized in that The method further comprises: When the verification result of each of the first PDF documents is successful, the CSS file is updated according to the first CSS expression.
7. A PDF document verification device, characterized in that: include: A hypertext markup language HTML finder, used for determining N HTML fragments in an HTML document according to a preset first cascading style sheet CSS expression, wherein a tag of each HTML fragment in the N HTML fragments matches a selector content included in the first CSS expression, and N is a positive integer; A PDF renderer, configured to generate N first PDF documents corresponding to the N HTML fragments according to the first CSS expression and the N HTML fragments; The PDF verifier is used to receive the verification result of each first PDF document in the N first PDF documents respectively.
8. A PDF document verification device, characterized in that: include: A first determining module is used to determine N HTML fragments in a hypertext markup language HTML document according to a preset first cascading style sheet CSS expression, wherein a tag of each HTML fragment in the N HTML fragments matches a selector content included in the first CSS expression, and N is a positive integer; A first generating module, configured to generate N first PDF documents corresponding to the N HTML fragments according to the first CSS expression and the N HTML fragments; The first receiving module is used to receive the verification result of each first PDF document in the N first PDF documents respectively.
9. An electronic device, characterized in that: Including transceiver and processor, The processor is used to determine N HTML fragments in a hypertext markup language HTML document according to a preset first cascading style sheet CSS expression, wherein a tag of each HTML fragment in the N HTML fragments matches a selector content included in the first CSS expression, and N is a positive integer; The processor is further configured to generate N first PDF documents corresponding to the N HTML fragments one by one, respectively, according to the first CSS expression and the N HTML fragments; The transceiver is used to receive the verification result of each of the N first PDF documents respectively.
10. An electronic device, characterized in that: include: A processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the steps of the PDF document verification method according to any one of claims 1 to 6 are implemented.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the PDF document verification method according to any one of claims 1 to 6 are implemented.
