CN114969588A - Document browsing method and device, electronic equipment and storage medium - Google Patents

Document browsing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114969588A
CN114969588A CN202210482643.9A CN202210482643A CN114969588A CN 114969588 A CN114969588 A CN 114969588A CN 202210482643 A CN202210482643 A CN 202210482643A CN 114969588 A CN114969588 A CN 114969588A
Authority
CN
China
Prior art keywords
target picture
page
display content
sliding
determining
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
CN202210482643.9A
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.)
Zhejiang Geely Holding Group Co Ltd
Zhejiang Zeekr Intelligent Technology Co Ltd
Original Assignee
Zhejiang Geely Holding Group Co Ltd
Zhejiang Zeekr Intelligent 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 Zhejiang Geely Holding Group Co Ltd, Zhejiang Zeekr Intelligent Technology Co Ltd filed Critical Zhejiang Geely Holding Group Co Ltd
Priority to CN202210482643.9A priority Critical patent/CN114969588A/en
Publication of CN114969588A publication Critical patent/CN114969588A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0484Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range
    • G06F3/0485Scrolling or panning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20112Image segmentation details
    • G06T2207/20132Image cropping

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Artificial Intelligence (AREA)
  • Geometry (AREA)
  • Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Human Computer Interaction (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The invention discloses a document browsing method and device, electronic equipment and a storage medium, and relates to the field of network document processing. The method comprises the following steps: displaying initial display content of a target picture in a current page; the target picture is obtained by converting a PDF document to be browsed; responding to a sliding operation instruction in the page, and determining a first sliding distance of the target picture; determining a first cutting position of the target picture according to the first sliding distance; determining first sliding display content of the target picture based on the first cutting position and the initial width of the target picture; rendering the first sliding display content to a canvas corresponding to the page; and displaying the PDF document based on the initial display content and the first sliding display content. The invention converts the PDF document into the form of the picture to be directly checked in the page, adopts the canvas rendering component, is convenient and quick, and reduces the performance loss and the blockage of the mobile terminal.

Description

Document browsing method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of network document processing, and more particularly, to a document browsing method and apparatus, an electronic device, and a storage medium.
Background
At present, there are many methods for browsing a PDF document in a mobile terminal, for example, calling an APP plug-in uses native code preview, and the effect of calling APP plug-in preview is the best from experience, but the method needs to be used in APP and cannot be used in a browser.
Many browsers also provide a function of directly opening and browsing a PDF document in a web page at present, and send a request for acquiring a content file and an attachment resource file corresponding to a page number to a server by determining the page number of the PDF document to be displayed in a visible area of the web page, so that the server acquires a storage path of the content file and a storage path of the attachment resource file corresponding to the page number according to the request, and returns the content file and the attachment resource file corresponding to the page number according to the acquired paths; and rendering the content file and the attachment resource file corresponding to the page number to obtain a target page, and browsing by rolling the page through a mouse or a scroll bar on the page.
The technical problems existing in the scheme can be as follows: the method comprises the following steps of frequently sending a request to a browser, checking through page numbers, jumping pages, calculating layout information of all information in the pages, redrawing the pages, having high requirements on the browser and easily causing blockage; the browser scroll bar is needed to check and browse, and the backflow and redrawing can be frequently triggered by the scrolling, so that the browsing is blocked, and the performance is influenced.
Disclosure of Invention
In view of the above-mentioned shortcomings of the prior art, the present application aims to solve the problem of PDF document browsing stagnation in a mobile terminal.
In order to solve the technical problem, the invention provides a document browsing method, a document browsing device, an electronic device and a storage medium, wherein the scheme is as follows:
in one aspect, a document browsing method is provided, including:
displaying initial display content of a target picture in a current page, wherein the height of the initial display content is consistent with that of the page; the target picture is obtained by converting a PDF document to be browsed;
responding to a sliding operation instruction in the page, and determining a first sliding distance of the target picture;
determining a first clipping position of the target picture according to the first sliding distance, wherein the first clipping position indicates the sliding height of the sliding display content of the target picture relative to the initial display content;
determining first sliding display content of the target picture based on the first cutting position and the initial width of the target picture;
rendering the first sliding display content to a canvas corresponding to the page; the size information of the canvas is consistent with the size information of the page;
and displaying the PDF document based on the initial display content and the first sliding display content.
Optionally, the method further includes:
in response to a zooming operation instruction in the page, determining a zooming scale, a zooming position and a second sliding distance of the target picture; the scaling is the ratio of the zoomed width of the target picture to the initial width of the target picture; the initial width of the target picture is consistent with the width of the page;
determining a second shearing position of the target picture according to the scaling, the scaling position and the second sliding distance of the target picture; the second clipping position indicates the display height of the zoomed target picture in the page;
determining the zooming display content of the target picture based on the second shearing position and the zoomed width of the target picture;
and rendering the zooming display content to the canvas corresponding to the page.
Optionally, the method further includes:
monitoring a touch screen event of the page, wherein the touch screen event comprises a sliding operation event and a zooming operation event;
when the sliding operation event is monitored, generating the sliding operation instruction;
and when the zooming operation event is monitored, generating the zooming operation instruction.
Optionally, if the first cropping position of the target picture is located at the boundary of the target picture, after determining the first slide display content of the target picture based on the first cropping position and the initial width of the target picture, the method further includes:
determining an adjacent target picture of the target picture according to the direction of the sliding operation; the adjacent target picture is used as a target picture to be displayed;
determining a third shearing position of the adjacent target picture according to the first shearing position of the target picture and the height of the page;
determining second sliding display content of the adjacent target picture based on the third cutting position and the width of the adjacent target picture; the width of the adjacent target picture is consistent with the initial width of the target picture;
after the rendering the first slide show content onto the canvas corresponding to the page, the method further comprises:
and rendering the second sliding display content to the canvas corresponding to the page.
Optionally, the method further includes:
controlling the response time of the touch screen event, and determining the rendering frequency aiming at the page according to the response time; the rendering frequency is the number of times of processing rendering events in a unit time, and represents the fluency of the page when the sliding operation and the zooming operation are carried out.
Optionally, the displaying the initial display content of the target picture in the current page includes:
responding to a conversion instruction, and converting the PDF document into the target picture with the corresponding page number according to the page number of the PDF document to be browsed;
acquiring size information of the page, and determining the initial display content based on the size information; the size information comprises the width and height of the page;
and rendering the initial display content to the canvas corresponding to the page.
Optionally, the method further includes:
creating a canvas element tag, wherein the canvas element tag comprises the size information of the canvas;
and calling a drawing script, and generating the canvas in the page based on the size information of the canvas.
In another aspect, there is provided a document browsing apparatus including:
the conversion module is used for displaying initial display content of the target picture in the current page, and the height of the initial display content is consistent with that of the page; the target picture is obtained by converting a PDF document to be browsed;
the sliding operation module is used for responding to a sliding operation instruction in the page and determining a first sliding distance of the target picture;
a first clipping position determining module, configured to determine a first clipping position of the target picture according to the first sliding distance, where the first clipping position indicates a sliding height of the sliding display content of the target picture relative to the initial display content;
a first sliding display content determining module, configured to determine first sliding display content of the target picture based on the first clipping position and the initial width of the target picture;
the first sliding display content rendering module is used for rendering the sliding display content to a canvas corresponding to the page; the size information of the canvas is consistent with the size information of the page;
and the display module is used for displaying the PDF document based on the initial display content and the first sliding display content.
Optionally, the apparatus further comprises:
the zooming operation module is used for responding to a zooming operation instruction in the page, and determining the zooming proportion, the zooming position and the second sliding distance of the target picture; the scaling is the ratio of the zoomed width of the target picture to the initial width of the target picture; the initial width of the target picture is consistent with the width of the page;
the second shearing position determining module is used for determining a second shearing position of the target picture according to the scaling ratio, the scaling position and the second sliding distance of the target picture; the second clipping position indicates the display height of the zoomed target picture in the page;
a zooming display content determination module, configured to determine zooming display content of the target picture based on the second clipping position and the zoomed width of the target picture;
and the zooming display content rendering module is used for rendering the zooming display content to the canvas corresponding to the page.
Optionally, the apparatus further comprises:
the monitoring module is used for monitoring touch screen events of the page, wherein the touch screen events comprise sliding operation events and zooming operation events;
the sliding operation instruction generating module is used for generating the sliding operation instruction when the sliding operation event is monitored;
and the zooming operation instruction generating module is used for generating the zooming operation instruction when the zooming operation event is monitored.
Optionally, if the first cropping position of the target picture is located at the boundary of the target picture, the apparatus further includes:
the adjacent target picture determining module is used for determining adjacent target pictures of the target pictures according to the direction of the sliding operation; the adjacent target picture is used as a target picture to be displayed;
the second cutting position determining module is used for determining a second cutting position of the adjacent target picture according to the first cutting position of the target picture and the height of the page;
a second sliding display content determining module, configured to determine second sliding display content of the adjacent target picture based on the second clipping position and the width of the adjacent target picture; the width of the adjacent target picture is consistent with the initial width of the target picture;
and the second sliding display content rendering module is used for rendering the second sliding display content to the canvas corresponding to the page.
Optionally, the conversion module includes:
the conversion unit is used for responding to a conversion instruction and converting the PDF document into the target picture with the corresponding page number according to the page number of the PDF document to be browsed;
the initial display content determining unit is used for acquiring the size information of the page and determining the initial display content based on the size information; the size information comprises the width and height of the page;
and the rendering unit is used for rendering the initial display content to the canvas corresponding to the page.
Optionally, the apparatus further comprises:
a canvas creation module for creating a canvas element tag containing size information of the canvas;
and the script calling module is used for calling a drawing script and generating the canvas in the page based on the size information of the canvas.
In another aspect, an electronic device is provided, which includes a processor and a memory, where at least one instruction or at least one program is stored in the memory, and the at least one instruction or the at least one program is loaded by the processor and executed to implement the steps of the above method.
In another aspect, a computer-readable storage medium is provided, wherein at least one instruction or at least one program is stored in the computer-readable storage medium, and the at least one instruction or the at least one program is loaded and executed by a processor to implement the steps of the above method.
In another aspect, a computer program product or computer program is provided, the computer program product or computer program comprising computer instructions stored in a computer readable storage medium, the computer instructions being read by a processor of a computer device from the computer readable storage medium, the computer instructions being executed by the processor to cause the computer device to perform the steps of the above method.
By adopting the technical scheme, the invention has the following beneficial effects:
the PDF document is converted into a picture form and is directly checked in a browser page, an APP plug-in does not need to be downloaded, and the method is more convenient and faster; by adopting the canvas rendering component, the content to be rendered is more accurately controlled, and besides the canvas label node which is just started, the attribute of the dom element does not need to be frequently modified to cause redrawing; the method has the advantages that the sliding operation of the page is monitored, the browser scroll bar is simulated, the scrolling amplitude can be controlled by the user, the user cannot slide down all the time and miss important content, the browser cannot calculate due to backflow and redrawing during scrolling, and accordingly performance loss and blocking of the mobile terminal are reduced.
Additional features and advantages of the invention will be set forth in the detailed description which follows.
Drawings
In order to more clearly illustrate the technical solution in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced, and it is apparent that the drawings in the description are only some embodiments of the present invention, wherein like reference numerals generally represent like parts. For a person skilled in the art, without inventive effort, further figures can be obtained from these figures.
FIG. 1 is a flowchart illustrating a document browsing method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating an alternative method of a document browsing method according to an embodiment of the present invention;
FIG. 3 is a schematic structural diagram of a document browsing apparatus according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a hardware structure of a terminal for operating a document browsing method according to an embodiment of the present invention.
Detailed Description
The technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. 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.
Reference herein to "one embodiment" or "an embodiment" means that a particular feature, structure, or characteristic may be included in at least one implementation of the invention. In the description of the present invention, it is to be understood that the terms "upper", "lower", "top", "bottom", and the like, indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, are only for convenience in describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed in a specific orientation, and be operated, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. Moreover, the terms "first," "second," and the like are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein.
Referring to fig. 1, a flowchart of a document browsing method according to an embodiment of the present invention is shown. It is noted that the present specification provides the method steps as described in the examples or flowcharts, but may include more or less steps based on routine or non-inventive labor. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of orders and does not represent the only order of execution. In practice, the system apparatus or product may be implemented in a sequential or parallel manner (e.g., in the context of parallel processors or multi-threaded processing) according to the embodiments or methods shown in the figures. The document browsing method provided by the embodiment of the invention comprises the following steps:
s101, displaying initial display content of a target picture in a current page, wherein the height of the initial display content is consistent with that of the page; the target picture is obtained by converting a PDF document to be browsed;
in one possible embodiment, the method further comprises:
(1) responding to a conversion instruction, and converting the PDF document into the target picture with the corresponding page number according to the page number of the PDF document to be browsed;
(2) acquiring size information of the page, and determining the initial display content based on the size information; the size information comprises a width and a height of the page;
(3) and rendering the initial display content to the canvas corresponding to the page.
In one possible embodiment, the method further comprises:
creating a canvas element tag, wherein the canvas element tag comprises the size information of the canvas;
and calling a drawing script, and generating the canvas in the page based on the size information of the canvas.
Specifically, in the embodiment of the present invention, an APP plug-in does not need to be downloaded, a PDF document to be browsed is imported in a browser page of a mobile terminal, the mobile terminal may include a mobile phone, a tablet computer, a personal computer, and the like, the PDF document is converted into a target picture, initial display content of the target picture is adapted to size information of the page, the size information of the page may be size information of an entire display interface of the mobile terminal, or size information of a personalized area for displaying characters, icons, or other page elements in a browser preset by a user, and an initial width of the target picture is consistent with a page width, that is, the target picture is displayed in a specified page visible range. In addition, functions of long-press menus, data embedding points, labeling and the like can be added to the page, and using experience is optimized.
In the embodiment of the invention, the canvas adopts canvas elements and is used for drawing and rendering the display content in the target picture. The canvas element itself has no drawing capability and the drawing is done using the draw script JavaScript. The Canvas element has various drawing paths, rectangles, circles, characters and image adding methods, the Canvas element is added to a page at a mobile terminal, a Canvas element label node is created, the width and the height of the element are specified, the width and the height are consistent with the size of the page, a JavaScript script is called to generate a Canvas, a target picture is cut according to the size information of the page by using a Canvas context curtain's drawImage method, and initial display content is rendered on the Canvas. Therefore, except for the initial canvas node, no dom node operation is performed, the attribute of the dom element does not need to be frequently modified, backflow or redrawing is avoided, and blocking is reduced.
S102, responding to a sliding operation instruction in the page, and determining a first sliding distance of the target picture;
s103, determining a first cutting position of the target picture according to the first sliding distance, wherein the first cutting position indicates the sliding height of the sliding display content of the target picture relative to the initial display content;
specifically, the user slides in the page to browse the target picture without a scroll bar of the browser. In one embodiment, when sliding downwards, the first sliding distance refers to a distance from a lower boundary of the initially displayed content of the target picture after sliding to a lower boundary of the page, and the target picture after sliding is taken as a first cut position at the lower boundary of the page.
S104, determining first sliding display content of the target picture based on the first shearing position and the initial width of the target picture;
s105, rendering the first sliding display content to a canvas corresponding to the page; the size information of the canvas is consistent with the size information of the page;
and according to the determined idea of the initial display content, determining the first sliding display content according to the initial width of the target picture and the sliding height indicated by the first cutting position, cutting the first sliding display content based on the first cutting position by using a drawImage, rendering the first sliding display content to a canvas, and completing the sliding browsing.
S106, displaying the PDF document based on the initial display content and the first sliding display content.
In a possible implementation manner, if the first cropping position of the target picture is located at the boundary of the target picture, the determining, based on the first cropping position and the initial width of the target picture, the first slide show content of the target picture further includes:
(1) determining an adjacent target picture of the target picture according to the direction of the sliding operation; the adjacent target picture is used as a target picture to be displayed;
(2) determining a third shearing position of the adjacent target picture according to the first shearing position of the target picture and the height of the page;
(3) determining second sliding display content of the adjacent target picture based on the third cutting position and the width of the adjacent target picture; the width of the adjacent target picture is consistent with the initial width of the target picture;
specifically, the PDF document has a plurality of pages of contents, and is converted into a plurality of pictures, if the first clipping position of the target picture is located at the boundary of the target picture, that is, the content of the target picture is not enough to display the visible region of the page, the adjacent target picture to be displayed is determined according to the direction of the sliding operation, in one embodiment, during the downward sliding operation, the next picture is acquired as the adjacent target picture, the slid target picture is taken as a third clipping position at the lower boundary of the page, and then the second sliding display content is determined according to the height difference between the third clipping position and the first clipping position and the width of the adjacent target picture.
After the rendering of the first sliding display content to the canvas corresponding to the page, the method further comprises: and rendering the second sliding display content to the canvas corresponding to the page. And the first sliding display content and the second sliding display content are taken together as the browsing object of the sliding operation. According to the embodiment of the invention, the simulated scroll is used for replacing the scroll bar of the browser, so that the browser can not calculate due to backflow and redrawing during scrolling, and the fluency of the browser is improved.
Referring to fig. 2, which is a schematic flow chart illustrating an alternative method of a document browsing method according to an embodiment of the present invention, in a possible implementation manner, the document browsing method further includes:
s201, in response to a zooming operation instruction in the page, determining a zooming ratio, a zooming position and a second sliding distance of the target picture; the scaling is the ratio of the zoomed width of the target picture to the initial width of the target picture; the initial width of the target picture is consistent with the width of the page;
besides the sliding operation, the user may perform a zooming operation, including zooming in or zooming out, on the target picture, where the sliding distance is a distance by which the target picture slides with respect to the upper boundary and the lower boundary of the page, and the distance may be determined according to the zooming ratio and the page size.
In a possible implementation manner, the document browsing method further includes:
monitoring a touch screen event of the page, wherein the touch screen event comprises a sliding operation event and a zooming operation event;
when the sliding operation event is monitored, generating the sliding operation instruction;
and generating the zooming operation instruction when the zooming operation event is monitored.
By monitoring the touch screen event of the page in real time and hiding the default scroll bar of the browser, a user can realize scrolling and zooming by himself, the touch screen event triggering time and the redrawing time are ensured to be synchronous, page jumping cannot be caused, and backflow is caused without frequently acquiring the position of the scroll bar.
S202, determining a second shearing position of the target picture according to the scaling ratio, the scaling position and the second sliding distance of the target picture; the second clipping position indicates the display height of the zoomed target picture in the page;
s203, determining the zooming display content of the target picture based on the second shearing position and the zoomed width of the target picture;
s204, rendering the zooming display content to the canvas corresponding to the page.
Specifically, when the zooming-out operation is performed, a zooming-out position is taken as a center, a second cutting position is determined at the upper boundary and the lower boundary of the page according to the zooming-out proportion and the second sliding distance, zooming-out display content is determined according to the second cutting position and the zoomed-out target picture width, and the zoomed-out display content is rendered on the canvas; similarly, when the zooming-in operation is performed, the zooming-in position is taken as the center, the second cutting position is determined at the upper boundary and the lower boundary of the page according to the zooming-in proportion and the second sliding distance, the zooming-in display content is determined according to the second cutting position and the width of the zoomed-in target picture, and the zoomed-in display content is rendered on the canvas.
In one possible implementation, the document browsing method further includes:
controlling the response time of the touch screen event, and determining the rendering frequency aiming at the page according to the response time; the rendering frequency is the number of times of processing rendering events in a unit time, and represents the fluency of the page when the sliding operation and the zooming operation are carried out.
Specifically, the rendering events are cached, a certain number of pages are refreshed, and the frequent redrawing phenomenon of the pages is reduced. The browser maintains 1 queue, puts all operations (rendering events) which can cause backflow and redrawing into the queue, and when the operations in the queue reach a certain number or reach a certain time interval, the browser carries out batch processing, so that the backflow and redrawing for many times are changed into one backflow redrawing, the calculation times are reduced, and the performance is optimized. In the embodiment of the invention, the response time of the touch screen event is controlled, the rendering frequency is controlled to be 30 frames, the jamming can be reduced on the premise of ensuring that the visual experience is not influenced, and the browsing smoothness is improved.
Corresponding to the above document browsing method, embodiments of the present invention further provide a document browsing device, and since the path planning device provided in embodiments of the present invention corresponds to the document browsing methods provided in the foregoing embodiments, embodiments of the document browsing method are also applicable to the document browsing device provided in this embodiment, and are not described in detail in embodiments of the present invention.
Referring to fig. 3, it is a schematic structural diagram of a document browsing apparatus provided in an embodiment of the present invention, where the apparatus has a function of implementing a document browsing method in the foregoing method embodiment, where the function may be implemented by hardware, or may be implemented by hardware executing corresponding software, and the apparatus may include:
a conversion module 301, configured to display initial display content of a target picture in a current page, where a height of the initial display content is consistent with a height of the page; the target picture is obtained by converting a PDF document to be browsed;
a sliding operation module 302, configured to determine a first sliding distance of the target picture in response to a sliding operation instruction in the page;
a first cropping position determining module 303, configured to determine a first cropping position of the target picture according to the first sliding distance, where the first cropping position indicates a sliding height of the sliding display content of the target picture relative to the initial display content;
a first slide show content determination module 304, configured to determine a first slide show content of the target picture based on the first cropping position and the initial width of the target picture; the initial width of the target picture is consistent with the width of the page;
a first slide show content rendering module 305, configured to render the slide show content onto a canvas corresponding to the page; the size information of the canvas is consistent with the size information of the page;
a displaying module 306, configured to display the PDF document based on the initial display content and the first sliding display content.
Optionally, the apparatus further comprises:
the zooming operation module is used for responding to a zooming operation instruction in the page, and determining the zooming proportion, the zooming position and the second sliding distance of the target picture; the scaling is the ratio of the zoomed width of the target picture to the initial width of the target picture; the initial width of the target picture is consistent with the width of the page;
the second shearing position determining module is used for determining a second shearing position of the target picture according to the scaling ratio, the scaling position and the second sliding distance of the target picture; the second clipping position indicates the display height of the zoomed target picture in the page;
a zooming display content determination module, configured to determine zooming display content of the target picture based on the second clipping position and the zoomed width of the target picture;
and the zooming display content rendering module is used for rendering the zooming display content to the canvas corresponding to the page.
Optionally, the apparatus further comprises:
the monitoring module is used for monitoring touch screen events of the page, wherein the touch screen events comprise sliding operation events and zooming operation events;
the sliding operation instruction generating module is used for generating the sliding operation instruction when the sliding operation event is monitored;
and the zooming operation instruction generating module is used for generating the zooming operation instruction when the zooming operation event is monitored.
Optionally, if the first cropping position of the target picture is located at the boundary of the target picture, the apparatus further includes:
the adjacent target picture determining module is used for determining adjacent target pictures of the target pictures according to the direction of the sliding operation; the adjacent target picture is used as a target picture to be displayed;
the second cutting position determining module is used for determining a second cutting position of the adjacent target picture according to the first cutting position of the target picture and the height of the page;
a second sliding display content determining module, configured to determine second sliding display content of the adjacent target picture based on the second clipping position and the width of the adjacent target picture; the width of the adjacent target picture is consistent with the initial width of the target picture;
and the second sliding display content rendering module is used for rendering the second sliding display content to the canvas corresponding to the page.
Optionally, the conversion module includes:
the conversion unit is used for responding to a conversion instruction and converting the PDF document into the target picture with the corresponding page number according to the page number of the PDF document to be browsed;
the initial display content determining unit is used for acquiring the size information of the page and determining the initial display content based on the size information; the size information comprises a width and a height of the page;
and the rendering unit is used for rendering the initial display content to the canvas corresponding to the page.
Optionally, the apparatus further comprises:
the canvas creating module is used for creating a canvas element label, and the canvas element label contains the size information of the canvas;
and the script calling module is used for calling a drawing script and generating the canvas in the page based on the size information of the canvas.
The embodiment of the present invention further provides an electronic device, which includes a processor and a memory, where the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the steps of the above document browsing method.
The memory may be used to store software programs and modules, and the processor may execute various functional applications by executing the software programs and modules stored in the memory. The memory can mainly comprise a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs needed by functions and the like; the storage data area may store data created according to use of the apparatus, and the like. Further, the memory may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory may also include a memory controller to provide the processor access to the memory. The processor may be a central processing unit, but may also be other general purpose processors, such as a microprocessor or the processor may be any conventional processor, a digital signal processor, an application specific integrated circuit or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc.
The method provided by the embodiment of the invention can be executed in a computer terminal, a server or a similar operation device. Taking the operation on the terminal as an example, referring to fig. 4, it is shown a schematic diagram of a hardware structure of the terminal for operating a document browsing method according to the embodiment of the present invention.
Specifically, the terminal may include RF (Radio Frequency) circuitry 410, a memory 420 including one or more computer-readable storage media, an input unit 430, a display unit 440, a sensor 450, audio circuitry 460, a WiFi (wireless fidelity) module 470, a processor 480 including one or more processing cores, and a power supply 490. Those skilled in the art will appreciate that the terminal configuration shown in fig. 4 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
RF circuit 410 may be used for receiving and transmitting signals during a message transmission or call, and in particular, for receiving downlink information from a base station and processing the received downlink information by one or more processors 480; in addition, data relating to uplink is transmitted to the base station. In general, RF circuitry 410 includes, but is not limited to, an antenna, at least one Amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier), a duplexer, and the like. In addition, the RF circuit 410 may also communicate with networks and other terminals through wireless communication. The wireless communication may use any communication standard or protocol, including but not limited to GSM (Global System for Mobile communications), GPRS (General Packet Radio Service), CDMA (Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (Long Term Evolution), email, SMS (Short Messaging Service), and the like.
The memory 420 may be used to store software programs and modules, and the processor 480 executes various functional applications and data processing by operating the software programs and modules stored in the memory 420. The memory 420 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, application programs required for functions, and the like; the storage data area may store data created according to the use of the terminal, and the like. Further, the memory 420 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, memory 420 may also include a memory controller to provide access to memory 420 by processor 480 and input unit 430.
The input unit 430 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. In particular, the input unit 430 may include a touch-sensitive surface 431 as well as other input devices 432. The touch-sensitive surface 431, also referred to as a touch display screen or a touch pad, may collect touch operations by a user on or near the touch-sensitive surface 431 (e.g., operations by a user on or near the touch-sensitive surface 431 using any suitable object or attachment such as a finger, a stylus, etc.) and drive the corresponding connection device according to a predetermined program. Alternatively, the touch sensitive surface 431 may comprise both a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 480, and receives and executes commands sent from the processor 480. In addition, the touch-sensitive surface 431 may be implemented in various types, such as resistive, capacitive, infrared, and surface acoustic wave. The input unit 430 may include other input devices 432 in addition to the touch-sensitive surface 431. In particular, other input devices 432 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 440 may be used to display information input by or provided to a user and various graphic user interfaces of the terminal, which may be configured by graphics, text, icons, video, and any combination thereof. The Display unit 440 may include a Display panel 441, and optionally, the Display panel 441 may be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), or the like. Further, the touch-sensitive surface 431 may overlay the display panel 441, and when a touch operation is detected on or near the touch-sensitive surface 431, the touch operation is transmitted to the processor 480 to determine the type of the touch event, and then the processor 480 provides a corresponding visual output on the display panel 441 according to the type of the touch event. Where the touch sensitive surface 431 and the display panel 441 may implement input and output functions as two separate components, in some embodiments the touch sensitive surface 431 and the display panel 441 may be integrated to implement input and output functions.
The terminal may also include at least one sensor 450, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor that may adjust the brightness of the display panel 441 according to the brightness of ambient light, and a proximity sensor that may turn off the display panel 441 and/or a backlight when the terminal is moved to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally, three axes), detect the magnitude and direction of gravity when the terminal is stationary, and can be used for applications of recognizing terminal gestures (such as horizontal and vertical screen switching, related games, magnetometer gesture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured in the terminal, detailed description is omitted here.
An audio circuit 460, a speaker 461, a microphone 462 may provide an audio interface between a user and the terminal. The audio circuit 460 may transmit the electrical signal converted from the received audio data to the speaker 461, and convert the electrical signal into a sound signal for output by the speaker 461; on the other hand, the microphone 462 converts the collected sound signal into an electric signal, which is received by the audio circuit 460 and converted into audio data, which is then processed by the audio data output processor 480, and then transmitted to, for example, another terminal via the RF circuit 410, or output to the memory 420 for further processing. The audio circuit 460 may also include an earbud jack to provide communication of peripheral headphones with the terminal.
WiFi belongs to short-distance wireless transmission technology, and the terminal can help the user send and receive e-mail, browse web pages, access streaming media, etc. through the WiFi module 470, and it provides wireless broadband internet access for the user. Although fig. 4 shows the WiFi module 470, it is understood that it does not belong to the essential constitution of the terminal, and can be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 480 is a control center of the terminal, connects various parts of the entire terminal using various interfaces and lines, performs various functions of the terminal and processes data by operating or executing software programs and/or modules stored in the memory 420 and calling data stored in the memory 420, thereby integrally monitoring the terminal. Optionally, processor 480 may include one or more processing cores; preferably, the processor 480 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 480.
The terminal also includes a power supply 490 (e.g., a battery) for powering the various components, which may preferably be logically connected to the processor 480 via a power management system to manage charging, discharging, and power consumption via the power management system. The power supply 490 may also include one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and any like components.
Although not shown, the terminal may further include a camera, a bluetooth module, and the like, which are not described herein again. In this embodiment, the terminal further includes a memory and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the one or more processors. The one or more programs include steps for performing the document browsing methods provided by the above-described method embodiments.
The embodiment of the present invention further provides a computer-readable storage medium, where at least one instruction or at least one program is stored in the computer-readable storage medium, and the at least one instruction or the at least one program is loaded and executed by a processor to implement the steps of the above-mentioned document browsing method. In an embodiment of the invention, the computer program comprises computer program code, which may be in source code form, object code form, an executable file or some intermediate form, etc. The computer-readable storage medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer memory, read-only memory, random access memory, electrical carrier signal, telecommunications signal, software distribution medium, etc.
The embodiment of the present application further provides a computer storage medium, where at least one instruction or at least one program is stored in the computer storage medium, and the at least one instruction or the at least one program is loaded and executed by a processor to implement the method described above. In an embodiment of the invention, the computer program comprises computer program code, which may be in source code form, object code form, an executable file or some intermediate form, etc. The computer-readable storage medium may include, but is not limited to: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer memory, read-only memory, random access memory, electrical carrier signal, telecommunications signal, software distribution medium, etc.
Embodiments of the present invention also provide a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the document browsing method provided in the various alternative implementations described above.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (10)

1. A method for browsing a document, comprising:
displaying initial display content of a target picture in a current page, wherein the height of the initial display content is consistent with that of the page; the target picture is obtained by converting a PDF document to be browsed;
responding to a sliding operation instruction in the page, and determining a first sliding distance of the target picture;
determining a first clipping position of the target picture according to the first sliding distance, wherein the first clipping position indicates the sliding height of the sliding display content of the target picture relative to the initial display content;
determining first sliding display content of the target picture based on the first cutting position and the initial width of the target picture;
rendering the first sliding display content to a canvas corresponding to the page; the size information of the canvas is consistent with the size information of the page;
and displaying the PDF document based on the initial display content and the first sliding display content.
2. The document browsing method of claim 1, further comprising:
in response to a zooming operation instruction in the page, determining a zooming scale, a zooming position and a second sliding distance of the target picture; the scaling ratio is the ratio of the zoomed width of the target picture to the initial width of the target picture; the initial width of the target picture is consistent with the width of the page;
determining a second shearing position of the target picture according to the scaling, the scaling position and the second sliding distance of the target picture; the second clipping position indicates the display height of the zoomed target picture in the page;
determining the zooming display content of the target picture based on the second shearing position and the zoomed width of the target picture;
and rendering the zooming display content to the canvas corresponding to the page.
3. The document browsing method of claim 2, further comprising:
monitoring a touch screen event of the page, wherein the touch screen event comprises a sliding operation event and a zooming operation event;
when the sliding operation event is monitored, generating the sliding operation instruction;
and generating the zooming operation instruction when the zooming operation event is monitored.
4. The method for browsing documents according to claim 1, wherein if the first cropping position of the target picture is located at the boundary of the target picture, the determining the first slide show content of the target picture based on the first cropping position and the initial width of the target picture further comprises:
determining an adjacent target picture of the target picture according to the direction of the sliding operation; the adjacent target picture is used as a target picture to be displayed;
determining a third shearing position of the adjacent target picture according to the first shearing position of the target picture and the height of the page;
determining second sliding display content of the adjacent target picture based on the third cutting position and the width of the adjacent target picture; the width of the adjacent target picture is consistent with the initial width of the target picture;
after the rendering the first slide show content onto the canvas corresponding to the page, the method further comprises:
and rendering the second sliding display content to the canvas corresponding to the page.
5. The document browsing method of claim 3, further comprising:
controlling the response time of the touch screen event, and determining the rendering frequency of the page according to the response time; the rendering frequency is the number of times of processing rendering events in a unit time, and represents the fluency of the page when the sliding operation and the zooming operation are carried out.
6. The document browsing method of claim 1, wherein the initial display content of the target picture in the current page comprises:
responding to a conversion instruction, and converting the PDF document into the target picture with the corresponding page number according to the page number of the PDF document to be browsed;
acquiring size information of the page, and determining the initial display content based on the size information; the size information comprises a width and a height of the page;
and rendering the initial display content to the canvas corresponding to the page.
7. The document browsing method of claim 6, further comprising:
creating a canvas element tag, wherein the canvas element tag comprises the size information of the canvas;
and calling a drawing script, and generating the canvas in the page based on the size information of the canvas.
8. A document browsing apparatus, comprising:
the conversion module is used for displaying initial display content of the target picture in the current page, and the height of the initial display content is consistent with that of the page; the target picture is obtained by converting a PDF document to be browsed;
the sliding operation module is used for responding to a sliding operation instruction in the page and determining a first sliding distance of the target picture;
a first clipping position determining module, configured to determine a first clipping position of the target picture according to the first sliding distance, where the first clipping position indicates a sliding height of the sliding display content of the target picture relative to the initial display content;
a first sliding display content determining module, configured to determine first sliding display content of the target picture based on the first clipping position and the initial width of the target picture;
the first sliding display content rendering module is used for rendering the sliding display content to a canvas corresponding to the page; the size information of the canvas is consistent with the size information of the page;
and the display module is used for displaying the PDF document based on the initial display content and the first sliding display content.
9. An electronic device comprising a processor and a memory, wherein at least one instruction or at least one program is stored in the memory, and wherein the at least one instruction or the at least one program is loaded and executed by the processor to implement the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, in which at least one instruction or at least one program is stored, which is loaded and executed by a processor to implement the steps of the method according to any one of claims 1 to 7.
CN202210482643.9A 2022-05-05 2022-05-05 Document browsing method and device, electronic equipment and storage medium Pending CN114969588A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210482643.9A CN114969588A (en) 2022-05-05 2022-05-05 Document browsing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210482643.9A CN114969588A (en) 2022-05-05 2022-05-05 Document browsing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114969588A true CN114969588A (en) 2022-08-30

Family

ID=82981956

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210482643.9A Pending CN114969588A (en) 2022-05-05 2022-05-05 Document browsing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114969588A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115828007A (en) * 2022-11-21 2023-03-21 上海秉匠信息科技有限公司 Page display method, device, system, electronic equipment and medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115828007A (en) * 2022-11-21 2023-03-21 上海秉匠信息科技有限公司 Page display method, device, system, electronic equipment and medium
CN115828007B (en) * 2022-11-21 2023-08-04 上海秉匠信息科技有限公司 Page display method, device and system, electronic equipment and medium

Similar Documents

Publication Publication Date Title
CN106406712B (en) Information display method and device
RU2616536C2 (en) Method, device and terminal device to display messages
JP6368455B2 (en) Apparatus, method, and program
WO2017008551A1 (en) Bullet screen display method and apparatus
US20150082231A1 (en) Method and terminal for displaying desktop
CN105975190B (en) Graphical interface processing method, device and system
CN104102419B (en) Page display method, device and terminal device
CN108205398B (en) Method and device for adapting webpage animation to screen
CN107247691B (en) Text information display method and device, mobile terminal and storage medium
US20150301991A1 (en) Webapp startup method and device
WO2015014305A1 (en) Method and apparatus for presenting clipboard contents on a mobile terminal
CN108920226B (en) Screen recording method and device
CN107766548B (en) Information display method and device, mobile terminal and readable storage medium
WO2014206055A1 (en) A method and system for generating a user interface
US9977661B2 (en) Method and system for generating a user interface
CN108073647B (en) Webpage display method and device
CN108763297B (en) Webpage resource processing method and device and mobile terminal
US20150089431A1 (en) Method and terminal for displaying virtual keyboard and storage medium
CN109491738A (en) A kind of control method and terminal device of terminal device
CN108763544A (en) A kind of display methods and terminal
CN109992337B (en) Webpage display method and device and storage medium
CN110383244A (en) A kind of operation method and terminal of calculator
CN115390707A (en) Sharing processing method and device, electronic equipment and storage medium
CN106204588B (en) Image processing method and device
CN105095259B (en) Waterfall flow object display method and device

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