CN110795914B - Method and device for converting PDF document into picture and electronic equipment - Google Patents

Method and device for converting PDF document into picture and electronic equipment Download PDF

Info

Publication number
CN110795914B
CN110795914B CN201810779986.5A CN201810779986A CN110795914B CN 110795914 B CN110795914 B CN 110795914B CN 201810779986 A CN201810779986 A CN 201810779986A CN 110795914 B CN110795914 B CN 110795914B
Authority
CN
China
Prior art keywords
page
target
width
height
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810779986.5A
Other languages
Chinese (zh)
Other versions
CN110795914A (en
Inventor
邓斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Guangzhou Kingsoft Mobile Technology Co Ltd
Original Assignee
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Guangzhou Kingsoft Mobile Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Office Software Inc, Zhuhai Kingsoft Office Software Co Ltd, Guangzhou Kingsoft Mobile Technology Co Ltd filed Critical Beijing Kingsoft Office Software Inc
Priority to CN201810779986.5A priority Critical patent/CN110795914B/en
Publication of CN110795914A publication Critical patent/CN110795914A/en
Application granted granted Critical
Publication of CN110795914B publication Critical patent/CN110795914B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Processing Or Creating Images (AREA)

Abstract

The embodiment of the invention provides a method, a device and electronic equipment for converting PDF documents into pictures, and relates to the technical field of data conversion, wherein the method comprises the following steps: and determining the target height and the target width according to the height and the width of each PDF document, applying for a target memory with the size of the target width from the running memory, storing each page in the PDF document into the target memory, converting the data in the target memory into a picture file, and storing the picture file into a disk. Therefore, the embodiment of the invention can convert the PDF document into a long picture, and is convenient for a user to manage the picture converted by the PDF document.

Description

Method and device for converting PDF document into picture and electronic equipment
Technical Field
The present invention relates to the field of data conversion technologies, and in particular, to a method and an apparatus for converting a PDF document into a picture, and an electronic device.
Background
The portable document format (Portable Document Format, PDF) may encapsulate text, fonts, formats, colors, and graphic images independent of device and resolution, etc. in one file.
In the prior art, the method for converting the PDF document into the picture mainly comprises the following steps: and acquiring each page of the PDF document, and converting each page into a picture.
The inventors have found that in the process of implementing the present invention, at least the following problems exist in the prior art:
this conversion method of the prior art is to actually convert one PDF document into a plurality of picture files of the same number as the number of pages. When the management operation is performed, a plurality of picture files need to be managed respectively, which is inconvenient.
For example: a PDF document file containing 100 pages is converted into 100 picture files. When the 100 picture files are transferred to other folders, the transfer operation needs to be performed on the 100 picture files respectively, which is inconvenient.
Therefore, the prior art cannot realize convenient document management for the conversion method of PDF documents.
Disclosure of Invention
The embodiment of the invention aims to provide a method and a device for converting PDF documents into pictures and electronic equipment, so that convenience is brought to a user in managing the pictures converted from PDF documents. The specific technical scheme is as follows:
In a first aspect, there is provided a method of converting a PDF document into a picture, the method comprising:
Acquiring the height and width of each page in a PDF document to be converted; the height is the length of the page in the vertical direction, and the width is the length of the page in the horizontal direction;
Determining a target height and a target width;
Applying for a target memory space with the target width from the running memory;
Storing each page of data in the document into a target memory space with the target height and the target width according to the sequence;
And converting the data in the target memory space into a picture file and storing the picture file into a disk storage.
Optionally, the step of determining the target height and the target width includes:
adding the heights of each page, and determining the result as a target height;
comparing the width of each page, and determining the maximum width as a target width;
or, the step of determining the target height and the target width includes:
adding the width of each page, and determining the result as a target width;
the heights of each page are compared, and the maximum one height is determined as the target height.
Optionally, the step of storing each page in the document in the memory with the target height and the target width in sequence includes:
Acquiring page number sequences of pages in the document;
And storing each page in the document into the memory according to a preset splicing mode.
Optionally, the step of storing each page in the document in the memory according to a preset splicing manner includes:
acquiring typesetting directions of the contents of all pages in the document;
Selecting an unselected page in sequence, and determining the unselected page as a current page;
according to a preset first alignment mode, the typesetting direction of the current page is consistent with that of the previous page, and the width of the current page is spliced with that of the previous page and is stored in the memory; the preset first alignment mode comprises the following steps: left alignment, right alignment, or centered alignment;
Returning to the step of sequentially selecting one unselected page and determining the unselected page as the current page until all pages in the PDF document are stored in the memory;
Or, according to a preset splicing algorithm, the step of storing each page in the document into the memory in sequence includes:
acquiring typesetting directions of the contents of all pages in the document;
Selecting an unselected page in sequence, and determining the unselected page as a current page;
According to a preset second alignment mode, the typesetting direction of the current page is consistent with that of the previous page, and the height of the current page is spliced with that of the previous page and is stored in the memory; the preset second alignment mode comprises the following steps: upper alignment, lower alignment, or centered alignment;
and returning to the step of sequentially selecting one unselected page and determining the unselected page as the current page until all pages in the PDF document are stored in the memory.
Optionally, the step of converting the data in the target memory space into a picture file and storing the picture file in the disk storage includes:
encoding the data in the target memory space into a picture format;
calling a system writing file interface;
Storing the encoded data in a disk.
In a second aspect, there is provided an apparatus for converting a PDF document into a picture, the apparatus comprising:
The acquisition module is used for acquiring the height and the width of each page in the PDF document to be converted; the height is the length of the page in the vertical direction, and the width is the length of the page in the horizontal direction;
the determining module is used for determining the target height and the target width;
The application module is used for applying the target height to the running memory for the target memory space with the target width;
the storage module is used for sequentially storing each page of data in the document into a target memory space with the target height and the target width;
And the conversion module is used for converting the data in the target memory space into a picture file and storing the picture file into a disk storage.
Optionally, the determining module includes: a first target height determining unit and a first target width determining unit;
the first target height determining unit is used for adding the heights of the pages and determining the result as a target height;
The first target width determining unit is used for comparing the width of each page and determining the largest width as a target width;
or, the determining module includes: a second target width determining unit and a second target height determining unit;
The second target width determining unit is used for adding the width of each page and determining the result as a target width;
the second target height determining unit is used for comparing the heights of each page and determining the maximum height as the target height.
Optionally, the storage module includes: a page number order acquisition unit and a storage unit;
the page sequence acquisition unit is used for acquiring page sequence of pages in the document;
the storage unit is used for storing each page in the document into the memory according to a preset splicing mode.
Optionally, the storage unit includes: the first typesetting direction obtaining subunit, the first selecting subunit, the first splicing subunit and the first calling subunit;
the first typesetting direction acquisition subunit is used for acquiring typesetting directions of contents of all pages in the document;
the first selecting subunit is configured to sequentially select an unselected page, and determine the unselected page as a current page;
The first splicing subunit is used for splicing the width of the current page and the width of the last page which are not spliced according to a preset first alignment mode and consistent typesetting direction of the current page and the last page, and storing the spliced width of the current page and the spliced width of the last page into the memory; the preset first alignment mode comprises the following steps: left alignment, right alignment, or centered alignment;
The first calling subunit is used for calling the first selecting subunit until all pages in the PDF document are stored in the memory;
Or, the storage unit includes: the second typesetting direction obtaining subunit, the second selecting subunit, the second splicing subunit and the second calling subunit;
The second typesetting direction obtaining subunit is used for obtaining typesetting directions of contents of all pages in the document;
the second selecting subunit is configured to sequentially select an unselected page, and determine the unselected page as a current page;
The second splicing subunit is used for splicing the height of the current page and the height of the un-spliced upper page and storing the height into the memory according to a preset second alignment mode, wherein the typesetting direction of the current page and the typesetting direction of the upper page are consistent; the preset second alignment mode comprises the following steps: upper alignment, lower alignment, or centered alignment;
The second calling subunit is configured to call the second selecting subunit until all pages in the PDF document are stored in the memory.
Optionally, the conversion module includes: the device comprises an encoding unit, a calling unit and a saving unit;
The encoding unit is used for encoding the data in the target memory space into a picture format;
the calling unit is used for calling a system write file interface;
the storage unit is used for storing the encoded data into a magnetic disk.
In a third aspect, an electronic device is provided, the electronic device including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory perform communication with each other through the communication bus;
A memory for storing a computer program;
and the processor is used for realizing the method for converting any PDF document into a picture when executing the program stored in the memory.
In a fourth aspect, an embodiment of the present invention further provides a computer readable storage medium, where a computer program is stored, where the computer program when executed by a processor implements the steps of the method for converting any PDF document into a picture.
According to the method, the device and the electronic equipment for converting the PDF document into the picture, the target height and the target width can be determined according to the height and the width of each PDF document, a memory with the size equal to the target width is applied to the running memory, each page in the PDF document is stored in the memory, and data in the memory is converted into a picture file and is stored in a magnetic disk. Therefore, the embodiment of the invention can convert the PDF document into a long picture, and is convenient for a user to manage the picture converted by the PDF document.
Of course, it is not necessary for any one product or method of practicing the invention to achieve all of the advantages set forth above at the same time.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings which are used in the description of the embodiments or the prior art will be briefly described, it being obvious that the drawings in the description below are only some embodiments of the invention, and that other drawings can be obtained from these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a method for converting a PDF document into a picture according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for determining a target height and a target width in a method for converting a PDF document into a picture according to an embodiment of the present invention;
FIG. 3 is another flowchart of a method for determining a target height and a target width in a method for converting a PDF document into a picture according to an embodiment of the present invention;
FIG. 4 is a flowchart of a method for storing pages in a memory in a method for converting a PDF document into a picture according to an embodiment of the present invention;
FIG. 5 is another flowchart of a method for storing pages in a memory in a method for converting a PDF document into a picture according to an embodiment of the present invention;
Fig. 6 is a flowchart of a conversion method in a method for converting a PDF document into a picture according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a device for converting a PDF document into a picture according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The following description of the technical solutions according to the embodiments of the present invention will be given with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The embodiment of the invention provides a method and a device for converting a PDF document into a picture and electronic equipment.
In the embodiment of the invention, the electronic equipment can be any electronic equipment such as a computer, a mobile phone and a tablet personal computer which can process PDF format files.
Referring to fig. 1, fig. 1 is a flowchart of a method for converting a PDF document into a picture according to an embodiment of the present invention, including the following steps:
Step 101, acquiring the height and width of each page in a PDF document to be converted; the height is the length of the page in the vertical direction, and the width is the length of the page in the horizontal direction.
In one implementation, attribute information of each page may be obtained from a PDF file, where the attribute information includes a height and a width of each page.
Step 102, determining the target height and the target width.
In one implementation, all page heights may be added, determined to be the target height, and the largest one page width determined to be the target width; in another implementation, all page widths may be added, determined to be the target width, and the largest one height determined to be the target height.
Step 103, applying for a target memory space with a target height and a target width from the running memory.
In one implementation, a program applies for a target memory space of a size that is a multiplication of a target height and a target width from a running memory of an electronic device.
Step 104, storing each page of data in the document into a target memory space with a target height and a target width according to the sequence.
Specifically, the method for sequentially storing each page of data in the document into the target memory space with the target height and the target width may include:
acquiring page number sequences of pages in a document;
And storing each page in the document into the memory according to the sequence according to a preset splicing mode.
In one implementation, according to page number sequence of pages in a PDF document, storing each page in the document into an applied memory according to sequence in a vertical splicing mode, wherein the width of each page is connected with the width of the last page.
Step 105, converting the data in the target memory space into a picture file and storing the picture file in the disk storage.
In one implementation, the format of the picture file may be: a joint image experts group (Joint Photographic Experts Group, JPEG) format.
Therefore, by applying the method for converting the PDF document into the picture provided by the embodiment of the invention, the target height and the target width can be determined according to the height and the width of each PDF document, a memory with the size equal to the target width is applied to the running memory, each page in the PDF document is stored in the memory, and the data in the memory is converted into the picture file and is stored in the disk. Therefore, the embodiment of the invention can convert the PDF document into a long picture, and is convenient for a user to manage the picture converted by the PDF document. In addition, when the text content in the PDF document is identified, the text content in the document needs to be identified page by page, so that the consumption time is long, the use is inconvenient, and after the PDF document is converted into one picture, the speed is high and the use is convenient compared with the identification before the conversion when the text identification is carried out on the one picture.
Further, referring to fig. 2, fig. 2 is a flowchart of a method for determining a target height and a target width in a method for converting a PDF document into a picture according to an embodiment of the present invention;
When the pages in the PDF document are vertically spliced, the method for determining the target height and the target width can comprise the following steps:
step 201, the height of each page is added, and the result is determined as the target height.
Here, in order to reduce the memory footprint, the result of adding each page height may be determined as the target height in the above-described method, but if the memory footprint reduction is not considered, a length larger than the result of adding each page height may be determined as the target height.
Step 202, comparing the width of each page, and determining the maximum width as the target width.
Similarly, in order to reduce the memory footprint, the maximum one width may be determined as the target width according to the above method, and, if the memory footprint is not considered to be reduced, a length larger than the maximum one width may be determined as the target height.
Here, since the contents of each page in the PDF document are different, the height and width of each page in the PDF document may be different by the program at the time of generating the PDF document; in addition, the page size in the PDF document can also be set by the user, so the height and width of each page in the PDF document will also be different accordingly.
Therefore, by applying the method for converting the PDF document into the picture, the target height and the target width of the memory required to be occupied during vertical splicing can be determined under the condition of reducing the memory occupation as much as possible.
Referring to fig. 3, fig. 3 is another flowchart of a method for determining a target height and a target width in a method for converting a PDF document into a picture according to an embodiment of the present invention;
When the pages in the PDF document are horizontally spliced, the method for determining the target height and the target width can comprise the following steps:
step 301, the width of each page is added, and the result is determined as the target width.
Step 302, comparing the heights of each page, and determining the maximum height as the target height.
The principle of determining the target height and the target width by the horizontal splicing is the same as that of the vertical splicing, so that the description is simpler, and the relevant parts are only needed by referring to the part of the description of the embodiment of the method for determining the target height and the target width by the vertical splicing.
Therefore, by applying the method for converting the PDF document into the picture, the target height and the target width of the memory to be occupied in horizontal splicing can be determined under the condition of reducing the memory occupation as much as possible.
FIG. 4 is a flowchart of a method for storing pages in a document in a memory in a method for converting a PDF document into a picture according to an embodiment of the present invention;
If the PDF document is vertically spliced, the method for storing the pages in the document into the memory can comprise the following steps:
step 401, obtaining typesetting direction of contents of each page in the document.
Optionally, when the splicing is performed, the typesetting direction of each page needs to be ensured to be consistent, and if the typesetting directions are inconsistent, the problems of inconvenient reading or inconvenient recognition and the like may be caused.
In one implementation, attribute information of the page can be obtained in the PDF file, where the attribute information includes a typesetting direction of the page content.
In step 402, an unselected page is sequentially selected and determined to be the current page.
In one implementation, to avoid repeatedly stitching the same page, an unselected page needs to be selected when the page is selected; meanwhile, in order to facilitate management or reading, the pages in the PDF document need to be spliced in sequence.
Step 403, according to a preset first alignment mode, the typesetting direction of the current page is consistent with that of the previous page, and the width of the current page is spliced with the width of the previous page which is not spliced, and the spliced width is stored in a memory; the presetting of the first alignment mode comprises the following steps: left aligned, right aligned, or centered aligned.
In one implementation, after the previous page is stored in the memory, the width of the current page and the width of the previous page are spliced according to the typesetting direction same as that of the previous page and stored in the memory.
Here, since the size of each page of the PDF document may be different, when the current page is different from the previous page in the splicing process, an alignment mode needs to be set, and the alignment mode may be set by a user or may be a default alignment mode of a program.
And step 404, selecting one unselected page in sequence, determining the unselected page as the current page, according to a preset first alignment mode, matching the typesetting direction of the current page with the typesetting direction of the previous page, splicing the width of the current page with the width of the previous page, and storing the spliced width into a memory until all pages in the PDF document are stored into the memory.
In one implementation, according to the page number sequence in the PDF document, selecting the next unselected page, determining the page as the current page, and according to the typesetting direction same as that of the previous page, splicing the width of the current page with the width of the previous page and storing the same in a memory; if the current page is the last page in the PDF document, the next page is not selected after the current page is stored in the memory, and the next operation of storing the data in the memory into the disk is executed.
Therefore, by applying the method for converting the PDF document into the picture, the pages of the PDF document can be vertically spliced, different requirements of users can be met, an alignment mode can be set according to the requirements of the users, and the spliced pages are convenient for the users to read and use according to the sequence in the PDF document.
FIG. 5 is another flowchart of a method for storing pages in a document in a memory in a method for converting a PDF document into a picture according to an embodiment of the invention;
If the PDF document is horizontally spliced, the method for storing the pages in the document into the memory can comprise the following steps:
Step 501, obtaining typesetting directions of contents of all pages in a document;
Step 502, selecting an unselected page in sequence, and determining the unselected page as a current page;
Step 503, according to a preset second alignment mode, the typesetting direction of the current page is consistent with that of the previous page, and the high of the current page and the high of the previous page which are not spliced are spliced and stored in a memory; the preset second alignment mode comprises the following steps: upper alignment, lower alignment, or centered alignment;
And 504, selecting one unselected page in sequence, determining the unselected page as the current page, matching the typesetting direction of the current page with the typesetting direction of the previous page according to a preset second alignment mode, splicing the high of the current page with the high of the previous page, and storing the spliced high of the current page and the spliced high of the previous page into a memory until all pages in the PDF document are stored into the memory.
Since the method embodiment of storing the pages in the document in the memory during the horizontal splicing is basically similar to the method embodiment of storing the pages in the document in the memory during the vertical splicing, the alignment mode of the horizontal splicing is different from that of the vertical splicing, so that the description is simpler, and the relevant points are referred to the partial description of the method embodiment of storing the pages in the document in the memory during the vertical splicing.
Therefore, by applying the method for converting the PDF document into the picture, which is provided by the embodiment of the invention, the pages of the PDF document can be transversely spliced, different requirements of users can be met, an alignment mode can be set according to the requirements of the users, and the spliced pages are convenient for the users to read and use according to the sequence in the PDF document.
Referring to fig. 6, fig. 6 is a flowchart of a conversion method in a method for converting a PDF document into a picture according to an embodiment of the present invention, which may include the following steps:
in step 601, data in the target memory space is encoded into a picture format.
Alternatively, the picture format may be of a wide variety, for example: a joint image experts group (Joint Photographic Experts Group, JPEG) format, a label image file format (TagImage FileFormat, TIFF) or a BitMap (BitMap, BMP).
Step 602, call system write file interface.
In one implementation, the write file interface API of the system may be called by a program.
And 603, storing the encoded data in a magnetic disk.
Here, since the encoded data is in a picture format, it is stored in a disk and then is in the form of a whole picture.
Therefore, by applying the method for converting the PDF document into the picture, the PDF document can be stored in the memory first, and then recoded into the picture format and stored in the disk, so that the operation of converting the PDF document into the picture is completed, and the method is simple to operate and convenient to use.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a device for converting a PDF document into a picture according to an embodiment of the present invention, where the device includes:
An acquiring module 701, configured to acquire a height and a width of each page in a PDF document to be converted; the height is the length of the page in the vertical direction, and the width is the length of the page in the horizontal direction;
A determining module 702 for determining a target height and a target width;
an application module 703, configured to apply a target memory space with the target width size to the running memory;
A storage module 704, configured to sequentially store each page of data in the document into a target memory space with the target height and the target width;
the conversion module 705 is configured to convert the data in the target memory space into a picture file, and store the picture file in the disk storage.
Specifically, the determining module 702 may include: a first target height determining unit and a first target width determining unit;
the first target height determining unit is used for adding the heights of the pages and determining the result as a target height;
The first target width determining unit is used for comparing the width of each page and determining the largest width as a target width;
Alternatively, the determining module 702 may include: a second target width determining unit and a second target height determining unit;
The second target width determining unit is used for adding the width of each page and determining the result as a target width;
the second target height determining unit is used for comparing the heights of each page and determining the maximum height as the target height.
Specifically, the storage module 704 may include: a page number order acquisition unit and a storage unit;
the page sequence acquisition unit is used for acquiring page sequence of pages in the document;
the storage unit is used for storing each page in the document into the memory according to a preset splicing mode.
Specifically, the storage unit may include: the first typesetting direction obtaining subunit, the first selecting subunit, the first splicing subunit and the first calling subunit;
the first typesetting direction acquisition subunit is used for acquiring typesetting directions of contents of all pages in the document;
the first selecting subunit is configured to sequentially select an unselected page, and determine the unselected page as a current page;
The first splicing subunit is used for splicing the width of the current page and the width of the last page which are not spliced according to a preset first alignment mode and consistent typesetting direction of the current page and the last page, and storing the spliced width of the current page and the spliced width of the last page into the memory; the preset first alignment mode comprises the following steps: left alignment, right alignment, or centered alignment;
The first calling subunit is used for calling the first selecting subunit until all pages in the PDF document are stored in the memory;
Or, the storage unit may include: the second typesetting direction obtaining subunit, the second selecting subunit, the second splicing subunit and the second calling subunit;
The second typesetting direction obtaining subunit is used for obtaining typesetting directions of contents of all pages in the document;
the second selecting subunit is configured to sequentially select an unselected page, and determine the unselected page as a current page;
The second splicing subunit is used for splicing the height of the current page and the height of the un-spliced upper page and storing the height into the memory according to a preset second alignment mode, wherein the typesetting direction of the current page and the typesetting direction of the upper page are consistent; the preset second alignment mode comprises the following steps: upper alignment, lower alignment, or centered alignment;
The second calling subunit is configured to call the second selecting subunit until all pages in the PDF document are stored in the memory.
Specifically, the conversion module 705 may include: the device comprises an encoding unit, a calling unit and a saving unit;
The encoding unit is used for encoding the data in the target memory space into a picture format;
the calling unit is used for calling a system write file interface;
the storage unit is used for storing the encoded data into a magnetic disk.
Therefore, the device for converting the PDF document into the picture can determine the target height and the target width according to the height and the width of each PDF document, apply for the memory with the target height and the target width to the running memory, store each page in the PDF document into the memory, and convert the data in the memory into the picture file to be stored in the disk. Therefore, the embodiment of the invention can convert the PDF document into a long picture, and is convenient for a user to manage the picture converted by the PDF document.
The embodiment of the present invention further provides an electronic device, as shown in fig. 8, including a processor 801, a communication interface 802, a memory 803, and a communication bus 804, where the processor 801, the communication interface 802, and the memory 803 complete communication with each other through the communication bus 804,
A memory 803 for storing a computer program;
The processor 801, when executing the program stored in the memory 803, implements the following steps:
Acquiring the height and width of each page in a PDF document to be converted; the height is the length of the page in the vertical direction, and the width is the length of the page in the horizontal direction;
Determining a target height and a target width;
Applying for a target memory space with the target width from the running memory;
Storing each page of data in the document into a target memory space with the target height and the target width according to the sequence;
And converting the data in the target memory space into a picture file and storing the picture file into a disk storage.
The electronic device for converting the PDF document into the picture can determine the target height and the target width according to the height and the width of each PDF document, apply for the memory with the target height and the target width to the running memory, store each page in the PDF document into the memory, and convert the data in the memory into the picture file to be stored in the disk. Therefore, the embodiment of the invention can convert the PDF document into a long picture, and is convenient for a user to manage the picture converted by the PDF document.
The communication bus mentioned above for the electronic device may be a peripheral component interconnect standard (PERIPHERAL COMPONENT INTERCONNECT, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but may also be a digital signal processor (DIGITAL SIGNAL Processing, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), field-Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic device, discrete gate or transistor logic device, discrete hardware components.
In yet another embodiment of the present invention, there is also provided a computer readable storage medium having stored therein a computer program which when executed by a processor implements the steps of the method of converting any PDF document described above into a picture.
In yet another embodiment of the present invention, there is also provided a computer program product containing instructions that, when run on a computer, cause the computer to perform the method of converting a PDF document of any of the above embodiments into a picture.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk Solid STATE DISK (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for embodiments of the apparatus, electronic device, etc., the description is relatively simple as it is substantially similar to the method embodiments, as relevant points are found in the partial description of the method embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (8)

1. A method for converting a portable document format PDF document into a picture, comprising:
Acquiring the height and width of each page in a PDF document to be converted; the height is the length of the page in the vertical direction, and the width is the length of the page in the horizontal direction;
Determining a target height and a target width;
Applying for a target memory space with the target width from the running memory;
Storing each page of data in the document into a target memory space with the target height and the target width according to the sequence;
converting the data in the target memory space into a picture file in an encoding mode and storing the picture file into a disk storage;
wherein the step of determining the target height and the target width comprises:
adding the heights of each page, and determining the result as a target height;
comparing the width of each page, and determining the maximum width as a target width;
or, the step of determining the target height and the target width includes:
adding the width of each page, and determining the result as a target width;
comparing the height of each page, and determining the maximum height as a target height;
The step of storing each page of data in the document in order into the target memory space of the target height and the target width comprises the following steps:
Acquiring page number sequences of pages in the document;
and storing each page of data in the document into the target memory space according to the page sequence according to a preset splicing mode.
2. The method according to claim 1, characterized in that:
the step of storing each page of data in the document into the target memory space according to the page sequence according to a preset splicing mode comprises the following steps:
acquiring typesetting directions of the contents of all pages in the document;
selecting an unselected page according to the page number sequence, and determining the unselected page as a current page;
According to a preset first alignment mode, the typesetting direction of the current page is consistent with that of the previous page, and the width of the current page is spliced with that of the previous page and is stored in the target memory space; the preset first alignment mode comprises the following steps: left alignment, right alignment, or centered alignment;
returning to the step of selecting one unselected page according to the page number sequence and determining the unselected page as the current page until all pages in the PDF document are stored in the target memory space;
Or, the step of storing each page of data in the document into the target memory space according to the page sequence according to a preset splicing algorithm includes:
acquiring typesetting directions of the contents of all pages in the document;
selecting an unselected page according to the page number sequence, and determining the unselected page as a current page;
According to a preset second alignment mode, the typesetting direction of the current page is consistent with that of the previous page, and the height of the current page is spliced with that of the previous page and is stored in the target memory space; the preset second alignment mode comprises the following steps: upper alignment, lower alignment, or centered alignment;
And returning to the step of selecting one unselected page according to the page number sequence and determining the unselected page as the current page until all pages in the PDF document are stored in the target memory space.
3. The method according to claim 1 or 2, wherein the step of converting the data in the target memory space into a picture file by encoding and storing the picture file in the disk storage includes:
encoding the data in the target memory space into a picture format;
calling a system writing file interface;
Storing the encoded data in a disk.
4. An apparatus for converting a PDF document into a picture, comprising:
The acquisition module is used for acquiring the height and the width of each page in the PDF document to be converted; the height is the length of the page in the vertical direction, and the width is the length of the page in the horizontal direction;
the determining module is used for determining the target height and the target width;
The application module is used for applying the target height to the running memory for the target memory space with the target width;
the storage module is used for sequentially storing each page of data in the document into a target memory space with the target height and the target width;
The conversion module is used for converting the data in the target memory space into a picture file in an encoding mode and storing the picture file into a disk storage;
wherein, the determining module includes: a first target height determining unit and a first target width determining unit;
the first target height determining unit is used for adding the heights of the pages and determining the result as a target height;
The first target width determining unit is used for comparing the width of each page and determining the largest width as a target width;
or, the determining module includes: a second target width determining unit and a second target height determining unit;
The second target width determining unit is used for adding the width of each page and determining the result as a target width;
The second target height determining unit is used for comparing the heights of each page and determining the maximum height as the target height;
the memory module includes: a page number order acquisition unit and a storage unit;
the page sequence acquisition unit is used for acquiring page sequence of pages in the document;
the storage unit is used for storing each page of data in the document into the target memory space according to the page number sequence in a preset splicing mode.
5. The apparatus of claim 4, wherein the memory unit comprises: the first typesetting direction obtaining subunit, the first selecting subunit, the first splicing subunit and the first calling subunit;
the first typesetting direction acquisition subunit is used for acquiring typesetting directions of contents of all pages in the document;
The first selecting subunit is configured to select an unselected page according to the page number sequence, and determine the unselected page as a current page;
the first splicing subunit is used for splicing the width of the current page and the width of the last page which are not spliced according to a preset first alignment mode and consistent typesetting direction of the current page and the last page, and storing the spliced width of the current page and the spliced width of the last page into the target memory space; the preset first alignment mode comprises the following steps: left alignment, right alignment, or centered alignment;
The first calling subunit is used for calling the first selecting subunit until all pages in the PDF document are stored in the target memory space;
Or, the storage unit includes: the second typesetting direction obtaining subunit, the second selecting subunit, the second splicing subunit and the second calling subunit;
The second typesetting direction obtaining subunit is used for obtaining typesetting directions of contents of all pages in the document;
the second selecting subunit is configured to select an unselected page according to the page number sequence, and determine the unselected page as a current page;
The second splicing subunit is configured to match the typesetting direction of the current page with the typesetting direction of the previous page according to a preset second alignment mode, splice the height of the current page with the height of the previous page, and store the spliced height into the target memory space; the preset second alignment mode comprises the following steps: upper alignment, lower alignment, or centered alignment;
the second calling subunit is configured to call the second selecting subunit until all pages in the PDF document are stored in the target memory space.
6. The apparatus of claim 4 or 5, wherein the conversion module comprises: the device comprises an encoding unit, a calling unit and a saving unit;
The encoding unit is used for encoding the data in the target memory space into a picture format;
the calling unit is used for calling a system write file interface;
the storage unit is used for storing the encoded data into a magnetic disk.
7. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
A memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-3 when executing a program stored on a memory.
8. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1-3.
CN201810779986.5A 2018-07-16 2018-07-16 Method and device for converting PDF document into picture and electronic equipment Active CN110795914B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810779986.5A CN110795914B (en) 2018-07-16 2018-07-16 Method and device for converting PDF document into picture and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810779986.5A CN110795914B (en) 2018-07-16 2018-07-16 Method and device for converting PDF document into picture and electronic equipment

Publications (2)

Publication Number Publication Date
CN110795914A CN110795914A (en) 2020-02-14
CN110795914B true CN110795914B (en) 2024-06-18

Family

ID=69424854

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810779986.5A Active CN110795914B (en) 2018-07-16 2018-07-16 Method and device for converting PDF document into picture and electronic equipment

Country Status (1)

Country Link
CN (1) CN110795914B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112036123B (en) * 2020-08-31 2024-05-10 三六零数字安全科技集团有限公司 PDF generation method, device, equipment and storage medium based on webpage

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102368263A (en) * 2011-10-17 2012-03-07 苏州阔地网络科技有限公司 File format converting method and device
CN104244000A (en) * 2014-09-19 2014-12-24 浙江宇视科技有限公司 JPEG picture rapid splicing method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101853246B (en) * 2010-06-14 2012-05-23 深圳市万兴软件有限公司 Method and device for converting document format
CN107015739A (en) * 2017-03-07 2017-08-04 惠州Tcl移动通信有限公司 A kind of method and system for intercepting long length screen content
CN107908379B (en) * 2017-10-27 2020-08-14 长安大学 Method for displaying digital publishing original image of super-large page

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102368263A (en) * 2011-10-17 2012-03-07 苏州阔地网络科技有限公司 File format converting method and device
CN104244000A (en) * 2014-09-19 2014-12-24 浙江宇视科技有限公司 JPEG picture rapid splicing method and device

Also Published As

Publication number Publication date
CN110795914A (en) 2020-02-14

Similar Documents

Publication Publication Date Title
US20130259377A1 (en) Conversion of a document of captured images into a format for optimized display on a mobile device
US9088676B2 (en) Information processing apparatus, information processing method, and computer readable medium
US20150169944A1 (en) Image evaluation apparatus, image evaluation method, and non-transitory computer readable medium
CN107728892B (en) Picture display method, device, terminal and storage medium
CN111159594A (en) Information processing method, information processing device and terminal equipment
CN112487766A (en) Document labeling method and system and computer equipment
CN110795914B (en) Method and device for converting PDF document into picture and electronic equipment
US20150169508A1 (en) Obfuscating page-description language output to thwart conversion to an editable format
US20210012456A1 (en) Information processing method, image processing apparatus, and storage medium
CN112365401A (en) Image generation method, device, equipment and storage medium
US20150268907A1 (en) Image processing device and non-transitory computer readable medium
US8482763B2 (en) Method and apparatus for generating a file using address and information tags
CN104252475A (en) Method and device for positioning text messages in picture
CN112783840B (en) Method and device for storing document, electronic equipment and storage medium
CN111191418B (en) Online document processing method and device, electronic equipment and computer storage medium
KR101458155B1 (en) Apparatus and method for generating edited document
CN109634537B (en) Segmentation printing method and transaction terminal
CN113568578B (en) Picture processing method and device, electronic equipment and readable storage medium
CN110941589A (en) Picture exporting method and device, electronic equipment and readable storage medium
CN117234442B (en) Data printing method, device, computer equipment and computer readable storage medium
CN112529643B (en) Electronic invoice processing method and device, storage medium and electronic equipment
CN111091016B (en) Tripod nine-code reading method and device and mobile terminal
US10831833B2 (en) Information processing apparatus and non-transitory computer readable medium
US9350911B2 (en) Image acquisition
CN113918842A (en) File preview method and device and terminal equipment

Legal Events

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