Detailed Description
Fig. 1 is a flowchart of a first electronic book processing method according to an embodiment of the present invention, and as shown in fig. 1, the electronic book processing method according to the embodiment is suitable for a scenario in which a user terminal device serving as a reader obtains an electronic book from an electronic book making device and then performs a typesetting process on the electronic book locally, and at this time, the user terminal device needs to perform a typesetting process on the electronic book by combining with a screen size of the user terminal device; the method is also suitable for a scene that an e-book administrator performs typesetting processing on the e-book when the e-book administrator makes the e-book through the making equipment, and at this time, the making equipment needs to perform typesetting processing on the e-book by combining with the user terminal equipment which sends an e-book acquisition request to the making equipment or various pre-known screen size information of the terminal equipment so as to enable different terminal equipment to read and present the e-book. The electronic book processing method provided by this embodiment may be executed by a processing device, and the processing device may be integrated in an electronic book making device, or integrated in a user terminal device serving as a reader, or may be separately configured according to the difference between the two application scenarios.
The electronic book processing method provided by the embodiment comprises the following steps:
101, receiving an electronic book typesetting instruction, and acquiring screen size information of a user terminal needing to display the electronic book;
and 102, performing typesetting processing on each data element in the electronic book according to the screen size information to obtain electronic book content adaptive to the screen size of the user terminal.
In this embodiment, according to the difference between the two application scenarios, the processing device in the electronic book manufacturing apparatus may complete the electronic book typesetting process, or the processing device in the user terminal serving as the reader may complete the electronic book typesetting process obtained from the manufacturing apparatus. However, the method provided by this embodiment is particularly suitable for the production device to perform typesetting processing on the electronic book during the production process of the electronic book, and at the same time, after the reader obtains the electronic book subjected to typesetting processing, the electronic book is re-typesetted by using the same processing method as that in the production device, so as to finally present the scene of the content of the electronic book subjected to re-typesetting. That is to say, the typesetting engine which is the same as the production equipment is adopted in the user terminal as the reader to typeset the electronic book again, which is equivalent to one decoding operation, thereby being beneficial to avoiding the problem that the typesetting information is lost or wrong because the electronic book which is generally adopted in the prior art is directly presented on the reader, and being beneficial to ensuring that the layout effect in the production process is completely consistent with the final presentation effect on the reader. Since the typesetting processing methods adopted in the reader and the production device are the same, the description of the electronic book typesetting processing procedure is only performed in an alternative manner in this embodiment.
Specifically, when receiving an electronic book typesetting instruction initiated by a production side or a reading side, a processing device first needs to acquire screen size information of a user terminal displaying the electronic book, where the user terminal may be, for example, a smart phone, a tablet computer, a PC, and the like, and different user terminals have different screen sizes. After the screen size information of the user terminal is obtained, the screen size information is used as a reference basis to perform typesetting processing on various data elements in the electronic book, so that electronic book content adaptive to the screen size of the user terminal is obtained. Data elements in the electronic book are mainly divided into two types, namely paragraph character elements and non-paragraph character elements, and the non-paragraph character elements mainly include tables, pictures, formulas and the like. That is to say, the data elements in this embodiment are considered as a whole, but the data elements are not usually described in the prior art by points, lines, and planes, for example, for a table, the data elements are described in the prior art by the positions and the cross relations of the lines in the table, and this description often causes a lower processing effect and a poorer layout effect during layout. In this embodiment, each data element in the electronic book is considered as a whole, and the data elements are typeset according to the size of the screen of the user terminal, so that the electronic book is adapted to the size of the screen of the user terminal, and the typesetting efficiency is improved.
In this embodiment, the screen size information of the user terminal that needs to display the electronic book is obtained in the received electronic book typesetting instruction, so that the data elements in the electronic book can be typeset according to the screen size information, and the electronic book content that is adapted to the screen size of the user terminal is obtained, thereby overcoming the defect that the displayed content often fails to meet the requirements of the user when the electronic book is displayed on terminals of different sizes in the prior art.
Fig. 2 is a flowchart of a second embodiment of an electronic book processing method provided by the present invention, as shown in fig. 2, the method includes:
step 201, receiving an electronic book typesetting instruction sent by an electronic book administrator, and acquiring screen size information of a user terminal needing to display the electronic book from the electronic book typesetting instruction;
in this embodiment, an example is described in which a processing device receives an electronic book typesetting instruction initiated by an electronic book making device, and specifically, the processing device receives an electronic book typesetting instruction sent by an electronic book administrator, and acquires screen size information of a user terminal that needs to display an electronic book from the instruction. In practical application, a user may initiate an electronic book obtaining request to an electronic book making device through a terminal device of the user, where the request includes screen size information of the user terminal, so that an electronic book administrator can obtain the screen size information of the user terminal from the request received by the making device, and then the electronic book administrator sends an electronic book typesetting instruction carrying the screen size information of the user terminal to a processing device, so that the processing device can obtain the screen size information of the user terminal that needs to display the electronic book from the typesetting instruction. In addition, the screen size information of the user terminal may also be obtained by the manufacturing device according to statistics of various types of terminal devices in the market in advance, and in order to ensure that the manufactured electronic book can be displayed on user terminals with different screen sizes, when manufacturing the electronic book, an electronic book administrator may send an electronic book typesetting instruction carrying the screen size information of the target user terminal to the processing device, so that the processing device obtains the screen size information.
Further, step 201 may also be replaced by the following steps:
receiving an electronic book typesetting instruction sent by a user of a user terminal, and acquiring the screen size information of the user terminal from the information prestored by the user.
In this embodiment, the processing device is preset in the user terminal, and the user terminal stores the screen size information of the user terminal in advance, for example, the screen size information of the user terminal is stored in an attribute file of the user terminal. Specifically, the processing device obtains the screen size information of the user terminal from pre-stored information (such as a terminal attribute file) after receiving an electronic book typesetting instruction sent by a user.
Step 202, determining a typesetting area corresponding to the screen size information, wherein the typesetting area comprises column number and column width;
step 203, determining the typesetting format of each data element in the electronic book corresponding to the typesetting area, wherein the typesetting format is described by taking the typesetting area as a reference;
and 204, performing typesetting processing on each data element in the electronic book in the typesetting area according to the typesetting format.
In this embodiment, a layout file required for typesetting the electronic book is configured in the processing device, and the layout file specifies a processing standard to be complied with in the electronic book typesetting process. It should be noted that the composition file described in this embodiment is an extension of an existing composition file with streaming composition capability (such as the standard of a formal book format thumbnail file, the standard of an OOXML file by microsoft), in which a processing standard that uses the screen sizes of different user terminals as important constraint parameters for composition processing of an electronic book is extended. The layout file describes a rule for determining a layout area of the electronic book and a rule for determining a layout format required for layout of each data element in the electronic book. The method and the device expand on the basis of the existing streaming type-setting file without redeveloping a new type-setting file, greatly reduce the development difficulty, save the personnel cost, and have the advantages of the existing streaming type-setting file and good layout effect.
Specifically, after acquiring the screen size information of the user terminal from the received electronic book layout instruction, the processing device determines a layout area corresponding to the screen size information in the layout file, where the layout area includes the number of columns and the width of the columns. For example, if the screen size of the user terminal is a first size, only one column is in the layout area, and the column width is smaller than or equal to the first size; if the screen size of the user terminal is the second size, assuming that the second size is larger than the first size, the layout area is uniformly divided into two columns, and the column width of each column is smaller than or equal to half of the second size. In this embodiment, the layout area may include information such as a line pitch width in addition to the number of columns and the column width.
After determining the layout area corresponding to the user terminal screen size information, it is further required to determine the layout format of each data element in the electronic book corresponding to the layout area, where the layout format is described with reference to the layout area.
Specifically, if the data elements in the electronic book are paragraph text elements, determining a layout format of each data element in the electronic book corresponding to the layout area, where the layout format is described with reference to the layout area, and the method includes:
according to the column width, an insertion position for inserting a line break in the paragraph character and a head position of the paragraph character are determined, wherein the insertion position and the head position are described by taking the column width as a reference unit. In this embodiment, typesetting the elements of the paragraph characters mainly includes determining an insertion position and a segment head position of the line break, where the insertion position and the segment head position are described by using the column width as a reference unit, for example, the segment head position is located at 1/6 column width, and the line break insertion position is located at the column width. By adopting the relative description mode, the electronic book content can be displayed on different user terminals conveniently, and the consistent layout effect can be achieved.
It should be noted that, in this embodiment, in addition to determining the start position and the line break insertion position of the paragraph text, a processing rule for font size and the like may be further included, and the rule for font size and the like is similar to that in the prior art and is not described again.
After determining the layout format of each data element in the electronic book corresponding to the layout area, performing layout processing on each data element in the electronic book in the layout area according to the layout format, specifically, for a paragraph character element, the layout processing procedure includes:
positioning the head position of the segment in the current column area of the typesetting area;
inserting a line feed character at the insertion position so that the paragraph text is automatically fed when the insertion position is reached.
Further, if the data elements in the electronic book are non-paragraph character elements, determining a layout format of each data element in the electronic book corresponding to the layout region, where the layout format is described with reference to the layout region, and the method includes:
and determining the area size and the starting position occupied by the non-paragraph character elements according to the column width, wherein the area size and the starting position are described by taking the column width as a reference unit. For example, when composing a picture with a fixed size (10 cm × 10 cm) at a fixed position (3 cm,13 cm) in an electronic book, the size of the occupied area and the starting position are described in terms of the column width, for example, the size of the occupied area is 3/4 column width × 3/4 column width, and the starting position is located at coordinates (1/6 column width, 1/2 column width).
Correspondingly, performing typesetting processing on non-paragraph character elements in the electronic book in the typesetting area according to the typesetting format, wherein the typesetting processing comprises the following steps:
positioning the initial position in the current column area of the typesetting area;
and scaling the non-paragraph character elements by taking the initial position as an origin point so as to enable the area occupied by the non-paragraph character elements to be the size of the region.
In this embodiment, the typesetting format is described in any one of the following format types: script format, XML format, binary format, HTML format.
It should be noted that the above is only a process of performing adaptive typesetting processing on the paragraph file elements and the non-paragraph file elements according to the screen size information of the user terminal, and the typesetting file includes, but is not limited to, descriptions of the typesetting format of the line break insertion position, the segment head position, the non-paragraph element start position, and the occupied area size of the paragraph file elements, and may also include descriptions of other typesetting formats such as a text and picture superposition effect according to actual needs, which is not limited in this embodiment.
In addition, it should be noted that, in the process of performing the typesetting processing on the electronic book by the electronic book making device, the electronic book making device may further receive an adjustment instruction issued by an electronic book administrator to perform adjustment control on the electronic book typesetting process. For example, when the administrator finds that the layout effect of the layout is not ideal in the display interface of the manufacturing device, the layout processing procedure can be readjusted by modifying the relevant layout processing parameters in the layout file, such as the layout area, the layout format, and the appropriate terminal screen size information. Subsequently, when a certain user terminal device requests the production device to obtain an electronic book, the user terminal device needs to have a layout engine that is the same as that used in the final layout processing of the production device, that is, the user terminal device needs to obtain a layout engine that is finally used by the production device in advance, so that the obtained electronic book can be correctly analyzed and presented. That is, the user terminal device as the reader only needs to complete the process of parsing the presentation, and does not need to perform typesetting adjustment on the electronic book again.
In this embodiment, the layout area corresponding to the obtained screen size information of the user terminal is determined, and the layout format used for layout of each data element in the electronic book is described by using the layout area as a reference, so that not only can electronic book content adapted to the screen size of the user terminal be obtained, but also each data element in the electronic book can have a better layout effect in different user terminals through description of the layout format relative to the layout area.
Fig. 3 is a schematic diagram of an electronic book processing apparatus according to a first embodiment of the present invention, as shown in fig. 3, the apparatus includes:
the receiving module 11 is configured to receive an electronic book typesetting instruction, and acquire screen size information of a user terminal that needs to display the electronic book;
a processing module 12, configured to perform typesetting processing on each data element in the electronic book according to the screen size information to obtain electronic book content adapted to the screen size of the user terminal
The apparatus of this embodiment may be used to implement the technical solution of the method embodiment shown in fig. 1, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 4 is a schematic diagram of a second embodiment of an electronic book processing apparatus according to the present invention, as shown in fig. 4, based on the embodiment shown in fig. 3, the receiving module 11 is specifically configured to:
receiving an electronic book typesetting instruction sent by an electronic book administrator;
acquiring screen size information of a user terminal needing to display the electronic book from the electronic book typesetting instruction;
or,
receiving an electronic book typesetting instruction sent by a user of a user terminal;
and acquiring the screen size information of the user terminal from the information prestored by the user.
Further, the processing module 12 includes:
a first determining unit 121, configured to determine a layout area corresponding to the screen size information, where the layout area includes a column number and a column width;
a second determining unit 122, configured to determine a layout format of each data element in the electronic book corresponding to the layout region, where the layout format is described with reference to the layout region;
and the processing unit 123 is configured to perform typesetting processing on each data element in the electronic book in the typesetting area according to the typesetting format.
Further, if the data element is a paragraph character element, the second determining unit 122 is specifically configured to:
according to the column width, determining an insertion position for inserting a line feed character in the paragraph character and a head position of the paragraph character, wherein the insertion position and the head position are described by taking the column width as a reference unit;
correspondingly, the processing unit 123 is specifically configured to:
positioning the head position of the segment in the current column area of the typesetting area;
inserting a line feed character at the insertion position so that the paragraph text is automatically fed when the insertion position is reached.
If the data element is a non-paragraph text element, the second determining unit 122 is specifically configured to:
determining the area size and the starting position occupied by the non-paragraph character elements according to the column width, wherein the area size and the starting position are described by taking the column width as a reference unit;
correspondingly, the processing unit 123 is specifically configured to:
positioning the initial position in the current column area of the typesetting area;
and scaling the non-paragraph character elements by taking the initial position as an origin point so as to enable the area occupied by the non-paragraph character elements to be the size of the region.
Further, the typesetting format is described in any one of the following format types:
script format, XML format, binary format, HTML format.
The apparatus of this embodiment may be used to implement the technical solution of the method embodiment shown in fig. 2, and the implementation principle and the technical effect are similar, which are not described herein again.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.