CN114297232A - Page insertion method and device, electronic equipment and storage medium - Google Patents

Page insertion method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114297232A
CN114297232A CN202111646958.4A CN202111646958A CN114297232A CN 114297232 A CN114297232 A CN 114297232A CN 202111646958 A CN202111646958 A CN 202111646958A CN 114297232 A CN114297232 A CN 114297232A
Authority
CN
China
Prior art keywords
child node
page
objects
type
cache
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111646958.4A
Other languages
Chinese (zh)
Inventor
郭滔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhuhai Baoqu Technology Co Ltd
Original Assignee
Zhuhai Baoqu Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhuhai Baoqu Technology Co Ltd filed Critical Zhuhai Baoqu Technology Co Ltd
Priority to CN202111646958.4A priority Critical patent/CN114297232A/en
Publication of CN114297232A publication Critical patent/CN114297232A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a page insertion method and device, electronic equipment and a storage medium. The method comprises the following steps: the method has the advantages that the object which is quoted in the cache container in the page to be inserted is inserted into the target page in a quoted mode, so that the inserting speed of the page can be effectively improved, the memory consumption is reduced, and the disk space occupied by the final file can be reduced.

Description

Page insertion method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a page insertion method and apparatus, an electronic device, and a storage medium.
Background
With the development of computer technology, PDF documents are more and more popular, and as small as electronic books, as large as electronic contracts, they all have the silhouette of the PDF documents. With the wide application of PDF documents, people have an increasing demand for editing PDF documents, from text editing to picture editing, from header and footer to page insertion, and the like. The page insertion is a very important function in PDF editing, and a user often needs to insert a part of a page of a document into another document to complete content integration. In the conventional page insertion method, each page to be inserted is sequentially inserted in sequence, so that some elements shared among the pages, such as a certain picture element, are repeatedly added.
Disclosure of Invention
In view of this, embodiments of the present invention provide a page insertion method, an apparatus, an electronic device, and a storage medium, which can improve the page insertion speed, reduce memory consumption, and reduce the disk space occupied by the final file.
In a first aspect, an embodiment of the present invention provides a page insertion method, where the method includes:
acquiring a root node object of a page to be inserted, and analyzing a plurality of child node objects corresponding to the root node object;
determining types of the plurality of child node objects;
determining whether a child node object of the plurality of child node objects of which the type is a reference object exists in a cache container;
and for a first child node object which is of a reference object type and exists in a cache in the plurality of child node objects, referencing the first child node object to a target page from the cache container to generate a new page.
Preferably, the method further comprises: copying a second child node object of the plurality of child node objects, the second child node object being of a type that is a reference object and not present in a cache; adding the copied second child node object into the superior parent object, and generating a new page object tree after traversing the child node objects; and inserting the new page object tree into an array corresponding to the target page to generate a new page.
Preferably, the method further comprises: if the child node objects also comprise a third child node object of which the type is a non-reference object, copying the third child node object; adding the copied third child node object into the superior parent object, and generating a new page object tree after traversing the child node objects; and inserting the new page object tree into an array corresponding to the target page to generate a new page.
Preferably, after copying a second child node object of the plurality of child node objects, the second child node object being of a type of a reference object and not existing in a cache, the method further comprises: adding the second child node object to the cache container.
Preferably, the determining whether a child node object of which the type is a reference object exists in the cache container includes: and determining whether the child node object with the type as the reference object exists in the cache container according to the ID of the child node object with the type as the reference object in the child node objects.
Preferably, when there are a plurality of pages to be inserted, before obtaining a root node object of the page to be inserted, the method further includes: and sequencing the pages to be inserted according to rules set by a user.
In a second aspect, an embodiment of the present invention provides a page insertion apparatus, including:
the system comprises an acquisition unit, a processing unit and a display unit, wherein the acquisition unit is used for acquiring a root node object of a page to be inserted and analyzing a plurality of child node objects corresponding to the root node object;
a first determining unit for determining types of the plurality of child node objects;
a second determining unit, configured to determine whether a child node object of which the type is a reference object exists in the cache container;
and the reference unit is used for referring the first child node object which is of the type of the reference object and exists in the cache to the target page from the cache container so as to generate a new page.
Preferably, the apparatus further comprises: a first copying unit, configured to copy a second child node object, of the plurality of child node objects, of which the type is a reference object and which does not exist in a cache; the first adding unit is used for adding the copied second child node object into the superior parent object, and generating a new page object tree after traversing the child node objects; and the first generating unit is used for inserting the new page object tree into the array corresponding to the target page to generate a new page.
Preferably, the apparatus further comprises: a second copying unit, configured to copy a third child node object of which the type is a non-reference object if the plurality of child node objects further include the third child node object; the second adding unit is used for adding the copied third child node object into the superior parent object, and generating a new page object tree after traversing the child node objects; and the second generating unit is used for inserting the new page object tree into the array corresponding to the target page to generate a new page.
Preferably, the apparatus comprises: and the cache unit is used for adding the second child node object to the cache container after the first copying unit copies the second child node object.
Preferably, the second determining unit is specifically configured to: and determining whether the child node object with the type as the reference object exists in the cache container according to the ID of the child node object with the type as the reference object in the child node objects.
Preferably, the apparatus further comprises: and the sequencing unit is used for sequencing the pages to be inserted according to rules set by a user before the acquisition unit acquires the root node objects of the pages to be inserted when the number of the pages to be inserted is multiple.
In a third aspect, an embodiment of the present invention provides an electronic device, including: the device comprises a shell, a processor, a memory, a circuit board and a power circuit, wherein the circuit board is arranged in a space enclosed by the shell, and the processor and the memory are arranged on the circuit board; a power supply circuit for supplying power to each circuit or device of the electronic apparatus; the memory is used for storing executable program codes; the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory, for executing the page insertion method according to the first aspect.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing one or more programs, the one or more programs being executable by one or more processors to implement the page insertion method according to the first aspect.
According to the page insertion method, the page insertion device, the electronic equipment and the storage medium provided by the embodiment of the invention, the object which is quoted in the cache container in the page to be inserted is inserted into the target page in a quoted mode, so that the page insertion speed can be effectively improved, the memory consumption can be reduced, and the disk space occupied by the final file can be reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a page insertion method according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a page insertion apparatus according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an embodiment of an electronic device according to the present invention.
Detailed Description
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
It should be understood that the described embodiments are only some embodiments of the invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 is a schematic flowchart of a page insertion method according to an embodiment of the present invention. The page insertion method can be applied to electronic equipment.
As shown in fig. 1, the page insertion method of this embodiment may include:
step 101, obtaining a root node object of a page to be inserted, and analyzing a plurality of child node objects corresponding to the root node object.
Optionally, each page has a corresponding object tree according to the content of the page, so that the root node object can be obtained from the object tree corresponding to the page to be inserted, and all child node objects corresponding to the root node are analyzed. The child node object may represent an element to be inserted into the page, such as a picture, a text, and the like.
In an example, when there are a plurality of pages to be inserted, before step 101, the page insertion method provided in this embodiment may further include: and sequencing the pages to be inserted according to rules set by the user.
For example, when there are multiple pages to be inserted, thumbnails of the pages to be inserted, or page numbers or names may be displayed, so that the user may sort the pages as required, and then step 101 is sequentially performed on the multiple pages to be inserted according to the sort of the user.
Step 102, determining the types of a plurality of child node objects.
Specifically, when a user edits a page, different types of elements may be added to the page, so that the type of the child node object corresponding to each element can be determined before insertion, so that different insertion modes are used for different types of child node objects, and the insertion speed of the page is increased.
Step 103 is executed for the child node object of which the type is the reference object among the plurality of child node objects. Preferably, step 108 is performed for child node objects of the plurality of child node objects whose type is a non-referenced object.
It is understood that step 103 is only performed if the child node object whose type is a non-reference object is not included in the child node object.
Step 103, determining whether the child node object with the type of the reference object in the plurality of child node objects exists in the cache container.
In one example, each child node object corresponds to an ID, and the cache container also stores the ID of the reference object, so step 103 may include: and determining whether the child node object with the type as the reference object in the plurality of child node objects exists in the cache container according to the ID of the child node object with the type as the reference object in the plurality of child node objects.
It can be understood that, in the embodiment of the present invention, a child node object of which a type is a reference object and exists in the cache is made to be a first child node object, a child node object of which a type is a reference object and does not exist in the cache is made to be a second child node object, and a child node object of which a type is a non-reference object is made to be a third child node object.
Thereafter, step 104 is performed for the first child node object. For the second child object, step 105 is performed.
And 104, referring the first child node object which is of the reference object type and exists in the cache to the target page from the cache container aiming at the first child node object in the plurality of child node objects so as to generate a new page.
Optionally, if the child node object is a reference object and is cached in the cache container, the child node object may be directly referenced from the cache container to the target page, that is, the ID corresponding to the child node object is referenced to the target page, so as to generate the new page. Therefore, the memory consumption can be effectively reduced, and the disk space occupied by the final file can be greatly reduced because the child node object does not need to be copied to the target page.
And step 105, copying a second child node object which is of the type of the reference object and does not exist in the cache in the plurality of child node objects.
In an example, after step 105, the page inserting method provided in this embodiment may further include: and adding a second child node object which is not in the cache container to the cache container so that when a page references the same reference object, the reference can be directly performed, thereby improving the speed, reducing the memory consumption and reducing the occupied space.
And 106, adding the copied second child node object into the superior parent object, and generating a new page object tree after traversing a plurality of child node objects.
Optionally, because a reference object that is not in the cache container cannot be added to the target page by reference, a copy needs to be made and added to the parent object at the upper level to generate a new page object tree.
And step 107, inserting the new page object tree into the array corresponding to the target page to generate a new page.
Step 108, if the plurality of child node objects further include a third child node object of which the type is a non-reference object, copying the third child node object.
And step 109, adding the copied third child node object into the superior parent object, and generating a new page object tree after traversing a plurality of child node objects.
Step 110, inserting the new page object tree into the array corresponding to the target page to generate a new page.
It will be appreciated that the plurality of child nodes may include a second child node object and a third child node object. Then, the copied second child node object and the copied third child node object may be added to the parent object at the upper level, after traversing multiple child node objects, a new page object tree is generated, and then the new page object tree is inserted into the array corresponding to the target page to generate a new page.
By using the page inserting method provided by the embodiment of the invention, the object which is already quoted in the cache container in the page to be inserted is inserted into the target page in a quoting mode, so that the page inserting speed can be effectively improved, the memory consumption can be reduced, and the disk space occupied by the final file can be reduced.
Fig. 2 is a schematic structural diagram of a page insertion apparatus according to an embodiment of the present invention. The apparatus may be applied to an electronic device.
As shown in fig. 2, the page insertion apparatus of the present embodiment may include:
an obtaining unit 201, configured to obtain a root node object of a page to be inserted, and analyze a plurality of child node objects corresponding to the root node object;
a first determining unit 202, configured to determine types of the child node objects;
a second determining unit 203, configured to determine whether a child node object of which the type is a reference object exists in the cache container;
a reference unit 204, configured to, for a first child node object of the plurality of child node objects, which is a reference object in type and exists in the cache, reference the first child node object from the cache container to a target page to generate a new page.
Preferably, the apparatus further comprises: a first copying unit 205, configured to copy a second child node object of the plurality of child node objects, where the type of the second child node object is a reference object and the second child node object does not exist in the cache; a first adding unit 206, configured to add the copied second child node object to the parent object at the upper level, and generate a new page object tree after traversing the multiple child node objects; a first generating unit 207, configured to insert the new page object tree into the array corresponding to the target page to generate a new page.
Preferably, the apparatus further comprises: a first copying unit 208 for copying a second child node object of the plurality of child node objects, the second child node object being of a type of a reference object and not existing in the cache; a first adding unit 209, configured to add the copied second child node object to the parent object at the upper level, and generate a new page object tree after traversing the child node objects; a first generating unit 210, configured to insert the new page object tree into the array corresponding to the target page to generate a new page.
Preferably, the apparatus comprises: a caching unit (not shown in the figure) configured to add the second child node object to the cache container after the first copying unit 205 copies the second child node object.
Preferably, the second determining unit 203 is specifically configured to: and determining whether the child node object with the type as the reference object exists in the cache container according to the ID of the child node object with the type as the reference object in the child node objects.
Preferably, the apparatus further comprises: a sorting unit (not shown in the figure), configured to, when there are multiple pages to be inserted, sort the pages to be inserted according to a rule set by a user before the obtaining unit 201 obtains a root node object of the pages to be inserted.
By using the page inserting device provided by the embodiment of the invention, the object which is already quoted in the cache container in the page to be inserted is inserted into the target page in a quoted mode, so that the page inserting speed can be effectively improved, the memory consumption can be reduced, and the disk space occupied by the final file can be reduced.
The embodiment of the invention also provides the electronic equipment. Fig. 3 is a schematic structural diagram of an embodiment of an electronic device of the present invention, which can implement the process of the embodiment shown in fig. 1 of the present invention, and as shown in fig. 3, the electronic device may include: the device comprises a shell 31, a processor 32, a memory 33, a circuit board 34 and a power circuit 35, wherein the circuit board 34 is arranged inside a space enclosed by the shell 31, and the processor 32 and the memory 33 are arranged on the circuit board 34; a power supply circuit 35 for supplying power to each circuit or device of the electronic apparatus; the memory 33 is used for storing executable program codes; the processor 32 executes a program corresponding to the executable program code by reading the executable program code stored in the memory 33, for executing the method described in any of the foregoing embodiments.
The electronic device exists in a variety of forms, including but not limited to:
(1) a mobile communication device: such devices are characterized by mobile communications capabilities and are primarily targeted at providing voice, data communications. Such terminals include: smart phones (e.g., iphones), multimedia phones, functional phones, and low-end phones, among others.
(2) Ultra mobile personal computer device: the equipment belongs to the category of personal computers, has calculation and processing functions and generally has the characteristic of mobile internet access. Such terminals include: PDA, MID, and UMPC devices, etc., such as ipads.
(3) A portable entertainment device: such devices can display and play multimedia content. This type of device comprises: audio and video playing modules (such as an iPod), handheld game consoles, electronic books, and intelligent toys and portable car navigation devices.
(4) A server: the device for providing the computing service comprises a processor, a hard disk, a memory, a system bus and the like, and the server is similar to a general computer architecture, but has higher requirements on processing capacity, stability, reliability, safety, expandability, manageability and the like because of the need of providing high-reliability service.
(5) And other electronic equipment with data interaction function.
Embodiments of the present invention provide a computer-readable storage medium storing one or more programs, which are executable by one or more processors to implement a method as in any of the preceding embodiments.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
For convenience of description, the above devices are described separately in terms of functional division into various units/modules. Of course, the functionality of the units/modules may be implemented in one or more software and/or hardware implementations of the invention.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The above description is only for the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A page insertion method, comprising:
acquiring a root node object of a page to be inserted, and analyzing a plurality of child node objects corresponding to the root node object;
determining types of the plurality of child node objects;
determining whether a child node object of the plurality of child node objects of which the type is a reference object exists in a cache container;
and for a first child node object which is of a reference object type and exists in a cache in the plurality of child node objects, referencing the first child node object to a target page from the cache container to generate a new page.
2. The method of claim 1, further comprising:
copying a second child node object of the plurality of child node objects, the second child node object being of a type that is a reference object and not present in a cache;
adding the copied second child node object into the superior parent object, and generating a new page object tree after traversing the child node objects;
and inserting the new page object tree into an array corresponding to the target page to generate a new page.
3. The method according to claim 1 or 2, characterized in that the method further comprises:
if the child node objects also comprise a third child node object of which the type is a non-reference object, copying the third child node object;
adding the copied third child node object into the superior parent object, and generating a new page object tree after traversing the child node objects;
and inserting the new page object tree into an array corresponding to the target page to generate a new page.
4. The method of claim 2, wherein after copying a second child node object of the plurality of child node objects that is of a type that is a reference object and that is not present in a cache, the method further comprises:
adding the second child node object to the cache container.
5. The method of claim 1, wherein determining whether a child node object of the plurality of child node objects of which the type is a reference object exists in a cache container comprises:
and determining whether the child node object with the type as the reference object exists in the cache container according to the ID of the child node object with the type as the reference object in the child node objects.
6. The method according to claim 1, wherein when there are a plurality of pages to be inserted, before obtaining a root node object of a page to be inserted, the method further comprises:
and sequencing the pages to be inserted according to rules set by a user.
7. A page insertion apparatus, comprising:
the system comprises an acquisition unit, a processing unit and a display unit, wherein the acquisition unit is used for acquiring a root node object of a page to be inserted and analyzing a plurality of child node objects corresponding to the root node object;
a first determining unit for determining types of the plurality of child node objects;
a second determining unit, configured to determine whether a child node object of which the type is a reference object exists in the cache container;
and the reference unit is used for referring the first child node object which is of the type of the reference object and exists in the cache to the target page from the cache container so as to generate a new page.
8. The apparatus of claim 7, further comprising:
a first copying unit, configured to copy a second child node object, of the plurality of child node objects, of which the type is a reference object and which does not exist in a cache;
the first adding unit is used for adding the copied second child node object into the superior parent object, and generating a new page object tree after traversing the child node objects;
and the first generating unit is used for inserting the new page object tree into the array corresponding to the target page to generate a new page.
9. The apparatus of claim 7 or 8, further comprising:
a second copying unit, configured to copy a third child node object of which the type is a non-reference object if the plurality of child node objects further include the third child node object;
the second adding unit is used for adding the copied third child node object into the superior parent object, and generating a new page object tree after traversing the child node objects;
and the second generating unit is used for inserting the new page object tree into the array corresponding to the target page to generate a new page.
10. The apparatus of claim 8, wherein the apparatus comprises:
and the cache unit is used for adding the second child node object to the cache container after the first copying unit copies the second child node object.
CN202111646958.4A 2021-12-29 2021-12-29 Page insertion method and device, electronic equipment and storage medium Pending CN114297232A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111646958.4A CN114297232A (en) 2021-12-29 2021-12-29 Page insertion method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111646958.4A CN114297232A (en) 2021-12-29 2021-12-29 Page insertion method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114297232A true CN114297232A (en) 2022-04-08

Family

ID=80972011

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111646958.4A Pending CN114297232A (en) 2021-12-29 2021-12-29 Page insertion method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114297232A (en)

Similar Documents

Publication Publication Date Title
CN109657213B (en) Text similarity detection method and device and electronic equipment
CN111258965B (en) Data acquisition method and device, electronic equipment and storage medium
CN109684497B (en) Image-text matching information sending method and device and electronic equipment
CN110808065A (en) Method and device for detecting refrain, electronic equipment and storage medium
CN110209780B (en) Question template generation method and device, server and storage medium
CN111161283B (en) Picture resource processing method and device and electronic equipment
CN104598571A (en) Method and device for playing multimedia resource
CN114338102A (en) Security detection method and device, electronic equipment and storage medium
CN108804917B (en) File detection method and device, electronic equipment and storage medium
CN110874526A (en) File similarity detection method and device, electronic equipment and storage medium
CN105320641B (en) Text verification method and user terminal
CN109558131A (en) A kind of intelligence generates the method and system of front end static page
CN115048908A (en) Method and device for generating text directory
CN114297232A (en) Page insertion method and device, electronic equipment and storage medium
CN111124883A (en) Test case library introduction method, system and equipment based on tree form
CN112036133B (en) File storage method and device, electronic equipment and storage medium
CN114327310A (en) Electronic document merging printing method and device, electronic equipment and storage medium
KR20230159165A (en) Method, computer device, and computer program to recommend similar product based on keyword
CN113987335A (en) Data collection method and device, electronic equipment and storage medium
CN114064695A (en) Asset information screening method and device, electronic equipment and storage medium
CN111368208A (en) Method and device for recommending target object to user and electronic equipment
CN112036132A (en) Document header and footer editing method and device and electronic equipment
CN112035804A (en) Method and device for inserting watermark identification into document page, electronic equipment and storage medium
CN112035581A (en) Model-based task processing method, device, equipment and medium
CN112036149A (en) File editing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination