Method and terminal device for importing portable document format files
By converting PDF files into pictures and displaying them in rich text editors, the problem that PDF notes and rich text notes cannot be edited simultaneously in the prior art is solved, and the mixing of PDF files and text is realized, improving the user experience.
Patent Information
- Application Number
- CN202211467952.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-22
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2042-11-22
AI Technical Summary
The prior art cannot edit PDF notes and rich text notes simultaneously in the same note, resulting in the inability to mix PDF files and text.
By responding to user operations, convert the PDF file into at least one picture and display the picture in the editing area of the notes. The picture-text mixing mechanism of the rich text editor can be used to achieve the mixing effect of PDF file and text.
It realizes the editing of PDF files and text at the same time in the same note, improving the user's operation convenience and user experience.
Smart Images

Figure CN116737667B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal technology, and in particular to a method and terminal device for importing files in a portable document format. Background Art
[0002] Currently, various types of applications can be installed on terminal devices to provide users with various functions. The memo application is an application that allows users to record life, work and other events at any time. In some memos, multiple note formats can be recorded, such as portable document format (PDF) notes and rich text notes. Among them, PDF notes are an independent note format, and rich text notes are a note format that is parsed and rendered by a rich text editor. The data format is the fifth generation version of the hierarchical data format (H5), so it can also be an H5 format rich text note.
[0003] However, since PDF notes and rich text notes are in two different formats, PDF notes and rich text notes cannot be edited in one note at the same time.
[0004] Therefore, how to edit PDF notes and rich text notes in the same note, so as to achieve mixed layout of PDF files and text, becomes an urgent problem to be solved. Summary of the invention
[0005] The present application provides a method and terminal device for importing PDF files, which is conducive to the mixed layout of PDF files and text in the same note.
[0006] In a first aspect, the present application provides a method for importing a PDF file, the method comprising: in response to a user's operation of importing a PDF file in a note in a memo application, obtaining a PDF file, the PDF file comprising at least one page; obtaining at least one picture based on the PDF file, the at least one picture corresponding one-to-one to the at least one page of the PDF file; and displaying the at least one picture in the editing area of the note.
[0007] Based on the technical solution of the present application, in response to the user's operation of importing a PDF file into a note, the terminal device converts the PDF file into at least one picture and displays the at least one picture in the editing area. The note can be a newly created blank note or a note created by the user and edited with text or pictures. After converting the PDF file into the at least one picture, the terminal device can use the text and image mixing mechanism of the rich text editor to achieve the mixed effect of PDF files and text in the same note.
[0008] In combination with the first aspect, in certain implementations of the first aspect, after displaying the at least one picture in the editing area of the note, the method further includes: in response to the user's operation of editing text above or below any one of the at least one picture, displaying the text edited by the user at the user's editing location.
[0009] Based on the technical solution of the present application, the terminal device utilizes the mixed text and image typesetting mechanism of the rich text editor to edit text in the editing area including the at least one image, thereby achieving a mixed typesetting effect of the PDF file and text.
[0010] In combination with the first aspect, in certain implementations of the first aspect, after displaying the at least one picture in the editing area of the note, the method also includes: in response to a user's deletion operation on the first target picture in the editing area, deleting the first target picture in the editing area, the first target picture including one or more of the at least one picture; and / or, in response to a user's dragging operation on the second target picture in the editing area, adjusting the position of the second target picture in the editing area.
[0011] Based on the technical solution of the present application, the terminal device can edit at least one picture converted from the PDF file in response to the user's operation, including deleting the first target picture, or dragging the second target picture to adjust the position of the second target picture. Wherein, the at least one picture includes the second target picture.
[0012] In combination with the first aspect, in certain implementations of the first aspect, in response to an operation of a user importing a PDF file in a note in a memo application, before obtaining the PDF file, the method also includes: receiving an operation of the user importing a file in the note; and determining that the operation is an operation of importing a PDF file.
[0013] In combination with the first aspect, in some implementations of the first aspect, obtaining at least one picture according to the PDF file includes: converting each page of the PDF file into a picture to obtain the at least one picture.
[0014] In combination with the first aspect, in certain implementations of the first aspect, before displaying the at least one picture in the editing area of the note, the method also includes: determining a selection in the editing area of the note; determining an insertion position of the at least one picture in the data structure based on the selection; inserting the at least one picture at the insertion position; recording changes in the data structure, the changes in the data structure including inserting the at least one picture at the insertion position; displaying the at least one picture in the editing area of the note, including: displaying the at least one picture in the editing area of the note based on the changes in the data structure.
[0015] In combination with the first aspect, in certain implementations of the first aspect, after displaying the at least one picture in the editing area of the note, the method further includes: prompting the user that the import of the PDF file has been completed.
[0016] In combination with the first aspect, in some implementations of the first aspect, prompting the user that the importing of the PDF file has been completed includes: highlighting a control for importing the file to prompt the user that the importing of the PDF file has been completed.
[0017] In combination with the first aspect, in some implementations of the first aspect, prompting the user that the import of the PDF file has been completed includes: prompting the user that the import of the PDF file has been completed through text.
[0018] In a second aspect, the present application provides a terminal device, which may also be referred to as a terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. The terminal device may be a mobile phone, a personal computer (PC), a smart TV, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc.
[0019] The terminal device comprises: a processor and a memory; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the terminal device executes the method of the first aspect.
[0020] In a third aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the method of the first aspect is implemented.
[0021] In a fourth aspect, the present application provides a computer program product, which includes a computer program. When the computer program is executed, the computer executes the method of the first aspect.
[0022] In a fifth aspect, the present application provides a chip, the chip comprising a processor, the processor being used to call a computer program in a memory to execute the method described in the first aspect.
[0023] It should be understood that the second to fifth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 It is a schematic diagram of the structure of a terminal device applicable to the embodiment of the present application;
[0025] Figures 2 to 5 It is a schematic diagram of the interface of the memo provided in the embodiment of the present application;
[0026] Figure 6 This is a schematic diagram of a framework for importing a PDF file provided in an embodiment of the present application;
[0027] Figure 7 This is another schematic diagram of a framework for importing a PDF file provided in an embodiment of the present application;
[0028] Figure 8 is a schematic flow chart of a method for mixing PDF files and texts provided in an embodiment of the present application;
[0029] Fig. 9 It is a schematic flowchart of a method for importing a PDF file provided in an embodiment of the present application. DETAILED DESCRIPTION
[0030] The technical solution in this application will be described below in conjunction with the accompanying drawings.
[0031] In order to clearly describe the technical solutions of the embodiments of the present application, some of the terms involved in the embodiments of the present application are briefly introduced below:
[0032] In the embodiments of the present application, words such as "first" and "second" are used to distinguish the same or similar items with substantially the same functions and effects, and do not limit their order. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.
[0033] It should be noted that, in this application, words such as "exemplarily" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplarily" or "for example" in this application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a specific way.
[0034] In addition, "at least one" means one or more, and "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can mean: a, or b, or c, or a and b, or a and c, or b and c, or a, b and c, where a, b, c can be single or multiple.
[0035] It should be noted that the "at..." in the embodiment of the present application can be the instant when a certain situation occurs, or a period of time after a certain situation occurs, and the embodiment of the present application does not specifically limit this. In addition, the display interface provided in the embodiment of the present application is only an example, and the display interface can also include more or less content.
[0036] Figure 1 Schematic diagram of the structure of a terminal device applicable to the embodiment of the present application. Figure 1 As shown, the terminal device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a USB interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. It can be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.
[0037] The processor 110 may include one or more processing units, for example: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, a display processing unit (displayprocess unit, DPU), and / or a neural-network processing unit (neural-network processing unit, NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors. In some embodiments, the terminal device 100 may also include one or more processors 110. Among them, the processor may be the nerve center and command center of the terminal device 100. The processor may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions. A memory may also be set in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a high-speed cache memory. The memory may save instructions or data used or recycled by the processor 110. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110 , and thus improves the efficiency of the terminal device 100 .
[0038] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a USB interface, etc. Among them, the USB interface 130 is an interface that complies with the USB standard specification, and can specifically be a Mini USB interface, a MicroUSB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the terminal device 100, and can also be used to transmit data between the terminal device 100 and a peripheral device. It can also be used to connect headphones and play audio through the headphones.
[0039] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is for illustrative purposes only and does not constitute a structural limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0040] The wireless communication function of the terminal device 100 can be implemented by antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modulation and demodulation processor and baseband processor. Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the terminal device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antenna. For example, antenna 1 can be reused as a diversity antenna of a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0041] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the terminal device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier, etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0042] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.
[0043] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN), Bluetooth, global navigation satellite system (GNSS), frequency modulation (FM), NFC, infrared technology (IR), etc. applied to the terminal device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and filters it, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0044] In some embodiments, the antenna 1 of the terminal device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the terminal device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include GSM, GPRS, CDMA, WCDMA, TD-SCDMA, LTE, GNSS, WLAN, NFC, FM, and / or IR technology. The above-mentioned GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0045] The terminal device 100 can realize the display function through the GPU, the display screen 194 and the application processor. The application processor may include an NPU and / or a DPU. The GPU is a microprocessor for image processing, which is connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute instructions to generate or change display information. The NPU is a neural network (NN) computing processor, which quickly processes input information by drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, and can also continuously self-learn. The NPU can realize applications such as intelligent cognition of the terminal device 100, such as image recognition, face recognition, voice recognition, text understanding, etc. The DPU is also called a display subsystem (DSS). The DPU is used to adjust the color of the display screen 194. The DPU can adjust the color of the display screen through a color three-dimensional (3D) lookup table (LUT). DPU can also perform image scaling, noise reduction, contrast enhancement, backlight brightness management, HDR processing, and display parameter Gamma adjustment.
[0046] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed or a quantum dot light-emitting diode (QLED). In some embodiments, the terminal device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0047] The terminal device 100 can realize the shooting function through an ISP, one or more cameras 193, a video codec, a GPU, one or more display screens 194, and an application processor.
[0048] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, data files such as music, photos, and videos are stored in the external memory card.
[0049] The internal memory 121 can be used to store one or more computer programs, which include instructions. The processor 110 can enable the terminal device 100 to perform various functional applications and data processing by running the above instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system; the program storage area can also store one or more applications (such as a gallery, contacts, etc.). The data storage area can store data (such as photos, contacts, etc.) created during the use of the terminal device 100. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. In some embodiments, the processor 110 can enable the terminal device 100 to perform various functional applications and data processing by running instructions stored in the internal memory 121 and / or instructions stored in a memory provided in the processor 110.
[0050] The terminal device 100 can implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, and an application processor. For example, music playback, recording, etc. Among them, the audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be set in the processor 110, or some functional modules of the audio module 170 are set in the processor 110. The speaker 170A, also known as a "speaker", is used to convert audio electrical signals into sound signals. The terminal device 100 can listen to music or listen to hands-free calls through the speaker 170A. The receiver 170B, also known as a "handset", is used to convert audio electrical signals into sound signals. When the terminal device 100 answers a call or voice message, the voice can be answered by placing the receiver 170B close to the human ear. Microphone 170C, also known as "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can make a sound by approaching the microphone 170C with his mouth to input the sound signal into the microphone 170C. The terminal device 100 can be provided with at least one microphone 170C. In other embodiments, the terminal device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the terminal device 100 can also be provided with three, four or more microphones 170C to realize the collection of sound signals, noise reduction, identification of sound sources, realization of directional recording functions, etc. The headphone jack 170D is used to connect wired headphones. The headphone jack 170D can be a USB interface 130, or a 3.5mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0051] The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
[0052] The application layer of the terminal device 100 includes a memo application, which allows users to record life, work and other events at any time. In some memos, multiple note formats can be recorded, such as PDF notes and rich text notes. Among them, PDF notes are an independent note format, and rich text notes are a note format that is parsed and rendered by a rich text editor. The data format is H5, so it can also be called H5 format rich text notes. Figure 5 A schematic diagram of the interface of the memo provided in the embodiment of the present application is introduced.
[0053] Figure 2 Taking the interface of the memo on the PC as an example, the interface of the memo can be divided into multiple areas, including the folder list area, the note list area, the user event response area, and the editing area of the rich text editor.
[0054] When the user clicks on a note in the note list, the content of the note will be displayed in the editing area. Figure 2 The note that the user chooses to open is a newly created note. The user has not yet entered any content, so the note has no title yet. The user can perform editing actions on the note.
[0055] Exemplarily, the editing behavior may include adding text, adding pictures, importing PDF files, setting bold, setting italics, setting font size, setting color, etc.
[0056] When a user wants to import a PDF file into a note, the user can click Figure 2 In response to the user clicking on the control 01, as shown in Figure 3 As shown in FIG. 1 , the word “Import” is shown in the user event response area. When the user selects “Import”, Figure 4 As shown in the figure, a file selection window pops up on the PC, prompting the user to select a PDF file. After the user selects a PDF file, Figure 5 As shown, the content of the PDF file selected by the user is displayed in the editing area.
[0057] In some scenarios, users may want to mix PDF files and text in the same note. For example Figure 5 As shown, the user has imported a PDF file into a note. When reading the PDF file, the user may want to enter text in the note to record the reading experience while reading.
[0058] However, since PDF notes and rich text notes are in two different formats, PDF notes and rich text notes cannot be edited in one note at the same time. In other words, if a PDF file has been imported into a note, the user cannot edit the text in this note; conversely, if there is already edited text in a note, the user cannot import a PDF file into this note. Therefore, the user may need to create a new note to record the reading experience separately, which requires the user to frequently switch between the two notes, which brings great inconvenience to the user, is not conducive to user operation, and reduces the user experience.
[0059] In view of this, an embodiment of the present application provides a method for importing a PDF file. When the terminal device determines that the user operation is an operation of importing a PDF file, that is, when the imported file is a PDF file, the terminal device converts each page of the PDF file into a separate picture and displays it in the editing area of the note, thereby completing the import of the PDF file. Then, based on the mixed text and image mechanism, the terminal device can display the text edited by the user in the editing area including the picture converted from the PDF file, thereby realizing the mixed typesetting of the PDF file and the text.
[0060] Figure 6 It is a schematic diagram of a framework for importing a PDF file provided in an embodiment of the present application. Figure 6 Taking the memo on the Android side as an example, the memo on the Android side includes a native layer and a web view layer.
[0061] Among them, the native layer uses the Android native application programming interface (API) and user interface (UI) framework to implement UI rendering, and obtains user intentions by monitoring events in the UI layer, and passes the monitored events to the native layer through javascript (JS) and Android's communication interface (JS interface).
[0062] The WebView layer is used to connect the interface layer and the rich text editor, including the interface layer and the rich text editor. The interface layer is used to render components other than the editor and carries the communication interface between JS and Android.
[0063] The rich text editor is a framework that enables users to edit rich text content, including five modules: rendering mechanism, history, plug-in mechanism, behavior, and data model.
[0064] The data model can construct a tree structure according to the data format and use the Web characteristics to correspond the cursor and selection to the data structure through the path and offset. The cursor position is determined by a path and an offset. The value of the path represents the path from the root of the document's data model to the text interface where the cursor is located; the offset represents the offset of the cursor on the text interface.
[0065] Behaviors can define operations on data in the data model into nine types of behaviors, including: insert node, split node, insert selection, move node, insert text, merge node, set attribute, remove node, and remove text. These nine types of operations can be used in history backtracking and collaborative editing scenarios.
[0066] The plug-in mechanism can be combined with the elements rendered by the interface (text, pictures, tables, etc.) based on the above nine behaviors. Data and behaviors can be combined to achieve different functions. Different formats of data in the rich text editor are implemented in the plug-in mechanism, such as lists, ordered lists, unordered lists, etc.
[0067] History records are used to record every action of the user.
[0068] The rendering mechanism relies on open source UI frameworks and Web capabilities to render elements in the data structure onto the interface.
[0069] Figure 7 It is another schematic diagram of a framework for importing a PDF file provided in an embodiment of the present application. Figure 7 Taking the memo application on the PC as an example, the memo application on the PC implements the editor function based on the Web framework. The memo application includes a UI rendering layer, a user event processing service, a command service, and a rich text editor. The UI rendering layer includes react components, hypertext mark-up language (HTML) layout, and cascading style sheets (CSS) styles.
[0070] The UI rendering layer can pass the user's click event to the user event processing service. The user event processing service identifies the user's intent based on the event and calls the instruction service to match the instruction corresponding to the user's intent. Exemplarily, the user's intent may include setting bold, setting italics, adding pictures, adding colors, setting font size, etc. Through a series of operations such as instruction subscription, instruction matching, and instruction distribution, the instruction is passed to the rich text editor, and the rich text editor implements the editing behavior expected by the user based on the instruction.
[0071] Similar to the overall design concept of Android, the rich text editor includes five modules: rendering mechanism, history record, plug-in mechanism, behavior, and data model. For a description of each module, please refer to the above Figure 6 The description in will not be repeated here.
[0072] Combine the following Figure 8 , describes a method for a terminal device to achieve mixed layout of PDF files and texts through internal interaction.
[0073] Figure 8 800 is a schematic flow chart of a method 800 for mixing PDF files and text provided in an embodiment of the present application. The method 800 can be interactively executed by internal modules of a terminal device, the terminal device includes a memo application, the memo application includes a rich text editor, and the rich text editor can be integrated in an Android platform (such as Figure 6 ), or Windows platform (such as Figure 7 shown).
[0074] Figure 8 The terminal device shown includes a UI rendering layer, a user event processing service, a command service, and a rich text editor. The rich text editor includes five modules: rendering mechanism, history record, plug-in mechanism, behavior, and data model.
[0075] The method 800 includes S801 to S844, and the specific steps are as follows:
[0076] S801, the UI rendering layer renders the UI interface of the memo in response to the user's operation of starting the memo application. The rendered UI interface can be as follows Figure 2 shown.
[0077] S802: The UI rendering layer sends an initialization instruction to the rendering mechanism, instructing the rich text editor to be initialized. Accordingly, the rendering mechanism receives the initialization instruction.
[0078] S803, the rendering mechanism initializes the components of the rich text editor based on the initialization instruction, loads the data model, and initializes the data structure. If data exists, the data is loaded into the data model, and if the data is empty, an empty data model object is created.
[0079] S804, the UI rendering layer sends a start instruction to the instruction service and registers the currently supported function instructions. Correspondingly, the instruction service receives the start instruction.
[0080] Exemplarily, the function instructions may include an instruction to add a PDF file, an instruction to bold a font, an instruction to italicize a font, an instruction to highlight a font, an instruction to add a picture, and the like.
[0081] S805, the UI rendering layer receives an event of the user importing the file, and sends the event to the user event processing service. Correspondingly, the user event processing service receives the event.
[0082] S806, the user event processing service identifies the user intention based on the event. In this step, the user intention is to import a PDF file.
[0083] S807, the user event processing service sends the user intention to the instruction service. Correspondingly, the instruction service receives the user intention.
[0084] S808, the instruction service identifies the function instruction registered in S804 according to the user intention. If the instruction to add a PDF file is matched, S809 is executed; if no function instruction is matched, the process stops.
[0085] S809, the instruction service sends a function instruction matching the user's intention to the plug-in mechanism. Correspondingly, the plug-in mechanism receives the function instruction matching the user's intention.
[0086] S810, the plug-in mechanism identifies a function instruction that matches the user's intention and determines that the user expects to import a PDF file. Therefore, the plug-in mechanism obtains the PDF file, splits the PDF file, and converts each page of the PDF file into an image to obtain at least one image.
[0087] S811, the plug-in mechanism determines and executes the business logic of adding a picture.
[0088] S812, the plug-in mechanism sends an instruction to identify the selected area to the data model. Correspondingly, the data model receives the instruction to identify the selected area. The selected area here includes a cursor, which is a selected area with the same starting point and end point.
[0089] S813, the data model identifies the selection in the editing area of the note.
[0090] S814, the data model sends a message of completing identification to the plug-in mechanism. Correspondingly, the plug-in mechanism receives the message of completing identification.
[0091] S815, the plug-in mechanism sends an instruction to abstract the operation of adding a picture to the behavior. Correspondingly, the behavior receives the instruction to abstract the operation of adding a picture.
[0092] S816, the behavior is based on the instruction to abstract the operation of adding the image, and the operation of adding the image is abstracted into the insertion node in the nine behaviors described above.
[0093] S817, the behavior sends an instruction to update the data structure to the data model, carrying the abstracted behavior (ie, inserting a node). Correspondingly, the data model receives the instruction to update the data structure.
[0094] S818, the data model determines that an operation of inserting a picture into the data structure is to be performed based on the abstracted behavior, and locates the insertion position of at least one picture obtained after the PDF file is converted into the data structure based on the selected area identified in S813.
[0095] S819, the data model is updated according to the insertion position. Updating the data model includes inserting the at least one picture at the insertion position.
[0096] S820, the data model sends an instruction to add a behavior to the historical record, carrying the change of the data structure. Correspondingly, the historical record receives the instruction to add a behavior.
[0097] The change of the data structure includes inserting the at least one picture at the insertion position, that is, the image data in the data structure is changed.
[0098] S821, the history record adds the user behavior to the history stack and records the changes in the data structure.
[0099] S822: The history record sends the data structure changes to the rendering mechanism. Correspondingly, the rendering mechanism receives the data structure changes.
[0100] S823, the rendering mechanism updates the change of the data structure to the UI interface, and displays the at least one picture on the UI interface.
[0101] S824, the rendering mechanism sends a message of successful update to the UI rendering layer. Correspondingly, the UI rendering layer receives the message of successful update.
[0102] Optionally, the method 800 further includes S825, where the UI rendering layer prompts the user that the import of the PDF file has been completed.
[0103] In one possible implementation, the UI rendering layer highlights (e.g., highlights, bolds) a control for importing a file (e.g., Figure 3 Controls in 01).
[0104] In another possible implementation, the UI rendering layer prompts the user through text that the import of the PDF file has been completed.
[0105] After the above-mentioned import of the PDF file is completed, since the PDF file has been converted into at least one picture, the user can process the at least one picture in the editing area, for example, delete the first target picture therein, the first target picture includes one or more pictures in the at least one picture; for example, drag the second target picture in the at least one picture to change the order of the at least one picture, the second target picture includes one or more pictures in the at least one picture.
[0106] By executing the above steps, the terminal device can display at least one image converted from the PDF file in a note, so that the user can perform subsequent editing actions in the editing area including the at least one image, such as editing text, inserting images, and continuing to import PDF files. It should be understood that in the process of continuing to import PDF files, the terminal device still splits the PDF file into images to display in the editing area.
[0107] The following steps take the example of a user editing text in the editing area after importing a PDF file to introduce the interactive process of adding text inside the terminal device.
[0108] The UI rendering layer receives the event of the user editing text and sends the event to the user event processing service. S826 to S830 are similar to S805 to S809 described above, except that the user event processing service identifies the user intention as editing text, and the function instruction subsequently matched and passed to the plug-in mechanism is the edit text instruction.
[0109] In S831, after the plug-in mechanism recognizes that the function instruction is an edit text instruction, it enters the business logic of editing text.
[0110] S832 to S844 are similar to S812 to S824 described above, with the difference that the behavior abstracts the operation of editing text into nine behaviors, and the data model determines that it is to perform the operation of inserting text in the data structure based on the abstracted behavior, and locates the insertion position of the text in the data structure based on the selection identified in S833, and updates the data model based on the insertion position. In S841, the behavior added to the history record is inserting text, and the change in the data structure includes inserting text at the located insertion position. In S843, the rendering mechanism updates the changes in the data structure to the UI interface and adds the user-edited text to the UI interface.
[0111] In an embodiment of the present application, before the PDF file is imported into the note initially opened by the user, the note may include information such as text edited by the user or pictures inserted, or may not include any content edited or inserted by the user, and this embodiment of the present application is not limited to this.
[0112] In summary, Fig. 9 It is a schematic flowchart of a method 900 for importing a PDF file provided in an embodiment of the present application.
[0113] The method 900 includes S901 to S903, and the specific steps are as follows:
[0114] S901, in response to a user's operation of importing a PDF file into a note in a memo application, obtaining a PDF file, where the PDF file includes at least one page.
[0115] Optionally, the note opened by the user may include text edited by the user or a picture inserted, or it may be a blank note newly created by the user, which is not limited in this embodiment of the present application.
[0116] S902, obtaining at least one picture according to the PDF file, wherein the at least one picture corresponds one-to-one to the at least one page of the PDF file.
[0117] In this step, the terminal device converts each page of the PDF file into a picture to obtain the at least one picture.
[0118] S903: Display the at least one picture in the editing area of the note.
[0119] It should be understood that the sequence numbers of the above processes do not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0120] The method for importing a PDF file provided in the embodiment of the present application can be applied to a terminal device with a communication function. The specific device form of the terminal device can refer to the above related description, which will not be repeated here.
[0121] An embodiment of the present application provides a terminal device, which includes: a processor and a memory; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the terminal device executes the above method.
[0122] The embodiment of the present application provides a chip. The chip includes a processor, and the processor is used to call a computer program in a memory to execute the technical solution in the above embodiment. Its implementation principle and technical effect are similar to those of the above related embodiments, and will not be repeated here.
[0123] The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program. The above method is implemented when the computer program is executed by the processor. The method described in the above embodiment can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the function can be stored as one or more instructions or codes on a computer-readable medium or transmitted on a computer-readable medium. Computer-readable media can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium that can be accessed by a computer.
[0124] In one possible implementation, a computer readable medium may include random access memory (RAM), read-only memory (ROM), compact disc read-only memory (CD-ROM) or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that is intended to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer. Moreover, any connection is appropriately referred to as a computer readable medium. For example, if the software is transmitted from a website, server or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wireless technologies such as infrared, radio and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technologies such as infrared, radio and microwave are included in the definition of medium. Disks and optical disks as used herein include optical disks, laser disks, optical disks, digital versatile discs (DVD), floppy disks and Blu-ray discs, where disks usually reproduce data magnetically, while optical disks reproduce data optically using lasers. Combinations of the above should also be included within the scope of computer readable media.
[0125] An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed, the computer executes the above method.
[0126] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0127] The above specific implementation methods further illustrate the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above are only specific implementation methods of the present application and are not used to limit the protection scope of the present application. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present application should be included in the protection scope of the present application.
Claims
1. A method for importing a portable document format file, characterized in that: Applied to a terminal device, the terminal device includes a memo application, the memo includes a web view WebView layer, the web view WebView layer includes a UI rendering layer, an instruction service and a rich text editor, and the rich text editor includes the following modules: Rendering mechanism, history record, plug-in mechanism, behavior and data model; the memorandum also includes a user event processing service; the method includes: The UI rendering layer sends an initialization instruction to the rendering mechanism; The rendering mechanism initializes the components of the rich text editor based on the initialization instruction, loads the data model, and initializes the data structure; The UI rendering layer sends a start instruction to the instruction service and registers the currently supported function instructions, where the currently supported function instructions include adding a PDF file instruction; The UI rendering layer receives an event of a user importing a file, and sends the event to the user event processing service; The user event processing service identifies the user intention based on the event, and sends the user intention to the instruction service; The instruction service matches the currently supported function instructions according to the user intention; if the add PDF file instruction is matched, the function instruction matching the user intention is sent to the plug-in mechanism; The plug-in mechanism identifies a functional instruction matching the user intention, determines a PDF file to be imported, and obtains the PDF file, wherein the PDF file includes at least one page; The plug-in mechanism converts each page of the PDF file into an image to obtain at least one image, and each image in the at least one image corresponds one-to-one to the at least one page of the PDF file; The plug-in mechanism determines and executes the business logic of adding a picture, and sends an instruction to identify a selection area to the data model; The data model identifies the selection area in the editing area of the note in the memo application, and sends an identification completion message to the plug-in mechanism; The plug-in mechanism receives the recognition completion message and sends an instruction to the behavior to abstract the operation of adding the picture; The behavior is based on an instruction for abstracting an operation of adding a picture, abstracting the operation of adding a picture into an insert node in the behavior; and sending an instruction for updating a data structure to the data model, the instruction carrying the insert node; The data model determines, according to the insertion node, to perform an operation of inserting a picture into the data structure, locates an insertion position of the at least one picture in the data structure according to the selection area, and inserts the at least one picture at the insertion position to obtain an updated data model; The updated data model sends an instruction to add a behavior to the historical record, wherein the instruction to add a behavior carries a change in the data structure; The history record receives the instruction of adding the behavior, records the change of the data structure, and sends the change of the data structure to the rendering mechanism; The rendering mechanism updates the changes of the data structure on the UI interface, and displays the at least one picture in the editing area on the UI interface; In response to the user editing text above or below any one of the at least one picture in the editing area, the terminal device displays the text edited by the user at the position edited by the user in the editing area.
2. The method according to claim 1, characterized in that After displaying the at least one picture in the editing area of the rich text editor of the note, the method further includes: The terminal device deletes the first target picture in the editing area in response to a user's deletion operation on the first target picture in the editing area, wherein the first target picture includes one or more pictures of the at least one picture; and / or, The terminal device adjusts the position of the second target image in the editing area in response to a user's dragging operation on the second target image in the editing area.
3. The method according to claim 1 or 2, characterized in that: After displaying the at least one picture in the editing area on the UI interface, the method further includes: The terminal device prompts the user that the import of the PDF file has been completed.
4. The method according to claim 3, characterized in that The terminal device prompts the user that the import of the PDF file has been completed, including: The terminal device highlights the control for importing the file to prompt the user that the import of the PDF file has been completed.
5. The method according to claim 3, characterized in that: The terminal device prompts the user that the import of the PDF file has been completed, including: The terminal device prompts the user through text that the import of the PDF file has been completed.
6. A terminal device, characterized in that: include: processor and memory, wherein The memory is used to store computer programs; The processor is used to call and execute the computer program so that the terminal device executes the method according to any one of claims 1 to 5.
7. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed on a computer, causes the computer to execute the method according to any one of claims 1 to 5.
8. A computer program product, characterized in that The invention comprises a computer program which, when being executed, causes a computer to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
File analysis method and device and rich text editor
CN107656941A
Live streaming processing method and device and electronic equipment
CN112637623A
Rich text editing method, device and equipment
CN114548056A