WO2015180422A1 - Page layout method and device - Google Patents

Page layout method and device Download PDF

Info

Publication number
WO2015180422A1
WO2015180422A1 PCT/CN2014/090868 CN2014090868W WO2015180422A1 WO 2015180422 A1 WO2015180422 A1 WO 2015180422A1 CN 2014090868 W CN2014090868 W CN 2014090868W WO 2015180422 A1 WO2015180422 A1 WO 2015180422A1
Authority
WO
WIPO (PCT)
Prior art keywords
container
current page
content
page container
page
Prior art date
Application number
PCT/CN2014/090868
Other languages
French (fr)
Chinese (zh)
Inventor
蔺文龙
Original Assignee
广州市动景计算机科技有限公司
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 广州市动景计算机科技有限公司 filed Critical 广州市动景计算机科技有限公司
Publication of WO2015180422A1 publication Critical patent/WO2015180422A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/189Automatic justification

Definitions

  • the present invention relates to the field of mobile communication technologies, and in particular, to a page layout method and apparatus.
  • the traditional paging typesetting method first determines the character environment of the article, for example, the article is a Chinese environment, and secondly, the characters in the article are all regarded as Chinese. Characters, and according to the correspondence between Chinese character size and pixel, calculate the size of space each character should occupy, so as to get the number of characters that can be accommodated in each line, and the number of lines and the number of displayed pages that can accommodate each page.
  • the height of the character is equal to the height of the page, and the character fills the entire page; however, if the text includes fifty Chinese characters and fifty letters, the layout of the electronic reading terminal is as shown in the traditional page layout method. As shown in 1-2, after all the characters are inserted into the page, a blank line appears at the end of the page. Obviously, using the traditional html paging layout method, it is easy to cause blank lines at the end of some pages, resulting in low page utilization, poor display performance, and affecting the user experience.
  • the embodiment of the present invention provides a page layout method and device, which can avoid the phenomenon of blank lines at the end of the page, thereby improving the utilization of the page, optimizing the display effect, and improving the user experience.
  • an embodiment of the present invention provides a page layout method, the method comprising: determining a number of words that a terminal display area can accommodate; and placing an article according to a number of words that the terminal display area can accommodate Divided into a number of content blocks; load the content block into the corresponding content container; determine the current page a container and its corresponding content container, wherein the current page container has a blank line; insert the corresponding content container into the current page container, fill the blank line of the current page container; and immediately adjacent to the corresponding content container The next content container is inserted into the current page container; the current page container is typeset.
  • an embodiment of the present invention further provides a page layout method, the method comprising: determining a number of words that a terminal display area can accommodate; and according to the number of words that the terminal display area can accommodate, The article is divided into a number of content blocks; each content block is loaded into a corresponding content container; each content container is inserted into a corresponding page container; except for the last page container, in each page container, the next page container is inserted a content container; determining a current page container, wherein the current page container has a blank line, filling the empty line of the current page container by inserting the content container in the next page container; formatting the current page container; calculating the offset of the current page container The amount of the offset is accumulated to obtain a cumulative offset; the next page container of the current page container is used as the current page container, and the current page container is typeset according to the accumulated offset; and whether the current page container is determined Is the last container; when the current page container
  • an embodiment of the present invention further provides a page typesetting apparatus, the apparatus comprising: a first determining unit: configured to calculate a number of words that a terminal display area can accommodate; a paging unit: For dividing the article into several content blocks according to the number of words that the terminal display area can accommodate; loading unit: for loading the content block into the corresponding content container; second determining unit: for determining the current page container and its corresponding content container a first insertion unit; for inserting the corresponding content container into the page container; a second insertion unit: for inserting a next content container immediately adjacent to the corresponding content container into the current page container; Typeset the current page container.
  • an embodiment of the present invention further provides a page typesetting apparatus, the apparatus comprising: a first determining unit: configured to determine a number of words that a terminal display area can accommodate; a paging unit: For dividing the article into several content blocks according to the number of words that the terminal display area can accommodate; loading unit: for loading the content block into the corresponding content container; first inserting unit; for inserting each content container into the page container a second insertion unit: for inserting a content container in the next page container in each page container except the last page container; a second determining unit: for determining a current page container, wherein the current page container is empty Line, filling the empty line of the current page container by inserting the content container in the next page container; the first typesetting unit: for typesetting the current page container; the calculating unit: for calculating the offset of the current page container; : for accumulating the offset, obtaining a cumulative offset; the second typesetting unit: for
  • an embodiment of the present invention further provides a computer readable medium having program code executable by a processor, which, when executed, causes the processor to execute Steps: determining the number of words that the terminal display area can accommodate; dividing the article into a plurality of content blocks according to the number of words that the terminal display area can accommodate; loading the plurality of content blocks into the corresponding content container; determining the current page container and Corresponding content container, wherein the current page container has a blank line; inserting the corresponding content container into the page container, filling a blank line of the current page container; next to the next content container The content container is inserted into the current page container; the current page container is typeset.
  • an embodiment of the present invention further provides a computer readable medium having program code executable by a processor, which, when executed, causes the processor to execute Steps: determining the number of words that the terminal display area can accommodate; dividing the article into a plurality of content blocks according to the number of words that the terminal display area can accommodate; loading each of the plurality of content blocks into the corresponding content container; Inserting each content container into a corresponding page container; in addition to the last page container, inserting a content container in the next page container in each page container; determining a current page container, wherein the current page container is empty Row, filling the empty line of the current page container by inserting the content container in the next page container; typesetting the current page container; calculating the offset of the current page container; accumulating the offset to obtain the cumulative offset ; the next page container of the current page container is used as the current page container, according to the cumulative offset pair
  • the front page container performs typesetting; determines whether
  • an embodiment of the present invention provides a computer program for executing a page layout method according to an embodiment of the present invention.
  • the page layout method and device divides the content blocks obtained by the articles into pages and loads the content blocks into the corresponding content containers. After determining the current page container and its corresponding content container, the content container is inserted into the page container. Since there is a blank line in the tail portion of the current page container, except for the last page container, the blank line of the current page container is filled by inserting the next content container immediately adjacent to the corresponding content container into the current page container. Compared with the prior art, when there is a blank line in the page after paging, the blank line can be filled, thereby avoiding the phenomenon of blank lines at the end of the page, improving the utilization of the page, and further optimizing the display effect and improving the user experience. .
  • 1-1 is a schematic diagram showing the first display effect of the electronic reading terminal provided by the present invention.
  • 1-2 is a schematic diagram showing a second display effect of the electronic reading terminal provided by the present invention.
  • FIG. 2 is a flowchart of a first implementation method of a page layout method according to an embodiment of the present invention
  • FIG. 3 is a flowchart of a second implementation method of a page layout method according to an embodiment of the present invention.
  • FIG. 4 is a flowchart of a third implementation method of a page layout method according to an embodiment of the present invention.
  • 5-1 is a schematic diagram of displaying a content container into a page container in an example provided by an embodiment of the present invention
  • FIG. 5-2 is a schematic diagram of displaying an empty line of each page container in an example provided by an embodiment of the present invention.
  • 5-3 is a schematic diagram showing display after content offset in a page container in an example provided by an embodiment of the present invention.
  • FIG. 6 is a schematic structural diagram of a first implementation manner of a page typesetting apparatus according to an embodiment of the present disclosure
  • FIG. 7 is a schematic structural diagram of a second implementation manner of a page typesetting apparatus according to an embodiment of the present invention.
  • the page layout method includes the following steps:
  • Step S101 Determine the number of words that the terminal display area can accommodate.
  • the manner of determining the number of words that can be accommodated is different. Therefore, when an article is acquired, first, the character type of the article is determined, and the character type of the article is usually capable of being known from the article. Get it directly. After getting the character type of the article, the width of the character is calculated according to the determined character type. Specifically, when the character type of the article is Chinese, the width of each character may be determined according to the correspondence between the font size and the pixel of the character, or determined according to the empirical value, and the present invention does not limit this; when the article is an English character Calculate the average width of English characters.
  • the average width can be determined by calculating the average width value of 26 letters, or calculating the average value of the letter I with the smallest width and the letter W with the largest width. The average width of the letters. After determining the width of each character, the number of words that can be accommodated in each row is determined according to the width of the display area of the terminal, and then the number of lines that can be accommodated is determined according to the height of the display area of the terminal, thereby obtaining the number of words that the terminal display area can accommodate.
  • the manner in which the number of words that can be received by the display area of the terminal is determined is not limited to the foregoing description, and may be other determined manners, which are not described herein again.
  • the character width is determined, and then the number of words that can be accommodated is calculated according to the character width, and can be applied to any language without using any language, and the application range is wide.
  • Step S102 The article is divided into a plurality of content blocks according to the number of words that the terminal display area can accommodate.
  • the number of words that the terminal display area can accommodate that is, the number of words per page, divides the content of the article into a plurality of content blocks according to the number of words per page and the total number of words of the article, and each content block is displayed for each page.
  • Content For example, a 1000-word article, each page can hold 100 words, and each 100 words is a content block, and the article can be divided into 10 content blocks.
  • Step S103 Loading the content block into the corresponding content container.
  • a content block is correspondingly loaded in a content container, and a content tag is added to the content block in order to facilitate management of the content block.
  • the content tag includes a start tag and a closing tag.
  • the start tag is usually located before the first character of the content block to indicate the start of the content block; the end tag is located after the last character of the content block to indicate the end of the content block. .
  • the start tag and the end tag of each content block wrap the content block to form a content container corresponding to the content block.
  • the content tag may be any known or upcoming identifier capable of identifying the content of the document, which is not limited by the present invention.
  • the content tag may be a DOM (Document Object Model) node, and each 100 characters are marked by a DOM node starting from the first character.
  • the 100-character content container is formed for the starting DOM node and the ending DOM node of every 100 characters.
  • the content block is containerized to form a unified management of characters, which facilitates processing of the content, and the processing steps can be saved with respect to the character processing, and the algorithm is simple.
  • Step S104 Determine the current page container and its corresponding content container.
  • the current page container may be the first page container, and then the content container corresponding to the current page container is the first content container.
  • Step S105 Insert the corresponding content container into the page container.
  • the characters in the content container can realize natural typesetting such as line feed and stretch alignment.
  • the page container can simulate the terminal display area and display the content block in the content container.
  • the 'current page container' is the first page container
  • the content block in the first content container can be visually seen in the terminal. Shows the impression in the area.
  • the natural typesetting of the content blocks in the content container can be performed by CSS (Cascading Style Sheets) style control characters, and the natural typesetting of the characters is a technical means well known to those skilled in the art, and the present invention is here. No longer.
  • the method may further include: determining whether there is a blank line at the end of the current page container, and when the current page container has a blank line at the end of the page, filling the current page container by performing step S106 A blank line at the end of the page; when there is no blank line at the end of the 'current page container', step S107 is performed on the current page container.
  • the specific method for determining whether there is a blank line at the end of the current page container may be: determining the corresponding content container and Whether the height of the current page container is equal.
  • the current page container When the corresponding content container is equal to the height of the current page container, there is no blank line at the end of the current page container; when the height of the corresponding content container and the current page container are not equal, the current page container is There is a blank line at the end of the page.
  • the method for judging whether there is a blank line at the end of the current page container may be other methods, and the present invention is not limited herein.
  • Step S106 Insert the next content container immediately adjacent to the corresponding content container into the current page container.
  • the next content container before inserting the next content container, first determining the end tag of the current content container, according to which the next content container of the content container is inserted; preferably, the next line of the end tag may be adjacent
  • the starting position is inserted as the starting position of the next content container, and the starting label of the next content container is inserted into the position. Due to the container nature of the content container, when the next content container is inserted into the current page container, the first line in the next content container is displayed in the first line of the hollow line of the current page container.
  • the characters of the last line can be divided into the next content container.
  • the present invention will not be described in detail for the specific division method.
  • Step S107 Typesetting the current page container.
  • the layout of the current page container has been completed. Since the content displayed by the current page container is partially overlapped with the content displayed by the next next page container, the offset of the repeated portion needs to be calculated so as to typeset the next page container according to the offset.
  • the page layout method provided by the embodiment of the present invention divides a plurality of content blocks obtained by the article and loads the content block into the corresponding content container. After determining the current page container and its corresponding content container, the content container is inserted into the page container. Since there is a blank line in the tail portion of the current page container, except for the last page container, the blank line of the current page container is filled by inserting the next content container immediately adjacent to the corresponding content container into the current page container. Compared with the prior art, when there is a blank line in the page after paging, the blank line can be filled, thereby avoiding the phenomenon of blank lines at the end of the page, improving the utilization of the page, and further optimizing the display effect and improving the user experience. .
  • this figure shows a flow chart of a second implementation method of a page layout method according to an embodiment of the present invention.
  • This embodiment is an extension of the first embodiment.
  • the content of the method is not described in detail in the embodiment.
  • the method includes the following steps:
  • Step S201 Determine the number of words that the terminal display area can accommodate.
  • the article contains 1000 characters and the terminal display area can hold 100 words.
  • Step S202 The article is divided into a plurality of content blocks according to the number of words that the terminal display area can accommodate.
  • Step S203 Loading the content block into the corresponding content container.
  • Step S204 Determine the current page container and its corresponding content container.
  • the first page container corresponds to the first content container; the second page container corresponds to the second content container; and the third page container corresponds to the third content container, This type of push.
  • the content of the end portion of the first content container is concatenated with the content of the beginning portion of the second content container; the content of the end portion of the second content container is concatenated with the content of the beginning portion of the third content container; Step backwards.
  • Step S205 Insert the content container into the page container.
  • Step S206 Insert the next content container immediately adjacent to the content container into the current page container.
  • the third content container is inserted into the second page container to fill Two blank lines of the second page container.
  • the second page container only the content of the first line of the third content container can be displayed, and other parts cannot be displayed.
  • Step S207 Calculate the offset of the current page container.
  • the first two lines of content in the first content container are displayed in both the first page container and the second page container, causing repeated display, not only wasting the page. Resources, and affect the user's experience. Therefore, in order to remove the portion of the repeated display, it is necessary to adjust the display area of the second content container in the second page container.
  • the height difference between the first page container and the first content container is obtained by calculation, and the offset of the first page container is obtained, and the second page container is used according to the offset. Adjust the content container.
  • there is also a blank line in the second page container so the offset of the second page container needs to be calculated in order to typeset the subsequent page container.
  • Step S208 Accumulating the offset amount to obtain a cumulative offset.
  • the third page container needs to be the third.
  • Content container Offset two lines upwards.
  • the second page container itself already has two blank lines, so the third content container repeats in the second page container, the offset of the first page container and the second page container.
  • the accumulation of shifts Therefore, it is necessary to accumulate all the previously obtained offsets to obtain a cumulative offset so as to process the subsequent page containers according to the accumulated offset.
  • Step S209 The next page container of the current page container is used as the current page container, and the display content of the content container in the current page container is adjusted according to the accumulated offset.
  • the adjusting the content of the content container in the third page container according to the offset includes: determining whether the accumulated offset is smaller than the height of the third content container; and when the cumulative offset is less than the height of the third content container In the third content container, only part of the content is displayed in the second page container, and other parts need to be displayed in the third page container, so the third content container in the third page container Offward shifts the portion of the third content container that is repeatedly displayed with the second page container out of the visible area while shifting the fourth content container in the third page container up by the same amount.
  • the cumulative offset is greater than or equal to the height of the third content container, the content of the third content container is all displayed in the second content container, thus deleting the third page container.
  • the layout of the article ends.
  • the page container is removed on the basis of filling the blank area of each page container.
  • the repeated display between the parts not only makes full use of the page resources, but also improves the user experience.
  • FIG. 4 a flow chart of a third implementation method of a page layout method according to an embodiment of the present invention is shown.
  • This embodiment transforms the execution order of the above two embodiments to form the execution mode of the embodiment.
  • the content of the implementation of this embodiment is similar to that of the foregoing embodiment.
  • the method includes the following steps:
  • Step S301 Determine the number of words that the terminal display area can accommodate.
  • Step S302 The article is divided into a plurality of content blocks according to the number of words that the terminal display area can accommodate.
  • Step S303 Load each content block into a corresponding content container.
  • Step S304 Insert each content container into a corresponding page container.
  • Step S305 In addition to the last page container, in each page container, the content container in the next page container is inserted.
  • the last page container is removed, and the blank of each page container may be filled first; or, when the corresponding content container is inserted into the current page container, The next content container of the content container is inserted into the current page container.
  • Step S306 Determine the current page container.
  • Step S307 Typesetting the current page container.
  • the current page container is the first page container
  • the current page container has been formatted, and the offset is determined by calculating the height difference between the current page container and the first content container; when the 'current page container' is not the first page container
  • calculate the height difference between the current page container and its corresponding content container and then, according to the previously calculated offset, offset the content container in the current page container upward, and complete the current content container.
  • Step S308 Calculate the offset of the current page container.
  • Step S309 Accumulating the offset to obtain a cumulative offset
  • Step S310 The next page container of the current page container is used as the current page container, and the current page container is typeset according to the accumulated offset.
  • Step S311 determining whether the current page container is the last container, if not, executing step S308; when yes, executing step S312.
  • the offset needs to be calculated in order to obtain The offset is accumulated, and the subsequent page container is typeset according to the accumulated offset; when the 'current page container' is the last page container, all the page containers have completed the typesetting, and the operation ends.
  • a plurality of content blocks obtained by paging the articles are loaded, and the content blocks are loaded into the corresponding content containers.
  • the content container is inserted into the page container. Since there is a blank line in the tail portion of the current page container, except for the last page container, the blank line of the current page container is filled by inserting the next content container immediately adjacent to the corresponding content container into the current page container.
  • the blank line can be filled. Therefore, the phenomenon of blank lines at the end of the page can be avoided, the utilization of the page can be improved, and the display effect can be further optimized to improve the user experience.
  • a Chinese article including 1000 characters is taken as an example.
  • the electronic reading terminal is a mobile phone
  • the height and width parameters of the display interface are known, and the font size when the character is displayed is known.
  • the width of each character is calculated according to the relationship between the character size and the pixel; then, according to the width of the display interface of the mobile phone, the number of characters that can be accommodated in each line is calculated.
  • each line can accommodate 10 characters; finally, the number of lines that can be accommodated per page is calculated according to the height parameter of the display interface of the mobile phone.
  • 10 lines can be accommodated, thereby determining that in the present embodiment, each page can accommodate 100 characters. 1000 characters can be divided into 10 pages.
  • a DOM node is inserted for every 100 characters, and the content of each page is represented by a DOM node. Specifically, a start node is added before the first character, and an end node is added after the first hundred characters, and the same operation is performed for every 100 characters in the following.
  • every 100 characters can be regarded as a content block, and the DOM node can be regarded as a content container of a package content block.
  • 10 content containers are included.
  • 10 page containers are created, and each content container corresponds to one page container.
  • the size of the display area of the page container is set according to the size of the display screen of the mobile phone.
  • the content container is sequentially inserted into its corresponding page container, as shown in FIG. 5-1, which shows a schematic view of the content container 51 being inserted into the page container 52.
  • Each content container is inserted into the display area of the page container in the order of the content blocks, wherein the contents of the content blocks in any two adjacent page containers are connected to each other.
  • the content block in the content container 51 controls the layout of the characters according to the CSS style, forming a natural typesetting in which the end of each line is aligned. Since there are half-width punctuation marks or English letters in the content of the article, after the content block is naturally typeset, a blank line appears at the end of the page container 52.
  • any page container other than the last page container is used as the current page container, and the content container in the next page container of the current page container is inserted into the current page container.
  • the page container is displayed after the page container is blank.
  • Each of the page containers includes two content containers, and the first inserted content container 53 is all displayed, and the post-inserted content container 54 is displayed only in the blank portion of the page container 52, and other portions are not visible.
  • the page container is already filled, that is, the layout of the first page container has been completed; if the current page container is not the first page container, due to the current page container
  • the content displayed by the previous page container contains the same content as the content displayed by the current page container. Therefore, in order to improve the utilization of the page, the same part of the current page container as the previous page container should be removed.
  • Figure 5-3 shows the display after the content of the page container is offset.
  • the repeated portion inserted into the content container 52 is moved from the visible area of the page container 52 to the invisible area, so that the content displayed by the current page container header is compared with the previous page.
  • the content displayed at the end of the container is connected. It should be noted that, in order to ensure the consistency of the content displayed by the current page container, when the content container 52 is first shifted upward, the post-insertion content container 53 is also offset upward by the same amount, and thus the layout of the current page container is completed. .
  • the height difference between the visible area of the first page container and the content container inserted first is calculated, and the height difference is the first page container needs.
  • the filled blank area, the content displayed in the blank area is the height of the duplicate content in the current page container, so the height difference is determined as the offset of the content container in the current page container;
  • the 'current page container' is When the Nth (N is a natural number greater than 2) page containers, the height difference of the first N-1 page containers is obtained, and the N-1 height differences are accumulated to obtain the offset of the current page container.
  • the offset of the current page container is the sum of the difference between the height difference of the first page container and the height difference of the second page container, and the calculation of the offset of the other page containers is the same as the above, and the present invention I will not repeat them here.
  • the offset is smaller than the height of the content container inserted first in the current page container. If it is smaller, the content inserted in the content container is displayed in the previous page container. The rest of the content is displayed in the current page container, so the content container in the current page is adjusted according to the offset; if the offset is greater than or equal to the height of the content container first inserted, it means that all the content in the content container is inserted first.
  • the previous page container is populated, that is, its entire content is displayed in the previous page container, so the current page container is directly deleted.
  • a plurality of content blocks obtained by paging the articles are obtained, and the content blocks are loaded into the corresponding content containers.
  • the corresponding content container is inserted into the page container. Since there is a blank line in the footer portion of the current page container, the blank line of the page container is filled by inserting the next content container immediately adjacent to the corresponding content container into the current page container.
  • the blank line can be filled, thereby avoiding the phenomenon of blank lines at the end of the page, improving the utilization of the page, and further optimizing the display effect and improving the user experience.
  • the embodiment of the present invention further provides a page layout device, as shown in FIG. 6 , which is a schematic structural diagram of a first implementation manner of a page layout device according to an embodiment of the present invention.
  • the device includes: a first determining unit 11, a paging unit 12, a loading unit 13, a second determining unit 14, a first inserting unit 15, a second inserting unit 16, and a typesetting unit 17, wherein the first determining unit 11
  • the paging unit 12 is configured to divide the article into a plurality of content blocks according to the number of words that the terminal display area can accommodate;
  • the loading unit 13 is configured to load the content block into the corresponding content container; a determining unit 14 for determining a current page container and its corresponding content container; a first inserting unit 15 for inserting a corresponding content container into the page container; and a second inserting unit 16 for placing the next right next to the corresponding content container A content container is inserted into
  • the device further includes a determining unit, configured to determine whether the height of the corresponding content container and the current page container are equal; the second inserting unit 16 is further used to When the height of the corresponding content container and the current page container are not equal, the next content container adjacent to the corresponding content container is inserted into the current page container; the typesetting unit 17 is further configured to: when the corresponding content container and the current page When the heights of the containers are equal, the current page container is typeset.
  • the apparatus further includes: a calculating unit, an accumulating unit, and an adjusting unit, wherein the calculating unit is configured to calculate an offset of the current page container; Yu The offset is accumulated to obtain a cumulative offset; the adjusting unit is configured to use the next page container of the current page container as the current page container, and adjust the display content of the content container in the current page container according to the accumulated offset.
  • the adjusting unit includes: a determining module, an offset module and a deleting module, and a determining module, configured to determine whether the accumulated offset is smaller than a height of a content container corresponding to the current page container; and the offset module is configured to: when the accumulated offset is smaller than When the height of the content container corresponding to the current page container is up, the content container in the page container is offset upward according to the accumulated offset; and the deleting module is configured to when the accumulated offset is greater than or equal to the height of the content container corresponding to the current page container. , delete the current page container.
  • the second determining unit 14 includes: an obtaining module, a determining module, and a calculating module, wherein the acquiring module is configured to obtain a font size of the character when the article is a double-byte character; or, when the article is a single-byte character, obtain the letter The average width; the determining module is configured to determine the width of the character according to the correspondence between the font size and the pixel when the article is a double-byte character; and the calculation module is configured to calculate the capacity according to the width when the article is a double-byte character The number of words; or, when the article is a single-byte character, the number of letters that can be accommodated is calculated by the average width.
  • the page typesetting apparatus divides a plurality of content blocks obtained by the article and loads the content block into the corresponding content container. After determining the current page container and its corresponding content container, the corresponding content container is inserted into the page container. Since there is a blank line in the footer portion of the current page container, the blank line of the page container is filled by inserting the next content container immediately adjacent to the corresponding content container into the current page container. Compared with the prior art, when there is a blank line in the page after paging, the blank line can be filled, thereby avoiding the phenomenon of blank lines at the end of the page, improving the utilization of the page, and further optimizing the display effect and improving the user experience. .
  • FIG. 7 is a schematic structural diagram of a second implementation manner of a page layout apparatus according to an embodiment of the present invention.
  • the apparatus includes: a first determining unit 20, a paging unit 21, a loading unit 22, a first inserting unit 23, a second inserting unit 24, a second determining unit 25, a first typesetting unit 26, a calculating unit 27, and an accumulating unit 28.
  • the second typesetting unit, 29, is configured to use the next page container of the current page container as the current page container, and typeset the current page container according to the accumulated offset; the determining unit 30 is configured to determine whether the current page container is the last
  • the page layout method and apparatus divides a plurality of content blocks obtained by the article and loads the content block into the corresponding content container. After determining the current page container and its corresponding content container, the corresponding content container is inserted into the page container. Since there is a blank line in the footer portion of the current page container, the blank line of the page container is filled by inserting the next content container immediately adjacent to the corresponding content container into the current page container. Compared with the prior art, when there is a blank line in the page after paging, the blank line can be filled, thereby avoiding the phenomenon of blank lines at the end of the page, improving the utilization of the page, and further optimizing the display effect and improving the user experience. .
  • the present invention is applicable to a wide variety of general purpose or special purpose computing system environments or configurations.
  • the invention may be described in the general context of computer-executable instructions executed by a computer, such as a program module.
  • program modules include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types.
  • the invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are connected through a communication network.
  • program modules can be located in both local and remote computer storage media including storage devices.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Document Processing Apparatus (AREA)
  • Processing Or Creating Images (AREA)

Abstract

Disclosed is a page layout method, comprising: determining the number of words that can be covered in a terminal display area; dividing a text into several content blocks according to the number of words that can be covered in the terminal display area; loading the content blocks into corresponding content containers; determining a current page container and the corresponding content container thereof; inserting the corresponding content container into the page container; inserting the next content container neighboring to the corresponding content container into the current page container; and implementing layout of the current page container. Also provided is a page layout device. By means of the provided page layout method and device, compared with the prior art, when a blank line exists in a page after pagination, the blank line can be filled, which prevents a blank line from appearing at the end of a page, improves the utilization rate of the page, further optimizes the display effect, and improves the user experience.

Description

页面排版方法及装置Page layout method and device 技术领域Technical field
本发明涉及移动通信技术领域,更具体而言,涉及一种页面排版方法及装置。The present invention relates to the field of mobile communication technologies, and in particular, to a page layout method and apparatus.
背景技术Background technique
随着互联网技术的发展和智能终端的普及,人们在阅读时不再局限于传统的纸质出版物,而是更加偏爱便于携带的电子阅读终端,比如手机、平板电脑等,这样更加方便人们利用日常生活的时间碎片使用电子阅读终端更加方便的进行阅读。With the development of Internet technology and the popularity of smart terminals, people are no longer limited to traditional paper publications when reading, but prefer electronic portable terminals that are easy to carry, such as mobile phones and tablet computers. Time fragments of everyday life are more easily read using an electronic reading terminal.
针对电子阅读终端的超文本标记语言(Hypertext Markup Language,以下简称为html)页面,传统分页排版方法首先,确定文章的字符环境,例如文章为中文环境,其次,将文章中的字符全部视为中文字符,并按照中文字符字号与像素的对应关系,计算每个字符应当占据的空间大小,从而得到每行可以容纳的字符数量,及每页可以容纳字符的行数及显示页数。For the Hypertext Markup Language (hereinafter referred to as html) page of the electronic reading terminal, the traditional paging typesetting method first determines the character environment of the article, for example, the article is a Chinese environment, and secondly, the characters in the article are all regarded as Chinese. Characters, and according to the correspondence between Chinese character size and pixel, calculate the size of space each character should occupy, so as to get the number of characters that can be accommodated in each line, and the number of lines and the number of displayed pages that can accommodate each page.
然而,在html页面中,无论是单字节字符语言还是双字节字符语言,都存在字符不等宽的现象。例如,中文环境中半角标点符号或者英文字母的宽度为中文字符宽度的一半;而英文环境中,字母与字母本身就不等宽。以中文环境为例,若电子阅读终端能够展示100个中文字符,当一段文字包含100个中文字符时,按照传统的分页排版方法排版后,电子阅读终端的展示效果如图1-1所示,字符的高度与页面的高度相等,字符填满整个页面;然而,若这段文字中包括五十个中文字符和五十个字母时,按照传统的页面排版方法排版,电子阅读终端展示效果如图1-2所示,字符全部插入页面后,页尾部分就会出现空行。很明显,使用传统的html分页排版方法,极易导致部分页面页尾出现空行,从而造成页面利用率低,展示效果不好,影响用户体验。However, in html pages, whether it is a single-byte character language or a double-byte character language, there are phenomena in which characters are not unequal. For example, the width of a half-width punctuation mark or English letter in a Chinese environment is half the width of a Chinese character; in an English environment, letters and letters themselves are not equal in width. Taking the Chinese environment as an example, if the electronic reading terminal can display 100 Chinese characters, when a paragraph of text contains 100 Chinese characters, according to the traditional paging typesetting method, the display effect of the electronic reading terminal is shown in Figure 1-1. The height of the character is equal to the height of the page, and the character fills the entire page; however, if the text includes fifty Chinese characters and fifty letters, the layout of the electronic reading terminal is as shown in the traditional page layout method. As shown in 1-2, after all the characters are inserted into the page, a blank line appears at the end of the page. Obviously, using the traditional html paging layout method, it is easy to cause blank lines at the end of some pages, resulting in low page utilization, poor display performance, and affecting the user experience.
发明内容Summary of the invention
有鉴于此,本发明实施例提供一种页面排版方法及装置,能够避免页尾出现空行的现象,从而能够提高页面的利用率,优化展示效果,提高用户体验。In view of this, the embodiment of the present invention provides a page layout method and device, which can avoid the phenomenon of blank lines at the end of the page, thereby improving the utilization of the page, optimizing the display effect, and improving the user experience.
为了实现上述目的,根据本发明的第一方面,本发明实施例提供了一种页面排版方法,所述方法包括:确定终端显示区域可以容纳的字数;根据终端显示区域可以容纳的字数,将文章分成若干内容块;将内容块加载到对应的内容容器;确定当前页面 容器及其对应的内容容器,其中,所述当前页面容器存在空行;将所述对应内容容器插入到当前页面容器中,填充所述当前页面容器的空行;将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器;对当前页面容器进行排版。In order to achieve the above object, according to a first aspect of the present invention, an embodiment of the present invention provides a page layout method, the method comprising: determining a number of words that a terminal display area can accommodate; and placing an article according to a number of words that the terminal display area can accommodate Divided into a number of content blocks; load the content block into the corresponding content container; determine the current page a container and its corresponding content container, wherein the current page container has a blank line; insert the corresponding content container into the current page container, fill the blank line of the current page container; and immediately adjacent to the corresponding content container The next content container is inserted into the current page container; the current page container is typeset.
为了实现上述目的,根据本发明的第二方面,本发明实施例还提供了一种页面排版方法,所述方法包括:确定终端显示区域可以容纳的字数;根据终端显示区域可以容纳的字数,将文章分成若干内容块;将每个内容块加载到对应的内容容器;将每个内容容器插入到对应的页面容器中;除最后一个页面容器,在每个页面容器中,插入下一个页面容器中的内容容器;确定当前页面容器,其中,当前页面容器存在空行,通过插入下一个页面容器中的内容容器填充当前页面容器的空行;对当前页面容器进行排版;计算当前页面容器的偏移量;累计所述偏移量,得到累计偏移量;将当前页面容器的下一个页面容器作为当前页面容器,根据所述累计偏移量对当前页面容器进行排版;判断所述当前页面容器是否为最后一个容器;当所述当前页面容器并非最后一个页面容器,重复执行计算当前页面容器的偏移量的操作;当所述当前页面容器是最后一个页面容器,不执行任何操作。In order to achieve the above object, according to a second aspect of the present invention, an embodiment of the present invention further provides a page layout method, the method comprising: determining a number of words that a terminal display area can accommodate; and according to the number of words that the terminal display area can accommodate, The article is divided into a number of content blocks; each content block is loaded into a corresponding content container; each content container is inserted into a corresponding page container; except for the last page container, in each page container, the next page container is inserted a content container; determining a current page container, wherein the current page container has a blank line, filling the empty line of the current page container by inserting the content container in the next page container; formatting the current page container; calculating the offset of the current page container The amount of the offset is accumulated to obtain a cumulative offset; the next page container of the current page container is used as the current page container, and the current page container is typeset according to the accumulated offset; and whether the current page container is determined Is the last container; when the current page container is not the last one Surface of the container, is repeatedly performed to calculate the current offset of the page operation the container; container when the current page is the last page of a container, does not perform any operation.
为了实现上述目的,根据本发明的第三方面,本发明实施例还提供了一种页面排版装置,所述装置包括:第一确定单元:用于计算终端显示区域可以容纳的字数;分页单元:用于根据终端显示区域可以容纳的字数,将文章分成若干内容块;加载单元:用于将内容块加载到对应的内容容器;第二确定单元:用于确定当前页面容器及其对应的内容容器;第一插入单元;用于将所述对应内容容器插入到页面容器中;第二插入单元:用于将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器;排版单元:用于对当前页面容器进行排版。In order to achieve the above object, according to a third aspect of the present invention, an embodiment of the present invention further provides a page typesetting apparatus, the apparatus comprising: a first determining unit: configured to calculate a number of words that a terminal display area can accommodate; a paging unit: For dividing the article into several content blocks according to the number of words that the terminal display area can accommodate; loading unit: for loading the content block into the corresponding content container; second determining unit: for determining the current page container and its corresponding content container a first insertion unit; for inserting the corresponding content container into the page container; a second insertion unit: for inserting a next content container immediately adjacent to the corresponding content container into the current page container; Typeset the current page container.
为了实现上述目的,根据本发明的第四方面,本发明实施例还提供了一种页面排版装置,所述装置包括:第一确定单元:用于确定终端显示区域可以容纳的字数;分页单元:用于根据终端显示区域可以容纳的字数,将文章分成若干内容块;加载单元:用于将内容块加载到对应的内容容器;第一插入单元;用于将每个内容容器插入到页面容器中;第二插入单元:用于除最后一个页面容器,在每个页面容器中,插入下一个页面容器中的内容容器;第二确定单元:用于确定当前页面容器,其中,当前页面容器存在空行,通过插入下一个页面容器中的内容容器填充当前页面容器的空行;第一排版单元:用于对当前页面容器进行排版;计算单元:用于计算当前页面容器的偏移量;累计单元:用于累计所述偏移量,得到累计偏移量;第二排版单元:用于将当前页面容器的下一个页面容器作为当前页面容器,根据所述累计偏移量对当前页面容器进行排版;判断单元:用于判断所述当前页面容器是否为最后一个容器;当所述当 前页面容器并非最后一个页面容器,所述计算单元,还用于计算当前页面容器的偏移量。In order to achieve the above object, in accordance with a fourth aspect of the present invention, an embodiment of the present invention further provides a page typesetting apparatus, the apparatus comprising: a first determining unit: configured to determine a number of words that a terminal display area can accommodate; a paging unit: For dividing the article into several content blocks according to the number of words that the terminal display area can accommodate; loading unit: for loading the content block into the corresponding content container; first inserting unit; for inserting each content container into the page container a second insertion unit: for inserting a content container in the next page container in each page container except the last page container; a second determining unit: for determining a current page container, wherein the current page container is empty Line, filling the empty line of the current page container by inserting the content container in the next page container; the first typesetting unit: for typesetting the current page container; the calculating unit: for calculating the offset of the current page container; : for accumulating the offset, obtaining a cumulative offset; the second typesetting unit: for using the current A lower surface of the container of the current page as a page container vessel, the vessel current page typeset according to the accumulated amount of offset; determining means: determines for the current page is the last vessel container; when the when The front page container is not the last page container, and the calculation unit is also used to calculate the offset of the current page container.
为了实现上述目的,根据本发明的第五方面,本发明实施例还提供了一种具有处理器可执行的程序代码的计算机可读介质,在被执行时,所述程序代码使得处理器执行下述步骤:确定终端显示区域可以容纳的字数;根据所述终端显示区域可以容纳的字数,将文章分成多个内容块;将所述多个内容块加载到对应的内容容器;确定当前页面容器及其对应内容容器,其中,所述当前页面容器存在空行;将所述对应内容容器插入到所述页面容器中,填充所述当前页面容器的空行;将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器;对当前页面容器进行排版。In order to achieve the above object, in accordance with a fifth aspect of the present invention, an embodiment of the present invention further provides a computer readable medium having program code executable by a processor, which, when executed, causes the processor to execute Steps: determining the number of words that the terminal display area can accommodate; dividing the article into a plurality of content blocks according to the number of words that the terminal display area can accommodate; loading the plurality of content blocks into the corresponding content container; determining the current page container and Corresponding content container, wherein the current page container has a blank line; inserting the corresponding content container into the page container, filling a blank line of the current page container; next to the next content container The content container is inserted into the current page container; the current page container is typeset.
为了实现上述目的,根据本发明的第六方面,本发明实施例还提供了一种具有处理器可执行的程序代码的计算机可读介质,在被执行时,所述程序代码使得处理器执行下述步骤:确定终端显示区域可以容纳的字数;根据所述终端显示区域可以容纳的字数将文章分成多个内容块;将所述多个内容块中的每个内容块加载到对应的内容容器;将每个内容容器插入到对应的页面容器中;除最后一个页面容器,在每个页面容器中,插入下一个页面容器中的内容容器;确定当前页面容器,其中,所述当前页面容器存在空行,通过插入下一个页面容器中的内容容器填充所述当前页面容器的空行;对当前页面容器进行排版;计算当前页面容器的偏移量;累计所述偏移量,得到累计偏移量;将当前页面容器的下一个页面容器作为当前页面容器,根据所述累计偏移量对当前页面容器进行排版;判断所述当前页面容器是否为最后一个容器;当所述当前页面容器并非最后一个页面容器时,重复执行计算当前页面容器的偏移量的操作;当所述当前页面容器是最后一个页面容器时,不执行任何操作。In order to achieve the above object, in accordance with a sixth aspect of the present invention, an embodiment of the present invention further provides a computer readable medium having program code executable by a processor, which, when executed, causes the processor to execute Steps: determining the number of words that the terminal display area can accommodate; dividing the article into a plurality of content blocks according to the number of words that the terminal display area can accommodate; loading each of the plurality of content blocks into the corresponding content container; Inserting each content container into a corresponding page container; in addition to the last page container, inserting a content container in the next page container in each page container; determining a current page container, wherein the current page container is empty Row, filling the empty line of the current page container by inserting the content container in the next page container; typesetting the current page container; calculating the offset of the current page container; accumulating the offset to obtain the cumulative offset ; the next page container of the current page container is used as the current page container, according to the cumulative offset pair The front page container performs typesetting; determines whether the current page container is the last container; when the current page container is not the last page container, repeatedly performs an operation of calculating an offset of the current page container; when the current page container When it is the last page container, no action is taken.
为了实现上述目的,根据本发明的第六方面,本发明实施例还提供了一种计算机程序,该计算机程序用于执行本发明实施例所述的页面排版方法。In order to achieve the above object, in accordance with a sixth aspect of the present invention, an embodiment of the present invention provides a computer program for executing a page layout method according to an embodiment of the present invention.
由以上技术方案可知,本发明实施例所提供的页面排版方法及装置,将文章分页得到的若干内容块,并将内容块加载到对应的内容容器中。在确定当前页面容器及其对应的内容容器后,将所述内容容器插入到页面容器中。由于当前页面容器页尾部分存在空行,除最后一个页面容器,通过将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器,填充当前页面容器的空行。与现有技术相比,当分页后页面中存在空行时,能够将空行进行填补,从而能够避免页尾出现空行的现象,提高页面的利用率,进一步能够优化展示效果,提高用户体验。 It can be seen from the above technical solution that the page layout method and device provided by the embodiment of the present invention divides the content blocks obtained by the articles into pages and loads the content blocks into the corresponding content containers. After determining the current page container and its corresponding content container, the content container is inserted into the page container. Since there is a blank line in the tail portion of the current page container, except for the last page container, the blank line of the current page container is filled by inserting the next content container immediately adjacent to the corresponding content container into the current page container. Compared with the prior art, when there is a blank line in the page after paging, the blank line can be filled, thereby avoiding the phenomenon of blank lines at the end of the page, improving the utilization of the page, and further optimizing the display effect and improving the user experience. .
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。通过附图所示,本发明的上述及其它目的、特征和优势将更加清晰。在全部附图中相同的附图标记指示相同的部分。并未刻意按实际尺寸等比例缩放绘制附图,重点在于示出本发明的主旨。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings to be used in the embodiments will be briefly described below. Obviously, the drawings in the following description are only some of the present invention. For the embodiments, those skilled in the art can obtain other drawings according to the drawings without any creative work. The above and other objects, features and advantages of the present invention will become apparent from the accompanying drawings. The same reference numerals are used throughout the drawings to refer to the same parts. The drawings are not intended to be scaled to scale in actual size, with emphasis on the gist of the present invention.
图1-1为本发明提供的电子阅读终端的第一种展示效果示意图;1-1 is a schematic diagram showing the first display effect of the electronic reading terminal provided by the present invention;
图1-2为本发明提供的电子阅读终端的第二种展示效果示意图;1-2 is a schematic diagram showing a second display effect of the electronic reading terminal provided by the present invention;
图2为本发明实施例提供的页面排版方法的第一种实施方法流程图;2 is a flowchart of a first implementation method of a page layout method according to an embodiment of the present invention;
图3为本发明实施例提供的页面排版方法的第二种实施方法流程图;3 is a flowchart of a second implementation method of a page layout method according to an embodiment of the present invention;
图4为本发明实施例提供的页面排版方法的第三种实施方法流程图4 is a flowchart of a third implementation method of a page layout method according to an embodiment of the present invention.
图5-1为本发明实施例提供的示例中将内容容器插入页面容器的显示示意图;5-1 is a schematic diagram of displaying a content container into a page container in an example provided by an embodiment of the present invention;
图5-2为本发明实施例提供的示例中补充每个页面容器空行的显示示意图;FIG. 5-2 is a schematic diagram of displaying an empty line of each page container in an example provided by an embodiment of the present invention; FIG.
图5-3为本发明实施例提供的示例中页面容器中内容偏移后的显示示意图;5-3 is a schematic diagram showing display after content offset in a page container in an example provided by an embodiment of the present invention;
图6为本发明实施例提供的页面排版装置的第一种实施方式结构示意图;FIG. 6 is a schematic structural diagram of a first implementation manner of a page typesetting apparatus according to an embodiment of the present disclosure;
图7为本发明实施例提供的页面排版装置的第二种实施方式结构示意图。FIG. 7 is a schematic structural diagram of a second implementation manner of a page typesetting apparatus according to an embodiment of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整的描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, but not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
实施例一Embodiment 1
请参见图2,该图示出了本发明实施例提供的页面排版方法的第一种实施方法流程图,该页面排版方法包括如下步骤: Referring to FIG. 2, a flow chart of a first implementation method of a page layout method according to an embodiment of the present invention is shown. The page layout method includes the following steps:
步骤S101:确定终端显示区域可以容纳的字数。Step S101: Determine the number of words that the terminal display area can accommodate.
本实施例中,文章字符不同时,确定能够容纳的字数的方式不同,因此,当获取到一篇文章时,首先,确定文章的字符类型,而文章的字符类型通常能够从文章已知的属性中直接得到。得到文章的字符类型后,根据确定的字符类型计算字符的宽度。具体包括:当文章的字符类型为中文时,可以根据字符的字号和像素的对应关系,确定每个字符的宽度,或者根据经验值确定,本发明对此不做限制;当文章为英文字符时,计算英文字符的平均宽度,在确定字型和字号后,该平均宽度的确定可以通过计算26个字母的平均宽度值,或者计算宽度最小的字母I和宽度最大的字母W的平均值,作为字母平均宽度。确定每个字符宽度之后,进而根据终端显示区域的宽度,确定每行能够容纳的字数,然后,根据终端显示区域的高度,确定能够容纳的行数,从而得到终端显示区域可以容纳的字数。In this embodiment, when the article characters are different, the manner of determining the number of words that can be accommodated is different. Therefore, when an article is acquired, first, the character type of the article is determined, and the character type of the article is usually capable of being known from the article. Get it directly. After getting the character type of the article, the width of the character is calculated according to the determined character type. Specifically, when the character type of the article is Chinese, the width of each character may be determined according to the correspondence between the font size and the pixel of the character, or determined according to the empirical value, and the present invention does not limit this; when the article is an English character Calculate the average width of English characters. After determining the font and font size, the average width can be determined by calculating the average width value of 26 letters, or calculating the average value of the letter I with the smallest width and the letter W with the largest width. The average width of the letters. After determining the width of each character, the number of words that can be accommodated in each row is determined according to the width of the display area of the terminal, and then the number of lines that can be accommodated is determined according to the height of the display area of the terminal, thereby obtaining the number of words that the terminal display area can accommodate.
当然,本发明的技术方案,确定终端显示区域可以容纳的字数的方式,不限于上述描述,还可以为其他确定方式,本发明此处不再赘述。Of course, in the technical solution of the present invention, the manner in which the number of words that can be received by the display area of the terminal is determined is not limited to the foregoing description, and may be other determined manners, which are not described herein again.
本实施例中,首先,确定字符宽度,然后,根据字符宽度计算能够容纳的字数,能够不依赖任何语言,从而能够应用于任何语言,应用范围广。In the present embodiment, first, the character width is determined, and then the number of words that can be accommodated is calculated according to the character width, and can be applied to any language without using any language, and the application range is wide.
步骤S102:根据终端显示区域可以容纳的字数,将文章分成若干内容块。Step S102: The article is divided into a plurality of content blocks according to the number of words that the terminal display area can accommodate.
基于上述步骤,终端显示区域可以容纳的字数,即,每页的字数,根据每页的字数及文章的总字数,将文章内容分为多个内容块,每个内容块即为每页所显示的内容。例如1000字的文章,每页可以容纳的字数为100,则每100个字为一个内容块,该文章能够划分为10个内容块。Based on the above steps, the number of words that the terminal display area can accommodate, that is, the number of words per page, divides the content of the article into a plurality of content blocks according to the number of words per page and the total number of words of the article, and each content block is displayed for each page. Content. For example, a 1000-word article, each page can hold 100 words, and each 100 words is a content block, and the article can be divided into 10 content blocks.
步骤S103:将内容块加载到对应的内容容器。Step S103: Loading the content block into the corresponding content container.
其中,本步骤中,一个内容容器中对应加载一个内容块,为了便于对内容块的管理,为内容块添加内容标签。内容标签包括起始标签和结束标签,起始标签通常位于内容块第一个字符前,用于表示该内容块的开始;结束标签位于内容块最后一个字符后,用于表示该内容块的结束。每个内容块的起始标签和结束标签将该内容块包裹,形成该内容块对应的内容容器。此外,内容标签可以为能够标识文档内容的、任意已知或者即将出现的标识符,本发明对此不做限制。在本发明的一个优选实施例中,内容标签可以为DOM(Document Object Model,文件对象模型)节点,从第一个字符开始,每100个字符通过DOM节点标注。每100个字符的起始DOM节点和结束DOM节点形成该100个字符的内容容器。 In this step, a content block is correspondingly loaded in a content container, and a content tag is added to the content block in order to facilitate management of the content block. The content tag includes a start tag and a closing tag. The start tag is usually located before the first character of the content block to indicate the start of the content block; the end tag is located after the last character of the content block to indicate the end of the content block. . The start tag and the end tag of each content block wrap the content block to form a content container corresponding to the content block. In addition, the content tag may be any known or upcoming identifier capable of identifying the content of the document, which is not limited by the present invention. In a preferred embodiment of the present invention, the content tag may be a DOM (Document Object Model) node, and each 100 characters are marked by a DOM node starting from the first character. The 100-character content container is formed for the starting DOM node and the ending DOM node of every 100 characters.
本发明实施例中,将内容块容器化,形成对字符的统一管理,便于对内容的处理,相对于对字符处理,能够节省处理步骤,而且算法简单。In the embodiment of the present invention, the content block is containerized to form a unified management of characters, which facilitates processing of the content, and the processing steps can be saved with respect to the character processing, and the algorithm is simple.
步骤S104:确定当前页面容器及其对应的内容容器。Step S104: Determine the current page container and its corresponding content container.
其中,为了能够直观的观察到每个页面的显示情况,方便对内容块的排版,在确定文章分页的数量之后,创建与文章分页相同数量的页面容器,页面容器的可见区域模拟终端显示区域设计。其中,一个页面容器对应一个内容容器,第一个页面容器对应第一个内容容器,第二个页面容器对应第二个内容容器,以此类推。本步骤中,当前页面容器可以为第一个页面容器,那么,当前页面容器对应的内容容器即为第一个内容容器。In order to be able to visually observe the display of each page, it is convenient to typeset the content block. After determining the number of pages of the article, create the same number of page containers as the article page, and the visible area of the page container simulates the display area of the terminal. . Wherein, one page container corresponds to one content container, the first page container corresponds to the first content container, the second page container corresponds to the second content container, and so on. In this step, the current page container may be the first page container, and then the content container corresponding to the current page container is the first content container.
步骤S105:将对应内容容器插入到页面容器中。Step S105: Insert the corresponding content container into the page container.
其中,内容容器中的字符能够实现换行、拉伸对齐等自然排版。将内容容器插入页面容器后,页面容器能够模拟终端显示区域,将内容容器中的内容块进行展示。当‘当前页面容器’为第一个页面容器时,将第一个内容容器插入当前页面容器后,在当前页面容器中,就能够直观的看到第一个内容容器中的内容块,在终端显示区域中的展示效果。此外,将内容容器中的内容块进行自然排版,可以通过CSS(Cascading Style Sheets,层叠样式表)样式控制字符进行,对字符进行自然排版为本领域技术人员所熟知的技术手段,本发明此处不再赘述。Among them, the characters in the content container can realize natural typesetting such as line feed and stretch alignment. After the content container is inserted into the page container, the page container can simulate the terminal display area and display the content block in the content container. When the 'current page container' is the first page container, after inserting the first content container into the current page container, in the current page container, the content block in the first content container can be visually seen in the terminal. Shows the impression in the area. In addition, the natural typesetting of the content blocks in the content container can be performed by CSS (Cascading Style Sheets) style control characters, and the natural typesetting of the characters is a technical means well known to those skilled in the art, and the present invention is here. No longer.
需要指出的,将对应内容容器插入到页面容器后,还可以包括,判断当前页面容器的页尾是否有空行,当‘当前页面容器’页尾有空行,通过执行步骤S106填充当前页面容器页尾的空行;当‘当前页面容器’页尾无空行,对当前页面容器执行步骤S107.其中,判断当前页面容器的页尾是否有空行的具体方法可以为:判断对应内容容器与当前页面容器的高度是否相等,当对应内容容器与当前页面容器的高度相等时,当前页面容器的页尾无空行;当对应内容容器与当前页面容器的高度不相等时,则当前页面容器的页尾有空行。当然,判断当前页面容器的页尾是否有空行的方法,还可以为其他方式,本发明此处不做限制。It should be noted that, after inserting the corresponding content container into the page container, the method may further include: determining whether there is a blank line at the end of the current page container, and when the current page container has a blank line at the end of the page, filling the current page container by performing step S106 A blank line at the end of the page; when there is no blank line at the end of the 'current page container', step S107 is performed on the current page container. The specific method for determining whether there is a blank line at the end of the current page container may be: determining the corresponding content container and Whether the height of the current page container is equal. When the corresponding content container is equal to the height of the current page container, there is no blank line at the end of the current page container; when the height of the corresponding content container and the current page container are not equal, the current page container is There is a blank line at the end of the page. Certainly, the method for judging whether there is a blank line at the end of the current page container may be other methods, and the present invention is not limited herein.
步骤S106:将紧邻对应内容容器的下一个内容容器插入到当前页面容器。Step S106: Insert the next content container immediately adjacent to the corresponding content container into the current page container.
其中,由于将内容块插入页面容器后,页面容器的页尾部分会出现空行。为了填充页面容器的空行,同时,保证该页面容器中所展示的内容的连贯性,将当前页面容器相对应的内容容器插入当前页面容器后,再将紧邻该内容容器的下一个内容容器插入当前页面容器的对应内容容器之后。需要指出的,为了保证页面容器中内容显示的 连贯性,在插入下一个内容容器前,可以先确定当前内容容器的结束标签,根据该结束标签将紧邻该内容容器的下一个内容容器插入;优选地,可以将紧邻该结束标签的下一行的起始位置作为插入下一个内容容器的起始位置,将下一个内容容器的起始标签插入该位置。由于内容容器的容器特性,当将下一个内容容器插入当前页面容器后,下一个内容容器中的第一行在当前页面容器中空行的第一行显示。Among them, since the content block is inserted into the page container, a blank line appears at the end of the page container. In order to fill the blank line of the page container, at the same time, to ensure the consistency of the content displayed in the page container, insert the content container corresponding to the current page container into the current page container, and then insert the next content container immediately adjacent to the content container. After the corresponding content container of the current page container. Need to point out, in order to ensure that the content in the page container is displayed Coherence, before inserting the next content container, first determining the end tag of the current content container, according to which the next content container of the content container is inserted; preferably, the next line of the end tag may be adjacent The starting position is inserted as the starting position of the next content container, and the starting label of the next content container is inserted into the position. Due to the container nature of the content container, when the next content container is inserted into the current page container, the first line in the next content container is displayed in the first line of the hollow line of the current page container.
此外,由于当前页面容器中,仅在页尾部分存在空行,因此,紧邻的下一个内容容器插入后,只显示部分内容,其他部分位于当前页面容器的不可见区域内,因此,无法显示。In addition, since there is only a blank line in the current page container, only the next content container is inserted, only part of the content is displayed, and the other part is located in the invisible area of the current page container, and therefore cannot be displayed.
此外,为了保证与当前页面容器对应的内容容器在最后一行显示时为一个整行,确定内容块时,可以将最后一行的儿个字符划分到下一个内容容器。本发明对具体划分方法不再赘述。In addition, in order to ensure that the content container corresponding to the current page container is an entire line when displayed on the last line, when the content block is determined, the characters of the last line can be divided into the next content container. The present invention will not be described in detail for the specific division method.
步骤S107:对当前页面容器进行排版。Step S107: Typesetting the current page container.
其中,当‘当前页面容器’为第一个内容容器时,对当前页面容器的排版已经完成。由于当前页面容器所显示的内容,与紧邻的下一个页面容器所显示的内容有部分重复,还需要计算该重复部分的偏移量,以便于根据该偏移量对下一个页面容器进行排版。Wherein, when the 'current page container' is the first content container, the layout of the current page container has been completed. Since the content displayed by the current page container is partially overlapped with the content displayed by the next next page container, the offset of the repeated portion needs to be calculated so as to typeset the next page container according to the offset.
由上述实施例可知,本发明实施例提供的页面排版方法,将文章分页得到的若干内容块,并将内容块加载到对应的内容容器中。在确定当前页面容器及其对应的内容容器后,将所述内容容器插入到页面容器中。由于当前页面容器页尾部分存在空行,除最后一个页面容器,通过将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器,填充当前页面容器的空行。与现有技术相比,当分页后页面中存在空行时,能够将空行进行填补,从而能够避免页尾出现空行的现象,提高页面的利用率,进一步能够优化展示效果,提高用户体验。It can be seen from the above embodiment that the page layout method provided by the embodiment of the present invention divides a plurality of content blocks obtained by the article and loads the content block into the corresponding content container. After determining the current page container and its corresponding content container, the content container is inserted into the page container. Since there is a blank line in the tail portion of the current page container, except for the last page container, the blank line of the current page container is filled by inserting the next content container immediately adjacent to the corresponding content container into the current page container. Compared with the prior art, when there is a blank line in the page after paging, the blank line can be filled, thereby avoiding the phenomenon of blank lines at the end of the page, improving the utilization of the page, and further optimizing the display effect and improving the user experience. .
实施例二Embodiment 2
参见图3,本图示出了本发明实施例提供的页面排版方法的第二种实施方法流程图。本实施例是在实施例一基础上的扩充,关于本实施例方法步骤中与实施例一重复性的内容可参见实施例一的内容,在本实施例中不再赘述。本实施例中,所述方法包括以下步骤:Referring to FIG. 3, this figure shows a flow chart of a second implementation method of a page layout method according to an embodiment of the present invention. This embodiment is an extension of the first embodiment. For the content of the method in the embodiment, the content of the method is not described in detail in the embodiment. In this embodiment, the method includes the following steps:
步骤S201:确定终端显示区域可以容纳的字数。 Step S201: Determine the number of words that the terminal display area can accommodate.
在本实施例中,假设文章包含1000个字符,终端显示区域可以容纳的100个字。In this embodiment, it is assumed that the article contains 1000 characters and the terminal display area can hold 100 words.
步骤S202:根据终端显示区域可以容纳的字数,将文章分成若干内容块。Step S202: The article is divided into a plurality of content blocks according to the number of words that the terminal display area can accommodate.
从文章的第一个字符开始,每100个字符作为一个内容块,得到10个内容块。Starting with the first character of the article, every 100 characters as a block of content, get 10 blocks of content.
步骤S203:将内容块加载到对应的内容容器。Step S203: Loading the content block into the corresponding content container.
步骤S204:确定当前页面容器及其对应的内容容器。Step S204: Determine the current page container and its corresponding content container.
在上述实施例的基础上,本实施例中,第一个页面容器对应第一个内容容器;第二个页面容器对应第二个内容容器;第三个页面容器对应第三个内容容器,以此类推。当然,第一个内容容器结束部分的内容与第二个内容容器起始部分的内容相互衔接;第二个内容容器结束部分的内容与第三个内容容器起始部分的内容相互衔接;衔接关系顺次向后。On the basis of the foregoing embodiment, in this embodiment, the first page container corresponds to the first content container; the second page container corresponds to the second content container; and the third page container corresponds to the third content container, This type of push. Of course, the content of the end portion of the first content container is concatenated with the content of the beginning portion of the second content container; the content of the end portion of the second content container is concatenated with the content of the beginning portion of the third content container; Step backwards.
步骤S205:将内容容器插入到页面容器中。Step S205: Insert the content container into the page container.
步骤S206:将紧邻内容容器的下一个内容容器插入到当前页面容器。Step S206: Insert the next content container immediately adjacent to the content container into the current page container.
假设当前页面容器为第二页面容器,由于插入第二个内容容器后,第二个页面容器页尾部分存在两行空行,则将第三个内容容器插入第二个页面容器中,以填充第二个页面容器的两空白行。当然,由上述实施例可知,在第二个页面容器中,第三个内容容器仅起始部分的两行内容能够显示,其他部分均无法显示。Assuming that the current page container is a second page container, since there are two blank lines in the tail portion of the second page container after inserting the second content container, the third content container is inserted into the second page container to fill Two blank lines of the second page container. Of course, as can be seen from the above embodiment, in the second page container, only the content of the first line of the third content container can be displayed, and other parts cannot be displayed.
步骤S207:计算当前页面容器的偏移量。Step S207: Calculate the offset of the current page container.
假设第一个页面容器中有两行空行,则第二个内容容器起始部分两行内容,在第一个页面容器和第二个页面容器中均有显示,造成重复显示,不仅浪费页面资源,而且影响用户的体验。因此,为了去掉重复显示的部分,需要调整第二个页面容器中第二个内容容器的显示区域。在本发明的一个优选实施例中,通过计算得到第一个页面容器与第一个内容容器的高度差,得到第一个页面容器的偏移量,用于第二个页面容器根据该偏移量调整内容容器。相类似的,第二个页面容器中也存在空行,因此,需要计算第二个页面容器的偏移量,以便于对后面页面容器进行排版。Assuming that there are two rows of blank lines in the first page container, the first two lines of content in the first content container are displayed in both the first page container and the second page container, causing repeated display, not only wasting the page. Resources, and affect the user's experience. Therefore, in order to remove the portion of the repeated display, it is necessary to adjust the display area of the second content container in the second page container. In a preferred embodiment of the present invention, the height difference between the first page container and the first content container is obtained by calculation, and the offset of the first page container is obtained, and the second page container is used according to the offset. Adjust the content container. Similarly, there is also a blank line in the second page container, so the offset of the second page container needs to be calculated in order to typeset the subsequent page container.
步骤S208:累计所述偏移量,得到累计偏移量。Step S208: Accumulating the offset amount to obtain a cumulative offset.
其中,在上述实施例的基础上可知,当对第二个页面容器中第二个内容容器向上偏移两行时,为了保证内容的衔接显示,还需要将第二个页面容器中第三个内容容器 向上偏移两行。而第二个页面容器本身已经存在两个空行,因此,第三个内容容器在第二个页面容器中重复的部分为,第一个页面容器的偏移量与第二个页面容器的偏移量的累加。因此,需要将之前得到的偏移量全部累计,得到累计偏移量,以便于对后面的页面容器根据累计偏移量进行处理。On the basis of the foregoing embodiment, when the second content container in the second page container is offset upward by two lines, in order to ensure the content display, the third page container needs to be the third. Content container Offset two lines upwards. The second page container itself already has two blank lines, so the third content container repeats in the second page container, the offset of the first page container and the second page container. The accumulation of shifts. Therefore, it is necessary to accumulate all the previously obtained offsets to obtain a cumulative offset so as to process the subsequent page containers according to the accumulated offset.
步骤S209:将当前页面容器的下一个页面容器作为当前页面容器,根据累计偏移量调整当前页面容器中内容容器的显示内容。Step S209: The next page container of the current page container is used as the current page container, and the display content of the content container in the current page container is adjusted according to the accumulated offset.
其中,根据偏移量调整第三个页面容器中内容容器的显示内容,具体包括:判断累计偏移量是否小于第三个内容容器的高度;当累计偏移量小于第三个内容容器的高度时,说明第三个内容容器中,仅有一部分内容在第二个页面容器中显示,其他部分需要在第三个页面容器中显示,因此,将第三个页面容器中的第三个内容容器向上偏移,将第三个内容容器中,与第二个页面容器重复显示的部分偏移出可见区域,同时将第三个页面容器中的第四个内容容器向上偏移相同的量。当累计偏移量大于或者等于第三个内容容器的高度时,说明第三个内容容器的内容,全部在第二个内容容器中显示,因此,删除第三个页面容器。当然,当‘当前页面容器’为最后一个页面容器时,对文章的排版结束。The adjusting the content of the content container in the third page container according to the offset includes: determining whether the accumulated offset is smaller than the height of the third content container; and when the cumulative offset is less than the height of the third content container In the third content container, only part of the content is displayed in the second page container, and other parts need to be displayed in the third page container, so the third content container in the third page container Offward shifts the portion of the third content container that is repeatedly displayed with the second page container out of the visible area while shifting the fourth content container in the third page container up by the same amount. When the cumulative offset is greater than or equal to the height of the third content container, the content of the third content container is all displayed in the second content container, thus deleting the third page container. Of course, when the 'current page container' is the last page container, the layout of the article ends.
本实施例中,通过计算重复显示内容的偏移量,并按照该偏移量将重复的部分从页面容器的可见区域偏移出,在填充每个页面容器空白区域的基础上,去除页面容器之间重复显示的部分,不仅能够充分利用页面资源,而且能够提高用户体验。In this embodiment, by calculating the offset of the repeatedly displayed content, and offsetting the repeated portion from the visible area of the page container according to the offset, the page container is removed on the basis of filling the blank area of each page container. The repeated display between the parts not only makes full use of the page resources, but also improves the user experience.
实施例三Embodiment 3
参见图4,该图示出了本发明实施例提供的页面排版方法的第三种实施方法流程图。本实施例将上述两个实施例的执行次序进行变换,形成本实施例的执行方式。本实施例的执行内容与上述实施例相似,对于本实施例方法步骤中与实施例一或者实施例二重复性的内容,可参见实施例一和/或者实施例二的内容,在本实施例中不再赘述。本实施例中,所述方法包括以下步骤:Referring to FIG. 4, a flow chart of a third implementation method of a page layout method according to an embodiment of the present invention is shown. This embodiment transforms the execution order of the above two embodiments to form the execution mode of the embodiment. The content of the implementation of this embodiment is similar to that of the foregoing embodiment. For the content of the method in this embodiment, which is repetitive with the first embodiment or the second embodiment, refer to the content of the first embodiment and/or the second embodiment. I won't go into details here. In this embodiment, the method includes the following steps:
步骤S301:确定终端显示区域可以容纳的字数。Step S301: Determine the number of words that the terminal display area can accommodate.
步骤S302:根据终端显示区域可以容纳的字数,将文章分成若干内容块。Step S302: The article is divided into a plurality of content blocks according to the number of words that the terminal display area can accommodate.
步骤S303:将每个内容块加载到对应的内容容器。Step S303: Load each content block into a corresponding content container.
步骤S304:将每个内容容器插入到对应的页面容器中。 Step S304: Insert each content container into a corresponding page container.
步骤S305:除最后一个页面容器,在每个页面容器中,插入下一个页面容器中的内容容器。Step S305: In addition to the last page container, in each page container, the content container in the next page container is inserted.
在本实施例中,将每个内容容器插入相对应的页面容器后,除去最后一个页面容器,可以首先填补每一个页面容器的空白;或者,将对应的内容容器插入当前页面容器时,同时将该内容容器的下一个内容容器一起插入当前页面容器。In this embodiment, after inserting each content container into the corresponding page container, the last page container is removed, and the blank of each page container may be filled first; or, when the corresponding content container is inserted into the current page container, The next content container of the content container is inserted into the current page container.
步骤S306:确定当前页面容器。Step S306: Determine the current page container.
步骤S307:对当前页面容器进行排版。Step S307: Typesetting the current page container.
如果当前页面容器为第一个页面容器,当前页面容器已经排版完成,通过计算当前页面容器与第一个内容容器的高度差确定偏移量;当‘当前页面容器’不为第一个页面容器也不为最后一个页面容器时,计算当前页面容器及其对应的内容容器的高度差,然后,根据之前计算的偏移量,将当前页面容器中的内容容器向上偏移,完成对当前内容容器的排版。If the current page container is the first page container, the current page container has been formatted, and the offset is determined by calculating the height difference between the current page container and the first content container; when the 'current page container' is not the first page container When not the last page container, calculate the height difference between the current page container and its corresponding content container, and then, according to the previously calculated offset, offset the content container in the current page container upward, and complete the current content container. Typography.
步骤S308:计算当前页面容器的偏移量。Step S308: Calculate the offset of the current page container.
步骤S309:累计所述偏移量,得到累计偏移量Step S309: Accumulating the offset to obtain a cumulative offset
步骤S310:将当前页面容器的下一个页面容器作为当前页面容器,根据所述累计偏移量对当前页面容器进行排版。Step S310: The next page container of the current page container is used as the current page container, and the current page container is typeset according to the accumulated offset.
步骤S311:判断当前页面容器是否为最后一个容器,当否时,执行步骤S308;当是时,执行步骤S312。Step S311: determining whether the current page container is the last container, if not, executing step S308; when yes, executing step S312.
其中,当‘当前页面容器’不为最后一个页面容器时,根据上述实施例所述,当前页面容器中存在与下一个页面容器中相同的内容,因此,仍然需要计算偏移量,以便于得到累计偏移量,并根据该累计偏移量对后面的页面容器进行排版;当‘当前页面容器’为最后一个页面容器时,所有的页面容器均已完成排版,结束操作。Wherein, when the 'current page container' is not the last page container, according to the above embodiment, the current page container has the same content as in the next page container, therefore, the offset needs to be calculated in order to obtain The offset is accumulated, and the subsequent page container is typeset according to the accumulated offset; when the 'current page container' is the last page container, all the page containers have completed the typesetting, and the operation ends.
本实施例所提供的页面排版方法,将文章分页得到的若干内容块,并将内容块加载到对应的内容容器中。在确定当前页面容器及其对应的内容容器后,将所述内容容器插入到页面容器中。由于当前页面容器页尾部分存在空行,除最后一个页面容器,通过将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器,填充当前页面容器的空行。与现有技术相比,当分页后页面中存在空行时,能够将空行进行填补, 从而能够避免页尾出现空行的现象,提高页面的利用率,进一步能够优化展示效果,提高用户体验。In the page layout method provided in this embodiment, a plurality of content blocks obtained by paging the articles are loaded, and the content blocks are loaded into the corresponding content containers. After determining the current page container and its corresponding content container, the content container is inserted into the page container. Since there is a blank line in the tail portion of the current page container, except for the last page container, the blank line of the current page container is filled by inserting the next content container immediately adjacent to the corresponding content container into the current page container. Compared with the prior art, when there is a blank line in the page after paging, the blank line can be filled. Therefore, the phenomenon of blank lines at the end of the page can be avoided, the utilization of the page can be improved, and the display effect can be further optimized to improve the user experience.
实施例四Embodiment 4
为了使本领域技术人员更加清楚的了解本发明的技术方案,本实施例中通过一个具体实例对本发明的技术方案进行详细的描述。In order to make the technical solutions of the present invention more clear to those skilled in the art, the technical solutions of the present invention are described in detail in this embodiment through a specific example.
本实施例中以一篇包括1000个字符的中文文章为例进行描述,假设电子阅读终端为手机,其显示界面的高度和宽度参数已知,字符显示时的字号已知。首先,根据字符字号与像素的关系计算每个字符所占的宽度;然后,根据手机显示界面的宽度,计算每行能够容纳的字符数。假设本实施例中,每行能够容纳10个字符;最后,根据手机显示界面的高度参数计算每页能够容纳的行数。假设本实施例中,能够容纳10行,从而确定在本实施例中,每页能够容纳100个字符。1000个字符能够分为10页。In this embodiment, a Chinese article including 1000 characters is taken as an example. Assume that the electronic reading terminal is a mobile phone, and the height and width parameters of the display interface are known, and the font size when the character is displayed is known. First, the width of each character is calculated according to the relationship between the character size and the pixel; then, according to the width of the display interface of the mobile phone, the number of characters that can be accommodated in each line is calculated. It is assumed that in this embodiment, each line can accommodate 10 characters; finally, the number of lines that can be accommodated per page is calculated according to the height parameter of the display interface of the mobile phone. It is assumed that in the present embodiment, 10 lines can be accommodated, thereby determining that in the present embodiment, each page can accommodate 100 characters. 1000 characters can be divided into 10 pages.
从第一个字符开始,为每100个字符插入DOM节点,通过DOM节点的形式表示出每页的内容。具体为,在第一个字符前面添加起始节点,在第一百个字符后面添加结束节点,顺次为后面每100个字符进行相同的操作。Starting from the first character, a DOM node is inserted for every 100 characters, and the content of each page is represented by a DOM node. Specifically, a start node is added before the first character, and an end node is added after the first hundred characters, and the same operation is performed for every 100 characters in the following.
需要指出的,每100个字符可以看做一个内容块,而DOM节点可以看做包裹内容块的内容容器,本实施例中,包括10个内容容器。此外,为了能够直观的看到每个内容块在手机显示界面的显示效果,在确定将文章分为10页之后,创建10个页面容器,每个内容容器对应一个页面容器。其中,页面容器显示区域的大小按照手机显示屏幕的大小设定。It should be noted that every 100 characters can be regarded as a content block, and the DOM node can be regarded as a content container of a package content block. In this embodiment, 10 content containers are included. In addition, in order to visually see the display effect of each content block on the mobile phone display interface, after determining to divide the article into 10 pages, 10 page containers are created, and each content container corresponds to one page container. The size of the display area of the page container is set according to the size of the display screen of the mobile phone.
顺次将内容容器插入其相对应的页面容器内,如图5-1所示,该图示出了将内容容器51插入页面容器52的显示示意图。按照内容块的顺序,将每个内容容器插入页面容器的显示区域,其中,任意两个相邻的页面容器中内容块的内容相互连接。需要指出的,将内容容器51插入页面容器52后,内容容器51中的内容块按照CSS样式控制字符的排版,形成每行行尾都对齐的自然排版。由于文章内容中存在半角标点符号或者英文字母,因此,内容块自然排版后,页面容器52页尾部分出现空行。The content container is sequentially inserted into its corresponding page container, as shown in FIG. 5-1, which shows a schematic view of the content container 51 being inserted into the page container 52. Each content container is inserted into the display area of the page container in the order of the content blocks, wherein the contents of the content blocks in any two adjacent page containers are connected to each other. It should be noted that after the content container 51 is inserted into the page container 52, the content block in the content container 51 controls the layout of the characters according to the CSS style, forming a natural typesetting in which the end of each line is aligned. Since there are half-width punctuation marks or English letters in the content of the article, after the content block is naturally typeset, a blank line appears at the end of the page container 52.
为了填补每个页面容器页尾出现的空行,将除最后一个页面容器之外的任意一个页面容器作为当前页面容器,将该当前页面容器的下一个页面容器中的内容容器插入当前页面容器。其中,插入前首先,确定先插入内容容器的结束节点,其次,将该结束节点后面紧邻的位置,最后,作为后插入内容容器的起始节点插入的位置。需要说 明的,后插入内容容器中内容的第一行自动另起一行。当然,如果当前页面容器为最后一个页面容器,则无须填补其页尾的空行。To fill the blank line that appears at the end of each page container, any page container other than the last page container is used as the current page container, and the content container in the next page container of the current page container is inserted into the current page container. First, before inserting, first determine the end node of the content container to be inserted first, secondly, the position immediately after the end node, and finally, the position to be inserted as the start node of the post-insertion content container. Need to say The first line of the content inserted in the content container is automatically followed by another line. Of course, if the current page container is the last page container, there is no need to fill in the blank lines at the end of its page.
如图5-2所示,为填补页面容器空白后页面容器的显示示意图。其中,每个页面容器内包含两个内容容器,先插入内容容器53全部显示,后插入内容容器54仅在页面容器52空行的部分显示,其他部分均不可见。As shown in Figure 5-2, the page container is displayed after the page container is blank. Each of the page containers includes two content containers, and the first inserted content container 53 is all displayed, and the post-inserted content container 54 is displayed only in the blank portion of the page container 52, and other portions are not visible.
若当前页面容器为第一个页面容器时,此时,页面容器已经填充满,即,已经完成对第一个页面容器的排版;若当前页面容器并非第一个页面容器,由于当前页面容器的上一个页面容器所显示的内容中,包含与当前页面容器所显示内容相同的部分,因此,为了提高页面的利用率,应当将当前页面容器中,与其上一个页面容器中相同的部分去掉。If the current page container is the first page container, at this time, the page container is already filled, that is, the layout of the first page container has been completed; if the current page container is not the first page container, due to the current page container The content displayed by the previous page container contains the same content as the content displayed by the current page container. Therefore, in order to improve the utilization of the page, the same part of the current page container as the previous page container should be removed.
请参见图5-3,该图为页面容器中内容偏移后的显示示意图。本实施例中,通过偏移内容容器,将先插入内容容器52中重复的部分从页面容器52的可见区域上移到不可见区域,从而使当前页面容器页头显示的内容,与其上一个页面容器页尾显示的内容衔接。需要指出的,为了保证当前页面容器所显示的内容的连贯性,将先插入内容容器52向上偏移时,后插入内容容器53也向上偏移同样的量,至此,完成对当前页面容器的排版。Please refer to Figure 5-3, which shows the display after the content of the page container is offset. In this embodiment, by shifting the content container, the repeated portion inserted into the content container 52 is moved from the visible area of the page container 52 to the invisible area, so that the content displayed by the current page container header is compared with the previous page. The content displayed at the end of the container is connected. It should be noted that, in order to ensure the consistency of the content displayed by the current page container, when the content container 52 is first shifted upward, the post-insertion content container 53 is also offset upward by the same amount, and thus the layout of the current page container is completed. .
此外,在本实施例中,当‘当前页面容器’为第二个页面容器时,计算第一个页面容器可见区域与其先插入内容容器的高度差,该高度差即为第一个页面容器需要填充的空白区域,该空白区域中所显示的内容,即为当前页面容器中重复内容的高度,所以将该高度差确定为当前页面容器中内容容器的偏移量;当‘当前页面容器’为第N(N为大于2的自然数)个页面容器时,得到前面N-1个页面容器的高度差,将该N-1个高度差累加,得到当前页面容器的偏移量。例如,N为3时,当前页面容器的偏移量为,第一个页面容器的高度差与第二个页面容器的高度差之和,其他页面容器偏移量的计算与上述相同,本发明此处不再赘述。In addition, in this embodiment, when the 'current page container' is the second page container, the height difference between the visible area of the first page container and the content container inserted first is calculated, and the height difference is the first page container needs. The filled blank area, the content displayed in the blank area is the height of the duplicate content in the current page container, so the height difference is determined as the offset of the content container in the current page container; when the 'current page container' is When the Nth (N is a natural number greater than 2) page containers, the height difference of the first N-1 page containers is obtained, and the N-1 height differences are accumulated to obtain the offset of the current page container. For example, when N is 3, the offset of the current page container is the sum of the difference between the height difference of the first page container and the height difference of the second page container, and the calculation of the offset of the other page containers is the same as the above, and the present invention I will not repeat them here.
需要指出的,在根据偏移量调整内容容器之前,判断偏移量是否小于当前页面容器中先插入内容容器的高度,如果小于,说明先插入内容容器中部分内容在上一个页面容器中显示,其余部分内容在当前页面容器中显示,因此,将当前页面中的内容容器按照偏移量调整;如果偏移量大于或者等于先插入内容容器的高度,说明先插入内容容器中全部的内容均用于填充上一个页面容器,即其全部内容均已在上一个页面容器中显示,因此,直接删除当前页面容器。 It should be noted that before adjusting the content container according to the offset, it is determined whether the offset is smaller than the height of the content container inserted first in the current page container. If it is smaller, the content inserted in the content container is displayed in the previous page container. The rest of the content is displayed in the current page container, so the content container in the current page is adjusted according to the offset; if the offset is greater than or equal to the height of the content container first inserted, it means that all the content in the content container is inserted first. The previous page container is populated, that is, its entire content is displayed in the previous page container, so the current page container is directly deleted.
当然,分别将内容容器插入相对应的页面容器之后,可以首先对每个页面容器执行填补空行的操作,然后再分别计算每个页面容器的高度差,并分别调整每个页面容器,直到最后一个页面容器;或者对当前页面容器执行,填补空行,然后计算高度差的操作之后,指向下一个页面容器,并执行相同的操作,直到最后一个容器。本发明对具体执行次序不做限制。Of course, after inserting the content container into the corresponding page container respectively, you can first perform the operation of filling the blank line for each page container, then calculate the height difference of each page container separately, and adjust each page container separately until the end. A page container; or execute on the current page container, fill in the empty line, and then calculate the height difference operation, point to the next page container, and perform the same operation until the last container. The present invention is not limited to the specific order of execution.
需要说明的,上述仅为本发明的一个优选示例,对本发明的技术方案不构成任何限制,每个执行步骤的简单变形和替换均属于本发明技术方案的保护范畴。It should be noted that the foregoing is only a preferred example of the present invention, and the technical solution of the present invention is not limited in any way. The simple deformation and replacement of each execution step belong to the protection scope of the technical solution of the present invention.
可以得到,本发明实施例所提供的页面排版方法,将文章分页得到的若干内容块,并将内容块加载到对应的内容容器中。在确定当前页面容器及其对应的内容容器后,将所述对应内容容器插入到页面容器中。由于当前页面容器页尾部分存在空行,通过将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器,填充页面容器的空行。与现有技术相比,当分页后页面中存在空行时,能够将空行进行填补,从而能够避免页尾出现空行的现象,提高页面的利用率,进一步能够优化展示效果,提高用户体验。In the page layout method provided by the embodiment of the present invention, a plurality of content blocks obtained by paging the articles are obtained, and the content blocks are loaded into the corresponding content containers. After determining the current page container and its corresponding content container, the corresponding content container is inserted into the page container. Since there is a blank line in the footer portion of the current page container, the blank line of the page container is filled by inserting the next content container immediately adjacent to the corresponding content container into the current page container. Compared with the prior art, when there is a blank line in the page after paging, the blank line can be filled, thereby avoiding the phenomenon of blank lines at the end of the page, improving the utilization of the page, and further optimizing the display effect and improving the user experience. .
实施例五Embodiment 5
与上述实现方法相对应的,本发明实施例还提供了页面排版装置,如图6所示,为本发明实施例提供的页面排版装置的第一种实施方式结构示意图。所述装置包括:第一确定单元11、分页单元12、加载单元13、第二确定单元14、第一插入单元15、第二插入单元16和排版单元17,其中,第一确定单元11,用于计算终端显示区域可以容纳的字数;分页单元12,用于根据终端显示区域可以容纳的字数,将文章分成若干内容块;加载单元13,用于将内容块加载到对应的内容容器;第二确定单元14,用于确定当前页面容器及其对应的内容容器;第一插入单元15,用于将对应内容容器插入到页面容器中;第二插入单元16,用于将紧邻对应内容容器的下一个内容容器插入到当前页面容器;排版单元17,用于对当前页面容器进行排版。Corresponding to the above implementation method, the embodiment of the present invention further provides a page layout device, as shown in FIG. 6 , which is a schematic structural diagram of a first implementation manner of a page layout device according to an embodiment of the present invention. The device includes: a first determining unit 11, a paging unit 12, a loading unit 13, a second determining unit 14, a first inserting unit 15, a second inserting unit 16, and a typesetting unit 17, wherein the first determining unit 11 The number of words that can be accommodated in the computing terminal display area; the paging unit 12 is configured to divide the article into a plurality of content blocks according to the number of words that the terminal display area can accommodate; the loading unit 13 is configured to load the content block into the corresponding content container; a determining unit 14 for determining a current page container and its corresponding content container; a first inserting unit 15 for inserting a corresponding content container into the page container; and a second inserting unit 16 for placing the next right next to the corresponding content container A content container is inserted into the current page container; a typesetting unit 17 is for formatting the current page container.
在本实施例的中,所述装置还包括判断单元,所述判断单元:用于判断所述对应内容容器与当前页面容器的高度是否相等;所述第二插入单元16:还用于当所述对应内容容器与当前页面容器的高度不相等时,将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器;所述排版单元17:还用于当所述对应内容容器与当前页面容器的高度相等时,对当前页面容器进行排版。In this embodiment, the device further includes a determining unit, configured to determine whether the height of the corresponding content container and the current page container are equal; the second inserting unit 16 is further used to When the height of the corresponding content container and the current page container are not equal, the next content container adjacent to the corresponding content container is inserted into the current page container; the typesetting unit 17 is further configured to: when the corresponding content container and the current page When the heights of the containers are equal, the current page container is typeset.
在本实施例的基础上,在另一个实施例中,所述装置还包括:计算单元、累计单元和调整单元,其中,计算单元,用于计算当前页面容器的偏移量;累计单元,用于 累计所述偏移量,得到累计偏移量;调整单元,用于将当前页面容器的下一个页面容器作为当前页面容器,根据累计偏移量调整当前页面容器中内容容器的显示内容。其中,调整单元包括:判断模块、偏移模块与删除模块,判断模块,用于判断累计偏移量是否小于当前页面容器对应的内容容器的高度;偏移模块,用于当累计偏移量小于当前页面容器对应的内容容器的高度时,将页面容器中的内容容器按照累计偏移量向上偏移;删除模块,用于当累计偏移量大于或者等于当前页面容器对应的内容容器的高度时,删除当前页面容器。On the basis of this embodiment, in another embodiment, the apparatus further includes: a calculating unit, an accumulating unit, and an adjusting unit, wherein the calculating unit is configured to calculate an offset of the current page container; Yu The offset is accumulated to obtain a cumulative offset; the adjusting unit is configured to use the next page container of the current page container as the current page container, and adjust the display content of the content container in the current page container according to the accumulated offset. The adjusting unit includes: a determining module, an offset module and a deleting module, and a determining module, configured to determine whether the accumulated offset is smaller than a height of a content container corresponding to the current page container; and the offset module is configured to: when the accumulated offset is smaller than When the height of the content container corresponding to the current page container is up, the content container in the page container is offset upward according to the accumulated offset; and the deleting module is configured to when the accumulated offset is greater than or equal to the height of the content container corresponding to the current page container. , delete the current page container.
第二确定单元14包括:获取模块、确定模块和计算模块,其中,获取模块,用于当文章为双字节字符时,获取字符的字号;或者,当文章为单字节字符时,获取字母的平均宽度;确定模块,用于当文章为双字节字符时,根据字号与像素的对应关系确定字符的宽度;计算模块,用于当文章为双字节字符时,根据宽度计算可以容纳的字数;或者,当文章为单字节字符时,通过平均宽度计算可以容纳的字母数。The second determining unit 14 includes: an obtaining module, a determining module, and a calculating module, wherein the acquiring module is configured to obtain a font size of the character when the article is a double-byte character; or, when the article is a single-byte character, obtain the letter The average width; the determining module is configured to determine the width of the character according to the correspondence between the font size and the pixel when the article is a double-byte character; and the calculation module is configured to calculate the capacity according to the width when the article is a double-byte character The number of words; or, when the article is a single-byte character, the number of letters that can be accommodated is calculated by the average width.
所述装置中各个单元的功能和作用的实现过程详见上述方法中对应的实现过程,在此不再赘述。For the implementation process of the function and the function of each unit in the device, refer to the corresponding implementation process in the foregoing method, and details are not described herein again.
本发明实施例所提供的页面排版装置,将文章分页得到的若干内容块,并将内容块加载到对应的内容容器中。在确定当前页面容器及其对应的内容容器后,将所述对应内容容器插入到页面容器中。由于当前页面容器页尾部分存在空行,通过将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器,填充页面容器的空行。与现有技术相比,当分页后页面中存在空行时,能够将空行进行填补,从而能够避免页尾出现空行的现象,提高页面的利用率,进一步能够优化展示效果,提高用户体验。The page typesetting apparatus provided by the embodiment of the present invention divides a plurality of content blocks obtained by the article and loads the content block into the corresponding content container. After determining the current page container and its corresponding content container, the corresponding content container is inserted into the page container. Since there is a blank line in the footer portion of the current page container, the blank line of the page container is filled by inserting the next content container immediately adjacent to the corresponding content container into the current page container. Compared with the prior art, when there is a blank line in the page after paging, the blank line can be filled, thereby avoiding the phenomenon of blank lines at the end of the page, improving the utilization of the page, and further optimizing the display effect and improving the user experience. .
实施例六Embodiment 6
参见图7,该图示出了本发明实施例提供的页面排版装置的第二种实施方式结构示意图。所述装置包括:第一确定单元20、分页单元21、加载单元22、第一插入单元23、第二插入单元24、第二确定单元25、第一排版单元26、计算单元27、累计单元28、第二排版单元29和判断单元30,其中,第一确定单元20,用于确定终端显示区域可以容纳的字数;分页单元21,用于根据终端显示区域可以容纳的字数,将文章分成若干内容块;加载单元22,用于将内容块加载到对应的内容容器;第一插入单元23,用于将每个内容容器插入到页面容器中;第二插入单元24,用于除最后一个页面容器,在每个页面容器中,插入下一个页面容器中的内容容器;第二确定单元25,用于确定当前页面容器;第一排版单元26,用于对当前页面容器进行排版;计算单元27,用于计算当前页面容器的偏移量;累计单元28,用于累计所述偏移量,得到累计偏移 量;第二排版单元,29,用于将当前页面容器的下一个页面容器作为当前页面容器,根据累计偏移量对当前页面容器进行排版;判断单元30,用于判断当前页面容器是否为最后一个容器;当当前页面容器并非最后一个页面容器,计算单元27还用于计算当前页面容器的偏移量。FIG. 7 is a schematic structural diagram of a second implementation manner of a page layout apparatus according to an embodiment of the present invention. The apparatus includes: a first determining unit 20, a paging unit 21, a loading unit 22, a first inserting unit 23, a second inserting unit 24, a second determining unit 25, a first typesetting unit 26, a calculating unit 27, and an accumulating unit 28. The second typesetting unit 29 and the determining unit 30, wherein the first determining unit 20 is configured to determine the number of words that the terminal display area can accommodate; the paging unit 21 is configured to divide the article into several contents according to the number of words that the terminal display area can accommodate a loading unit 22 for loading a content block into a corresponding content container, a first inserting unit 23 for inserting each content container into the page container, and a second inserting unit 24 for dividing the last page container Inserting a content container in the next page container in each page container; a second determining unit 25 for determining a current page container; a first typesetting unit 26 for formatting the current page container; and a calculating unit 27 An offset for calculating a current page container; an accumulation unit 28 for accumulating the offset to obtain a cumulative offset The second typesetting unit, 29, is configured to use the next page container of the current page container as the current page container, and typeset the current page container according to the accumulated offset; the determining unit 30 is configured to determine whether the current page container is the last A container; when the current page container is not the last page container, the computing unit 27 is also used to calculate the offset of the current page container.
所述装置中各个单元的功能和作用的实现过程详见上述方法中对应的实现过程,在此不再赘述。For the implementation process of the function and the function of each unit in the device, refer to the corresponding implementation process in the foregoing method, and details are not described herein again.
综合上述,本发明实施例所提供的页面排版方法及装置,将文章分页得到的若干内容块,并将内容块加载到对应的内容容器中。在确定当前页面容器及其对应的内容容器后,将所述对应内容容器插入到页面容器中。由于当前页面容器页尾部分存在空行,通过将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器,填充页面容器的空行。与现有技术相比,当分页后页面中存在空行时,能够将空行进行填补,从而能够避免页尾出现空行的现象,提高页面的利用率,进一步能够优化展示效果,提高用户体验。In summary, the page layout method and apparatus provided by the embodiment of the present invention divides a plurality of content blocks obtained by the article and loads the content block into the corresponding content container. After determining the current page container and its corresponding content container, the corresponding content container is inserted into the page container. Since there is a blank line in the footer portion of the current page container, the blank line of the page container is filled by inserting the next content container immediately adjacent to the corresponding content container into the current page container. Compared with the prior art, when there is a blank line in the page after paging, the blank line can be filled, thereby avoiding the phenomenon of blank lines at the end of the page, improving the utilization of the page, and further optimizing the display effect and improving the user experience. .
可以理解的是,本发明可用于众多通用或专用的计算系统环境或配置中。例如:个人计算机、服务器计算机、手持设备或便携式设备、平板型设备、多处理器系统、基于微处理器的系统、置顶盒、可编程的消费电子设备、网络PC、小型计算机、大型计算机、包括以上任何系统或设备的分布式计算环境等等。It will be appreciated that the present invention is applicable to a wide variety of general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor based systems, set-top boxes, programmable consumer electronics devices, network PCs, small computers, mainframe computers, including A distributed computing environment of any of the above systems or devices, and the like.
本发明可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本发明,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。The invention may be described in the general context of computer-executable instructions executed by a computer, such as a program module. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types. The invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are connected through a communication network. In a distributed computing environment, program modules can be located in both local and remote computer storage media including storage devices.
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个......”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。 It should be noted that, in this context, relational terms such as first and second are used merely to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply such entities or operations. There is any such actual relationship or order between them. Furthermore, the term "comprises" or "comprises" or "comprises" or any other variations thereof is intended to encompass a non-exclusive inclusion, such that a process, method, article, or device that comprises a plurality of elements includes not only those elements but also Other elements, or elements that are inherent to such a process, method, item, or device. An element that is defined by the phrase "comprising a ..." does not exclude the presence of additional equivalent elements in the process, method, item, or device that comprises the element.
以上所述仅是本发明的具体实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本发明的保护范围。 The above is only a specific embodiment of the present invention, and it should be noted that those skilled in the art can also make several improvements and retouchings without departing from the principles of the present invention. It should be considered as the scope of protection of the present invention.

Claims (13)

  1. 一种页面排版方法,其特征在于,包括:A page layout method, comprising:
    确定终端显示区域可以容纳的字数;Determining the number of words that the terminal display area can accommodate;
    根据所述终端显示区域可以容纳的字数,将文章分成多个内容块;Dividing the article into a plurality of content blocks according to the number of words that the terminal display area can accommodate;
    将所述多个内容块加载到对应的内容容器;Loading the plurality of content blocks into a corresponding content container;
    确定当前页面容器及其对应内容容器,其中,所述当前页面容器的尾部存在空行;Determining a current page container and a corresponding content container thereof, wherein a blank line exists at a tail of the current page container;
    将所述对应内容容器插入到所述页面容器中;Inserting the corresponding content container into the page container;
    将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器,填充所述空行;以及Inserting the next content container immediately adjacent to the corresponding content container into the current page container, filling the blank line;
    对当前页面容器进行排版。Typeset the current page container.
  2. 根据权利要求1所述的页面排版方法,其特征在于,所述方法还包括:The page layout method according to claim 1, wherein the method further comprises:
    计算当前页面容器的偏移量;Calculate the offset of the current page container;
    累计所述偏移量,得到累计偏移量;Accumulating the offset to obtain a cumulative offset;
    将当前页面容器的下一个页面容器作为当前页面容器,根据所述累计偏移量调整当前页面容器中内容容器的显示内容。The next page container of the current page container is used as the current page container, and the display content of the content container in the current page container is adjusted according to the accumulated offset.
  3. 根据权利要求2所述的页面排版方法,其特征在于,根据所述累计偏移量调整所述当前页面容器中内容容器的显示内容,包括:The page layout method according to claim 2, wherein the display content of the content container in the current page container is adjusted according to the accumulated offset, including:
    判断所述累计偏移量是否小于当前页面容器对应的内容容器的高度;Determining whether the accumulated offset is smaller than a height of a content container corresponding to the current page container;
    当所述累计偏移量小于当前页面容器对应的内容容器的高度时,将所述页面容器中的内容容器按照所述累计偏移量向上偏移;When the accumulated offset is smaller than the height of the content container corresponding to the current page container, the content container in the page container is offset upward according to the accumulated offset;
    当所述累计偏移量大于或者等于当前页面容器对应的内容容器的高度时,删除当前页面容器。When the accumulated offset is greater than or equal to the height of the content container corresponding to the current page container, the current page container is deleted.
  4. 根据权利要求1所述的页面排版方法,其特征在于,在将所述对应内容容器插入到当前页面容器中之后,将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器之前,所述方法还包括: The page layout method according to claim 1, wherein after inserting the corresponding content container into the current page container, inserting the next content container immediately adjacent to the corresponding content container into the current page container The method also includes:
    判断所述对应内容容器与当前页面容器的高度是否相等;Determining whether the heights of the corresponding content container and the current page container are equal;
    如果所述对应内容容器与当前页面容器的高度相等,执行对当前页面容器进行排版的操作;If the corresponding content container is equal in height to the current page container, performing an operation of formatting the current page container;
    如果所述对应内容容器与当前页面容器的高度不相等,执行将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器的操作。If the height of the corresponding content container and the current page container are not equal, performing an operation of inserting the next content container immediately adjacent to the corresponding content container into the current page container.
  5. 根据权利要求1至4中任一项所述的页面排版方法,其特征在于,确定终端显示区域可以容纳的字数,包括:The page layout method according to any one of claims 1 to 4, characterized in that the number of words that the terminal display area can accommodate is determined, including:
    当所述文章为双字节字符时,获取字符的字号;根据字号与像素的对应关系确定字符的宽度;根据所述宽度计算可以容纳的字数;When the article is a double-byte character, obtaining a font size of the character; determining a width of the character according to a correspondence between the font size and the pixel; and calculating a number of words that can be accommodated according to the width;
    当所述文章为单字节字符时,获取字母的平均宽度;通过所述平均宽度计算可以容纳的字母数。When the article is a single-byte character, the average width of the letter is obtained; the number of letters that can be accommodated is calculated by the average width.
  6. 一种页面排版方法,其特征在于,包括:A page layout method, comprising:
    确定终端显示区域可以容纳的字数;Determining the number of words that the terminal display area can accommodate;
    根据所述终端显示区域可以容纳的字数将文章分成多个内容块;Dividing the article into a plurality of content blocks according to the number of words that the terminal display area can accommodate;
    将所述多个内容块中的每个内容块加载到对应的内容容器;Loading each of the plurality of content blocks into a corresponding content container;
    将每个内容容器插入到对应的页面容器中;Insert each content container into the corresponding page container;
    除最后一个页面容器,在每个页面容器中,插入下一个页面容器中的内容容器;In addition to the last page container, in each page container, insert the content container in the next page container;
    确定当前页面容器,其中,所述当前页面容器的尾部存在空行,通过插入下一个页面容器中的内容容器填充所述空行;Determining a current page container, wherein a blank line exists at a tail of the current page container, and the blank line is filled by inserting a content container in a next page container;
    对当前页面容器进行排版;Typesetting the current page container;
    计算当前页面容器的偏移量;Calculate the offset of the current page container;
    累计所述偏移量,得到累计偏移量;Accumulating the offset to obtain a cumulative offset;
    将当前页面容器的下一个页面容器作为当前页面容器,根据所述累计偏移量对当前页面容器进行排版;Using the next page container of the current page container as the current page container, and formatting the current page container according to the accumulated offset;
    判断所述当前页面容器是否为最后一个页面内容容器;Determining whether the current page container is the last page content container;
    当所述当前页面容器并非最后一个页面容器时,重复执行计算当前页面容器的偏移量的操作; When the current page container is not the last page container, the operation of calculating the offset of the current page container is repeatedly performed;
    当所述当前页面容器是最后一个页面容器时,不执行任何操作。When the current page container is the last page container, no action is taken.
  7. 一种页面排版装置,其特征在于,包括处理器,所述处理器用于执行以下程序单元:A page layout apparatus, comprising: a processor, wherein the processor is configured to execute the following program unit:
    第一确定单元:用于计算终端显示区域可以容纳的字数;a first determining unit: configured to calculate a number of words that the terminal display area can accommodate;
    分页单元,用于根据终端显示区域可以容纳的字数,将文章分成若干内容块;a paging unit, configured to divide the article into a plurality of content blocks according to the number of words that the terminal display area can accommodate;
    加载单元,用于将内容块加载到对应的内容容器;a loading unit for loading a content block into a corresponding content container;
    第二确定单元,用于确定当前页面容器及其对应内容容器,其中,所述当前页面容器存在空行;a second determining unit, configured to determine a current page container and a corresponding content container thereof, wherein the current page container has a blank line;
    第一插入单元,用于将所述对应内容容器插入到页面容器中;a first insertion unit, configured to insert the corresponding content container into a page container;
    第二插入单元,用于将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器,填充所述当前页面容器的空行;a second insertion unit, configured to insert a next content container adjacent to the corresponding content container into a current page container, and fill a blank line of the current page container;
    排版单元,用于对当前页面容器进行排版。A typesetting unit for formatting a current page container.
  8. 根据权利要求7所述的页面排版装置,其特征在于,还包括:The page layout device according to claim 7, further comprising:
    计算单元,用于计算当前页面容器的偏移量;a calculation unit for calculating an offset of the current page container;
    累计单元,用于累计所述偏移量,得到累计偏移量;a cumulative unit for accumulating the offset to obtain a cumulative offset;
    调整单元,用于将当前页面容器的下一个页面容器作为当前页面容器,根据所述累计偏移量调整当前页面容器中内容容器的显示内容。The adjusting unit is configured to use the next page container of the current page container as the current page container, and adjust the display content of the content container in the current page container according to the accumulated offset.
  9. 根据权利要求7所述的页面排版装置,其特征在于,所述装置还包括判断单元,The page layout device according to claim 7, wherein the device further comprises a determination unit,
    所述判断单元:用于判断所述对应内容容器与当前页面容器的高度是否相等;The determining unit is configured to determine whether the heights of the corresponding content container and the current page container are equal;
    所述第二插入单元:还用于当所述对应内容容器与当前页面容器的高度不相等时,将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器;The second insertion unit is further configured to: insert the next content container immediately adjacent to the corresponding content container into the current page container when the height of the corresponding content container is not equal to the current page container;
    所述排版单元:还用于当所述对应内容容器与当前页面容器的高度相等时,对当前页面容器进行排版。The typesetting unit is further configured to perform layout on the current page container when the corresponding content container is equal in height to the current page container.
  10. 一种页面排版装置,其特征在于,包括处理器,所述处理器用于执行以下程序单元:A page layout apparatus, comprising: a processor, wherein the processor is configured to execute the following program unit:
    第一确定单元,用于确定终端显示区域可以容纳的字数; a first determining unit, configured to determine a number of words that the terminal display area can accommodate;
    分页单元,用于根据终端显示区域可以容纳的字数,将文章分成若干内容块;a paging unit, configured to divide the article into a plurality of content blocks according to the number of words that the terminal display area can accommodate;
    加载单元,用于将内容块加载到对应的内容容器;a loading unit for loading a content block into a corresponding content container;
    第一插入单元,用于将每个内容容器插入到页面容器中;a first insertion unit for inserting each content container into the page container;
    第二插入单元,用于除最后一个页面容器,在每个页面容器中,插入下一个页面容器中的内容容器;a second insertion unit, configured to insert a content container in the next page container in each page container except the last page container;
    第二确定单元,用于确定当前页面容器,其中,所述当前页面容器存在空行,通过插入下一个页面容器中的内容容器填充所述当前页面容器的空行;a second determining unit, configured to determine a current page container, wherein the current page container has a blank line, and the blank line of the current page container is filled by inserting a content container in the next page container;
    第一排版单元,用于对当前页面容器进行排版;a first typesetting unit for formatting a current page container;
    计算单元,用于计算当前页面容器的偏移量;a calculation unit for calculating an offset of the current page container;
    累计单元,用于累计所述偏移量,得到累计偏移量;a cumulative unit for accumulating the offset to obtain a cumulative offset;
    第二排版单元,用于将当前页面容器的下一个页面容器作为当前页面容器,根据所述累计偏移量对当前页面容器进行排版;a second typesetting unit, configured to use a next page container of the current page container as a current page container, and typeset the current page container according to the accumulated offset;
    判断单元,用于判断所述当前页面容器是否为最后一个容器;a determining unit, configured to determine whether the current page container is the last container;
    当所述当前页面容器并非最后一个页面容器,所述计算单元,还用于计算当前页面容器的偏移量。When the current page container is not the last page container, the calculation unit is further configured to calculate an offset of the current page container.
  11. 一种具有处理器可执行的程序代码的计算机可读介质,其特征在于,在被执行时,所述程序代码使得处理器执行下述步骤:A computer readable medium having processor-executable program code, wherein, when executed, the program code causes a processor to perform the steps of:
    确定终端显示区域可以容纳的字数;Determining the number of words that the terminal display area can accommodate;
    根据所述终端显示区域可以容纳的字数,将文章分成多个内容块;Dividing the article into a plurality of content blocks according to the number of words that the terminal display area can accommodate;
    将所述多个内容块加载到对应的内容容器;Loading the plurality of content blocks into a corresponding content container;
    确定当前页面容器及其对应内容容器,其中,所述当前页面容器存在空行;Determining a current page container and a corresponding content container thereof, wherein the current page container has a blank line;
    将所述对应内容容器插入到所述页面容器中;Inserting the corresponding content container into the page container;
    将紧邻所述对应内容容器的下一个内容容器插入到当前页面容器,填充所述当前页面容器的空行;以及Inserting a next content container immediately adjacent to the corresponding content container into the current page container, filling in the blank line of the current page container;
    对当前页面容器进行排版。Typeset the current page container.
  12. 一种具有处理器可执行的程序代码的计算机可读介质,其特征在于,在被执行时,所述程序代码使得处理器执行下述步骤: A computer readable medium having processor-executable program code, wherein, when executed, the program code causes a processor to perform the steps of:
    确定终端显示区域可以容纳的字数;Determining the number of words that the terminal display area can accommodate;
    根据所述终端显示区域可以容纳的字数将文章分成多个内容块;Dividing the article into a plurality of content blocks according to the number of words that the terminal display area can accommodate;
    将所述多个内容块中的每个内容块加载到对应的内容容器;Loading each of the plurality of content blocks into a corresponding content container;
    将每个内容容器插入到对应的页面容器中;Insert each content container into the corresponding page container;
    除最后一个页面容器,在每个页面容器中,插入下一个页面容器中的内容容器;In addition to the last page container, in each page container, insert the content container in the next page container;
    确定当前页面容器,其中,所述当前页面容器存在空行,通过插入下一个页面容器中的内容容器填充所述当前页面容器的空行;Determining a current page container, wherein the current page container has a blank line, and filling a blank line of the current page container by inserting a content container in a next page container;
    对当前页面容器进行排版;Typesetting the current page container;
    计算当前页面容器的偏移量;Calculate the offset of the current page container;
    累计所述偏移量,得到累计偏移量;Accumulating the offset to obtain a cumulative offset;
    将当前页面容器的下一个页面容器作为当前页面容器,根据所述累计偏移量对当前页面容器进行排版;Using the next page container of the current page container as the current page container, and formatting the current page container according to the accumulated offset;
    判断所述当前页面容器是否为最后一个容器;Determining whether the current page container is the last container;
    当所述当前页面容器并非最后一个页面容器时,重复执行计算当前页面容器的偏移量的操作;When the current page container is not the last page container, the operation of calculating the offset of the current page container is repeatedly performed;
    当所述当前页面容器是最后一个页面容器时,不执行任何操作。When the current page container is the last page container, no action is taken.
  13. 一种计算机程序,其特征在于,用于执行权利要求1至6中任一项所述的页面排版方法。 A computer program for performing the page layout method according to any one of claims 1 to 6.
PCT/CN2014/090868 2014-05-29 2014-11-12 Page layout method and device WO2015180422A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410235926.9 2014-05-29
CN201410235926.9A CN105224540A (en) 2014-05-29 2014-05-29 Page composing method and device

Publications (1)

Publication Number Publication Date
WO2015180422A1 true WO2015180422A1 (en) 2015-12-03

Family

ID=54698011

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/090868 WO2015180422A1 (en) 2014-05-29 2014-11-12 Page layout method and device

Country Status (2)

Country Link
CN (1) CN105224540A (en)
WO (1) WO2015180422A1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111177602A (en) * 2019-12-04 2020-05-19 思齐芙蓉教育集团(湖南)有限公司 Method and system for paging typesetting of webpage content
CN111223477A (en) * 2018-11-23 2020-06-02 珠海格力电器股份有限公司 Method and device for topic upward movement during man-machine interaction
CN112131840A (en) * 2020-09-17 2020-12-25 中消云(北京)物联网科技研究院有限公司 Page processing method, device, storage medium and processor
CN114528063A (en) * 2022-04-21 2022-05-24 苏州万店掌网络科技有限公司 Page display method, device, equipment and storage medium
CN115795192A (en) * 2022-06-30 2023-03-14 盐城金堤科技有限公司 Page adaptation method and device, storage medium and electronic equipment

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106503041B (en) * 2016-09-19 2019-11-15 曙光信息产业(北京)有限公司 Page layout self-adaptive method and system
CN106708985B (en) * 2016-12-12 2020-08-18 北京奇虎科技有限公司 Layout method and device for multi-column webpage
CN109408162A (en) * 2018-09-03 2019-03-01 平安普惠企业管理有限公司 A kind of method and terminal showing the page
CN112083899A (en) * 2020-09-10 2020-12-15 深圳开立生物医疗科技股份有限公司 Medical report printing method and device, ultrasonic equipment and medium
CN114579241A (en) * 2022-03-02 2022-06-03 湖南快乐阳光互动娱乐传媒有限公司 Page rendering method, device and system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101615175A (en) * 2009-08-11 2009-12-30 深圳市五巨科技有限公司 A kind of system and method for reading electronic book of mobile terminal
CN102479176A (en) * 2010-11-30 2012-05-30 汉王科技股份有限公司 Fast-approaching typesetting method and device of electronic reader
CN103150302A (en) * 2013-03-19 2013-06-12 北京小米科技有限责任公司 Type setting method and device
CN103593333A (en) * 2013-10-16 2014-02-19 小米科技有限责任公司 Electronic book document processing method, terminal and electronic equipment

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101763407B (en) * 2009-11-19 2012-05-30 青岛海信移动通信技术股份有限公司 Txt file reading method based on brew platform and reader thereof
CN102156716B (en) * 2010-12-02 2013-01-02 广州市动景计算机科技有限公司 Method and device for re-typesetting web page
JP5675445B2 (en) * 2011-03-09 2015-02-25 キヤノン株式会社 Information processing apparatus, information processing apparatus control method, and computer program

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101615175A (en) * 2009-08-11 2009-12-30 深圳市五巨科技有限公司 A kind of system and method for reading electronic book of mobile terminal
CN102479176A (en) * 2010-11-30 2012-05-30 汉王科技股份有限公司 Fast-approaching typesetting method and device of electronic reader
CN103150302A (en) * 2013-03-19 2013-06-12 北京小米科技有限责任公司 Type setting method and device
CN103593333A (en) * 2013-10-16 2014-02-19 小米科技有限责任公司 Electronic book document processing method, terminal and electronic equipment

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111223477A (en) * 2018-11-23 2020-06-02 珠海格力电器股份有限公司 Method and device for topic upward movement during man-machine interaction
CN111223477B (en) * 2018-11-23 2023-01-24 珠海格力电器股份有限公司 Method and device for topic upward movement during man-machine interaction
CN111177602A (en) * 2019-12-04 2020-05-19 思齐芙蓉教育集团(湖南)有限公司 Method and system for paging typesetting of webpage content
CN112131840A (en) * 2020-09-17 2020-12-25 中消云(北京)物联网科技研究院有限公司 Page processing method, device, storage medium and processor
CN114528063A (en) * 2022-04-21 2022-05-24 苏州万店掌网络科技有限公司 Page display method, device, equipment and storage medium
CN114528063B (en) * 2022-04-21 2022-07-12 苏州万店掌网络科技有限公司 Page display method, device, equipment and storage medium
CN115795192A (en) * 2022-06-30 2023-03-14 盐城金堤科技有限公司 Page adaptation method and device, storage medium and electronic equipment
CN115795192B (en) * 2022-06-30 2024-04-05 盐城天眼察微科技有限公司 Page adaptation method and device, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN105224540A (en) 2016-01-06

Similar Documents

Publication Publication Date Title
WO2015180422A1 (en) Page layout method and device
CN105975576B (en) Terminal content adaptive display method and device and terminal
US9471550B2 (en) Method and apparatus for document conversion with font metrics adjustment for format compatibility
KR101955732B1 (en) Associating captured image data with a spreadsheet
CN104820589B (en) A kind of method and its device of dynamic adaptation webpage
CN102184249B (en) Based on webpage layout method and the device of mobile terminal
CN110879937A (en) Method and device for generating webpage from document, computer equipment and storage medium
EP2506153A2 (en) A method for users to create and edit web page layouts
US20140215314A9 (en) Method for rearranging web page
US9465780B2 (en) User terminal device and scroll method supporting high-speed web scroll of web document
CN103605783B (en) Webpage display process and device
CN105069060B (en) HTML document paging typesetting method
AU2016277770B2 (en) Use of bloom filters to simplify dynamic font augmentation and subsetting
CN107885792B (en) Webpage article display method, device and system
JP2013511088A (en) Platform independent typesetting support for documentation
CN110162773B (en) Title clipper
CN111309671A (en) Method, device and storage medium for exporting PDF (Portable document Format) of web report
CN103577171A (en) Webpage content displaying method and mobile terminal
CN105205077A (en) Page layout method, device and system
US20240143898A1 (en) Content typesetting method and apparatus, computer device, and storage medium
US10346511B2 (en) Scalable content rendering
CN114625996A (en) Webpage content paging method and device, electronic equipment and readable storage medium
CN106776527B (en) Electronic book data display method and device and terminal equipment
CN111783007B (en) Display rendering method and device, electronic equipment and storage medium
CN112433995A (en) File format conversion method, system, computer equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14892997

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 15.03.2017)

122 Ep: pct application non-entry in european phase

Ref document number: 14892997

Country of ref document: EP

Kind code of ref document: A1