CN110795914A - 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
CN110795914A
CN110795914A CN201810779986.5A CN201810779986A CN110795914A CN 110795914 A CN110795914 A CN 110795914A CN 201810779986 A CN201810779986 A CN 201810779986A CN 110795914 A CN110795914 A CN 110795914A
Authority
CN
China
Prior art keywords
page
target
width
memory
height
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201810779986.5A
Other languages
Chinese (zh)
Inventor
邓斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
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/CN110795914A/en
Publication of CN110795914A publication Critical patent/CN110795914A/en
Pending legal-status Critical Current

Links

Images

Abstract

The embodiment of the invention provides a method and a device for converting a PDF document into a picture and electronic equipment, and relates to the technical field of data conversion, wherein the method comprises the following steps: 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 target height and the target width from the operating memory, storing each page of the PDF document in the target memory, converting data in the target memory into a picture file and storing the picture file in 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 converted picture of 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 (PDF) can encapsulate text, font, Format, color, and graphic images independent of device and resolution in one file.
In the prior art, the method for converting a PDF document into a picture mainly comprises: each page of the PDF document is obtained, and each page is converted into a picture.
The inventor finds that the prior art at least has the following problems in the process of implementing the invention:
this conversion method in the prior art actually converts one PDF document into a plurality of picture files of the same number as the number of pages. When the management operation is performed, it is inconvenient to separately manage the plurality of picture files.
For example: a PDF document file contains 100 pages and is converted into 100 picture files. When the 100 picture files are to be transferred to other folders, the 100 picture files need to be transferred respectively, which is very inconvenient.
Therefore, the method for converting the PDF document in the prior art cannot realize convenient document management.
Disclosure of Invention
The embodiment of the invention aims to provide a method and a device for converting a PDF document into a picture and electronic equipment, so as to realize the convenience for a user to manage the picture converted from the PDF document. The specific technical scheme is as follows:
in a first aspect, a method for converting a PDF document into a picture is provided, where the method includes:
acquiring the height and 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;
determining a target height and a target width;
applying for a target memory space with the target height and the target width from the operating memory;
storing each page of data in the document into a target memory space with the target height and the target width in sequence;
and converting the data in the target memory space into a picture file and storing the picture file in a disk memory.
Optionally, the step of determining the target height and the target width includes:
adding the height 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 comprises:
adding the width of each page, and determining the result as a target width;
the heights of each page are compared, and the largest one is determined as a target height.
Optionally, the step of sequentially storing each page in the document into the memory with the target height and the target width includes:
acquiring the page number sequence of pages in the document;
and storing each page in the document into the memory in sequence according to a preset splicing mode.
Optionally, the step of storing each page in the document into the memory in sequence according to a preset splicing manner includes:
acquiring the typesetting direction of each page content in the document;
sequentially selecting an unselected page to be determined as a current page;
according to a preset first alignment mode, the typesetting directions of the current page and the previous page are consistent, and the width of the current page and the width of the previous page which is not spliced are spliced and stored in the memory; the presetting of the first alignment manner includes: left, right, or center alignment;
returning to the step of selecting an unselected page in sequence and determining the page as the current page until all pages in the PDF document are stored in the memory;
or, the step of storing each page in the document into the memory in sequence according to a preset splicing algorithm includes:
acquiring the typesetting direction of each page content in the document;
sequentially selecting an unselected page to be determined as a current page;
according to a preset second alignment mode, the typesetting directions of the current page and the previous page are consistent, and the height of the current page and the height of the previous page which is not spliced are spliced and stored in the memory; the preset second alignment manner includes: upper alignment, lower alignment, or center alignment;
and returning to the step of selecting one unselected page in sequence and determining the 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 an image file and storing the image file in the disk storage includes:
encoding the data in the target memory space into a picture format;
calling a system writing file interface;
and storing the encoded data in a disk.
In a second aspect, an apparatus for converting a PDF document into a picture is provided, the apparatus comprising:
the acquisition module is used for acquiring the height and 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 height and the width of the target;
the application module is used for applying a target memory space with target height and target width to the running memory;
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 an image file and storing the image file to a disk memory.
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 height of each page and determining the result as the target height;
the first target width determining unit is used for comparing the width of each page and determining the maximum 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 the target width;
the second target height determining unit is configured to compare heights of each page, and determine a maximum one of the heights as a target height.
Optionally, the storage module includes: a page number sequence acquisition unit and a storage unit;
the page number sequence acquiring unit is used for acquiring the page number sequence of the pages in the document;
and the storage unit is used for sequentially storing each page in the document into the memory according to a preset splicing mode.
Optionally, the storage unit includes: the system comprises a first layout direction acquisition subunit, a first selection subunit, a first splicing subunit and a first calling subunit;
the first typesetting direction obtaining subunit is configured to obtain a typesetting direction of each page content in the document;
the first selection subunit is used for sequentially selecting one unselected page and determining the page as a current page;
the first splicing subunit is configured to, according to a preset first alignment mode, align the current page with the previous page in the same typesetting direction, splice the width of the current page with the width of the previous page that is not spliced, and store the spliced width in the memory; the presetting of the first alignment manner includes: left, right, or center 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 memory cell includes: the second typesetting direction acquiring subunit, a second selecting subunit, a second splicing subunit and a second calling subunit;
the second typesetting direction obtaining subunit is configured to obtain a typesetting direction of each page content in the document;
the second selection subunit is used for sequentially selecting one unselected page and determining the page as the current page;
the second splicing subunit is configured to, according to a preset second alignment mode, make the typesetting directions of the current page and the previous page consistent, splice the height of the current page and the height of the previous page that is not spliced, and store the height of the current page and the height of the previous page in the memory; the preset second alignment manner includes: upper alignment, lower alignment, or center alignment;
and the second calling subunit is used for calling 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 storage 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 writing file interface;
and the storage unit is used for storing the encoded data into a disk.
In a third aspect, an electronic device is provided, which includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing the steps of the method for converting any PDF document into the 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 in the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements the steps of any one of the above methods for converting a PDF document into a picture.
According to the method, the device and the electronic equipment 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, the memory with the target height and 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 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 converted picture of the PDF document.
Of course, not all of the advantages described above need to be achieved at the same time in the practice of any one product or method of the invention.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
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 illustrating a method for storing a page 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 a page 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 structural 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 technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
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 present invention, the electronic device may be any electronic device capable of processing a PDF format file, such as a computer, a mobile phone, and a tablet computer.
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, the attribute information of each page may be obtained from the PDF file, where the attribute information includes a height and a width of each page.
Step 102, determining a target height and a target width.
In one implementation, all the page heights may be added to determine the target height, and the largest one of the page widths may be determined as the target width; in another implementation, all page widths may be summed to determine the target width, and the largest one may be determined as the target height.
Step 103, apply for the target memory space with target height and target width from the operating memory.
In one implementation, a program applies a target memory space having a size multiplied by a target height and a target width to an operating memory of an electronic device.
And step 104, sequentially storing each page of data in the document into a target memory space with the target height and the target width.
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 the page number sequence of pages in a document;
and storing each page in the document into the memory in sequence according to a preset splicing mode.
In one implementation, each page in the document is sequentially stored in the applied memory according to the page number sequence of the page in the PDF document and a vertical splicing manner, wherein the width of each page is connected with the width of the previous page.
Step 105, converting the data in the target memory space into a picture file and storing the picture file in a disk memory.
In one implementation, the format of the picture file may be: 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 present 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 target height and the target width is applied to the operating 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 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 converted picture of the PDF document. In addition, when the character content in the PDF document is identified, the character content in the document needs to be identified page by page, which takes long time and is inconvenient to use, and when the PDF document is converted into one picture and then the character content in the picture is identified, the speed is high and the use is convenient compared with the identification before the conversion.
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 vertically splicing pages in a PDF document, the method for determining the target height and the target width may include:
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 usage, the result of adding the heights of each page may be determined as the target height according to the above method, and of course, if the reduction of the memory usage is not considered, the length greater than the result of adding the heights of each page 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 occupation, the maximum width may be determined as the target width according to the above method, and of course, if the reduction of the memory occupation is not considered, the length greater than the maximum width may also be determined as the target height.
Here, since the content of each page in the PDF document is different, the height and width of each page in the PDF document may be different when the program generates 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 can be different accordingly.
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 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 horizontally splicing pages in a PDF document, the method for determining the target height and the target width can comprise the following steps:
step 301, adding the width of each page, and determining the result as the target width.
Step 302, comparing the height of each page, and determining the largest height as the target height.
The principle of determining the target height and the target width by horizontal splicing is the same as that by vertical splicing, so the description is simple, and relevant points can be obtained by referring to part of the description of the method for determining the target height and the target width by vertical splicing.
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 of the memory required to be occupied during 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 a page in a document into a memory in a method for converting a PDF document into a picture according to an embodiment of the present invention;
if the PDF documents are vertically spliced, the method for storing the pages in the documents into the memory may include:
step 401, obtaining the typesetting direction of each page content in the document.
Optionally, when splicing, it is required to ensure that the typesetting directions of the pages are 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 a page may be obtained in a PDF file, where the attribute information includes a layout direction of page content.
Step 402, one unselected page is selected in sequence and determined as the current page.
In one implementation, in order to avoid repeatedly splicing the same page, an unselected page needs to be selected when selecting a page; meanwhile, in order to facilitate management or reading, pages in the PDF document need to be spliced in sequence.
Step 403, according to a preset first alignment mode, enabling the typesetting direction of the current page to be consistent with that of the previous page, splicing the width of the current page with the width of the previous page which is not spliced, and storing the spliced width into a memory; presetting the first alignment pattern includes: left aligned, right aligned, or center 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 and stored in the memory according to the same typesetting direction as the previous page.
Here, since the size of each page of the PDF document may be different, when performing the splicing, if the width of the current page is different from the width of the previous page, an alignment manner needs to be set, and the alignment manner may be set by a user or may be a default alignment manner of the program.
Step 404, sequentially selecting an unselected page, determining the page as a current page, typesetting the current page in a same direction as the previous page according to a preset first alignment mode, and splicing the width of the current page with the width of the previous page which is not spliced and storing the spliced width into a memory until all pages in the PDF document are stored into the memory.
In one implementation mode, according to the page number sequence in a PDF document, selecting the next unselected page, determining the page as the current page, splicing the width of the current page and the width of the previous page according to the same typesetting direction as the previous page, and storing the spliced page into a memory; and if the current page is the last page in the PDF document, the current page is stored in the memory and then the next page is not selected, and the next operation of storing the data in the memory into the disk is executed.
Therefore, the method for converting the PDF document into the picture provided by the embodiment of the invention can vertically splice the pages of the PDF document, meet different requirements of users, and can also set an alignment mode 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 a page in a document into 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 horizontally spliced, the method for storing the pages in the document into the memory may include:
step 501, obtaining the typesetting direction of each page content in the document;
step 502, selecting an unselected page in sequence to determine the page as a current page;
step 503, according to a preset second alignment mode, the typesetting directions of the current page and the previous page are consistent, and the height of the current page and the height of the previous page which are not spliced are spliced and stored in a memory; the presetting of the second alignment manner includes: upper alignment, lower alignment, or center alignment;
step 504, selecting an unselected page in sequence, determining the page as a current page, typesetting the current page in a same direction as the previous page according to a preset second alignment mode, and splicing the height of the current page with the height of the previous page which is not spliced and storing the spliced height into the memory until all pages in the PDF document are stored into the memory.
The method for storing the page in the document into the memory during the horizontal splicing is basically similar to the method for storing the page in the document into the memory during the vertical splicing, and only the alignment mode of the horizontal splicing is different from the alignment mode of the vertical splicing, so the description is simple, and related points can be referred to partial description of the method for storing the page in the document into the memory during the vertical splicing.
Therefore, by applying the method for converting the PDF document into the picture provided by the embodiment of the invention, the pages of the PDF document can be transversely spliced, different requirements of users are 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, where the conversion method may include the following steps:
step 601, encoding the data in the target memory space into a picture format.
Optionally, the picture format may be many, for example: joint Photographic Experts Group (JPEG) format, Tag Image File Format (TIFF), or BitMap (BitMap, BMP).
Step 602, call a system write file interface.
In one implementation, a write file interface API of the system may be called by a program.
Step 603, storing the encoded data in a disk.
Here, since the encoded data is in the form of a picture, the data is stored in the disk and then is stored in the form of a whole picture.
Therefore, by applying the method for converting the PDF document into the picture provided by the embodiment of the invention, the PDF document can be firstly stored in the memory, and then the document is 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 operation is simple and the use is convenient.
Referring to fig. 7, fig. 7 is a schematic structural diagram of an apparatus for converting a PDF document into a picture according to an embodiment of the present invention, where the apparatus includes:
an obtaining module 701, configured to obtain 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 a target height and a target width to an operating memory;
a storage module 704, configured to store each page of data in the document into a target memory space with the target height and the target width in sequence;
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 a 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 height of each page and determining the result as the target height;
the first target width determining unit is used for comparing the width of each page and determining the maximum 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 the target width;
the second target height determining unit is configured to compare heights of each page, and determine a maximum one of the heights as a target height.
Specifically, the storage module 704 may include: a page number sequence acquisition unit and a storage unit;
the page number sequence acquiring unit is used for acquiring the page number sequence of the pages in the document;
and the storage unit is used for sequentially storing each page in the document into the memory according to a preset splicing mode.
Specifically, the storage unit may include: the system comprises a first layout direction acquisition subunit, a first selection subunit, a first splicing subunit and a first calling subunit;
the first typesetting direction obtaining subunit is configured to obtain a typesetting direction of each page content in the document;
the first selection subunit is used for sequentially selecting one unselected page and determining the page as a current page;
the first splicing subunit is configured to, according to a preset first alignment mode, align the current page with the previous page in the same typesetting direction, splice the width of the current page with the width of the previous page that is not spliced, and store the spliced width in the memory; the presetting of the first alignment manner includes: left, right, or center 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 acquiring subunit, a second selecting subunit, a second splicing subunit and a second calling subunit;
the second typesetting direction obtaining subunit is configured to obtain a typesetting direction of each page content in the document;
the second selection subunit is used for sequentially selecting one unselected page and determining the page as the current page;
the second splicing subunit is configured to, according to a preset second alignment mode, make the typesetting directions of the current page and the previous page consistent, splice the height of the current page and the height of the previous page that is not spliced, and store the height of the current page and the height of the previous page in the memory; the preset second alignment manner includes: upper alignment, lower alignment, or center alignment;
and the second calling subunit is used for calling 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 storage 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 writing file interface;
and the storage unit is used for storing the encoded data into a disk.
It can be seen that the apparatus for converting a PDF document into a picture according to the embodiments of the present invention may determine a target height and a target width according to the height and width of each of PDF documents, apply for a memory with the target height and the target width from an operating memory, store each page of the PDF document in the memory, convert data in the memory into a picture file, and store the picture file in 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 converted picture of the PDF document.
An embodiment of the present invention further provides an electronic device, as shown in fig. 8, which includes 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 mutual communication through the communication bus 804,
a memory 803 for storing a computer program;
the processor 801 is configured to implement the following steps when executing the program stored in the memory 803:
acquiring the height and 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;
determining a target height and a target width;
applying for a target memory space with the target height and the target width from the operating memory;
storing each page of data in the document into a target memory space with the target height and the target width in sequence;
and converting the data in the target memory space into a picture file and storing the picture file in a disk memory.
The electronic device for converting a PDF document into a picture provided by the embodiment of the present invention may determine a target height and a target width according to the height and width of each PDF document, apply for a memory with the target height and the target width from an operating memory, store each page in the PDF document in the memory, convert data in the memory into a picture file, and store the picture file in 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 converted picture of the PDF document.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a 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 processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
In another embodiment of the present invention, a computer-readable storage medium is further provided, in which a computer program is stored, and the computer program, when executed by a processor, implements the steps of any one of the above methods for converting a PDF document into a picture.
In another embodiment of the present invention, there is also provided a computer program product containing instructions, which when run on a computer, causes the computer to execute any one of the above-mentioned methods for converting a PDF document into a picture.
In the above embodiments, the implementation may be wholly or partially realized 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, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be 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. Also, 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 an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for embodiments of devices, electronic devices, and the like, since they are substantially similar to the method embodiments, the description is relatively simple, and reference may be made to some descriptions of the method embodiments for relevant points.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (12)

1. A method for converting portable document format PDF document into picture is characterized by comprising the following steps:
acquiring the height and 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;
determining a target height and a target width;
applying for a target memory space with the target height and the target width from the operating memory;
storing each page of data in the document into a target memory space with the target height and the target width in sequence;
and converting the data in the target memory space into a picture file and storing the picture file in a disk memory.
2. The method of claim 1, wherein:
the step of determining the target height and the target width comprises:
adding the height 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 comprises:
adding the width of each page, and determining the result as a target width;
the heights of each page are compared, and the largest one is determined as a target height.
3. The method of claim 1, wherein the step of sequentially storing each page in the document into the memory of the target height x the target width comprises:
acquiring the page number sequence of pages in the document;
and storing each page in the document into the memory in sequence according to a preset splicing mode.
4. The method of claim 3, wherein:
the step of storing each page in the document into the memory in sequence according to a preset splicing mode comprises:
acquiring the typesetting direction of each page content in the document;
sequentially selecting an unselected page to be determined as a current page;
according to a preset first alignment mode, the typesetting directions of the current page and the previous page are consistent, and the width of the current page and the width of the previous page which is not spliced are spliced and stored in the memory; the presetting of the first alignment manner includes: left, right, or center alignment;
returning to the step of selecting an unselected page in sequence and determining the page as the current page until all pages in the PDF document are stored in the memory;
or, the step of storing each page in the document into the memory in sequence according to a preset splicing algorithm includes:
acquiring the typesetting direction of each page content in the document;
sequentially selecting an unselected page to be determined as a current page;
according to a preset second alignment mode, the typesetting directions of the current page and the previous page are consistent, and the height of the current page and the height of the previous page which is not spliced are spliced and stored in the memory; the preset second alignment manner includes: upper alignment, lower alignment, or center alignment;
and returning to the step of selecting one unselected page in sequence and determining the page as the current page until all pages in the PDF document are stored in the memory.
5. The method according to any one of claims 1 to 4, wherein the step of converting the data in the target memory space into a picture file to be stored in the disk storage comprises:
encoding the data in the target memory space into a picture format;
calling a system writing file interface;
and storing the encoded data in a disk.
6. An apparatus for converting a PDF document into a picture, comprising:
the acquisition module is used for acquiring the height and 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 height and the width of the target;
the application module is used for applying a target memory space with target height and target width to the running memory;
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 an image file and storing the image file to a disk memory.
7. The apparatus of claim 6, wherein the determining module comprises: a first target height determining unit and a first target width determining unit;
the first target height determining unit is used for adding the height of each page and determining the result as the target height;
the first target width determining unit is used for comparing the width of each page and determining the maximum 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 the target width;
the second target height determining unit is configured to compare heights of each page, and determine a maximum one of the heights as a target height.
8. The apparatus of claim 6, wherein the storage module comprises: a page number sequence acquisition unit and a storage unit;
the page number sequence acquiring unit is used for acquiring the page number sequence of the pages in the document;
and the storage unit is used for sequentially storing each page in the document into the memory according to a preset splicing mode.
9. The apparatus of claim 8, wherein the storage unit comprises: the system comprises a first layout direction acquisition subunit, a first selection subunit, a first splicing subunit and a first calling subunit;
the first typesetting direction obtaining subunit is configured to obtain a typesetting direction of each page content in the document;
the first selection subunit is used for sequentially selecting one unselected page and determining the page as a current page;
the first splicing subunit is configured to, according to a preset first alignment mode, align the current page with the previous page in the same typesetting direction, splice the width of the current page with the width of the previous page that is not spliced, and store the spliced width in the memory; the presetting of the first alignment manner includes: left, right, or center 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 memory cell includes: the second typesetting direction acquiring subunit, a second selecting subunit, a second splicing subunit and a second calling subunit;
the second typesetting direction obtaining subunit is configured to obtain a typesetting direction of each page content in the document;
the second selection subunit is used for sequentially selecting one unselected page and determining the page as the current page;
the second splicing subunit is configured to, according to a preset second alignment mode, make the typesetting directions of the current page and the previous page consistent, splice the height of the current page and the height of the previous page that is not spliced, and store the height of the current page and the height of the previous page in the memory; the preset second alignment manner includes: upper alignment, lower alignment, or center alignment;
and the second calling subunit is used for calling the second selecting subunit until all pages in the PDF document are stored in the memory.
10. The apparatus of any of claims 6-9, wherein the conversion module comprises: the device comprises an encoding unit, a calling unit and a storage 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 writing file interface;
and the storage unit is used for storing the encoded data into a disk.
11. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 5 when executing a program stored in the memory.
12. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-5.
CN201810779986.5A 2018-07-16 2018-07-16 Method and device for converting PDF document into picture and electronic equipment Pending CN110795914A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810779986.5A CN110795914A (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 CN110795914A (en) 2018-07-16 2018-07-16 Method and device for converting PDF document into picture and electronic equipment

Publications (1)

Publication Number Publication Date
CN110795914A true CN110795914A (en) 2020-02-14

Family

ID=69424854

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810779986.5A Pending CN110795914A (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) CN110795914A (en)

Cited By (2)

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

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101853246A (en) * 2010-06-14 2010-10-06 深圳市万兴软件有限公司 Method and device for converting document format
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
CN107015739A (en) * 2017-03-07 2017-08-04 惠州Tcl移动通信有限公司 A kind of method and system for intercepting long length screen content
CN107908379A (en) * 2017-10-27 2018-04-13 长安大学 A kind of method for showing super large page numeral printing original

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101853246A (en) * 2010-06-14 2010-10-06 深圳市万兴软件有限公司 Method and device for converting document format
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
CN107015739A (en) * 2017-03-07 2017-08-04 惠州Tcl移动通信有限公司 A kind of method and system for intercepting long length screen content
CN107908379A (en) * 2017-10-27 2018-04-13 长安大学 A kind of method for showing super large page numeral printing original

Cited By (2)

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

Similar Documents

Publication Publication Date Title
CN103455475B (en) Composition method, equipment and system
CN111444750B (en) PDF document identification method and device and electronic equipment
US20150169944A1 (en) Image evaluation apparatus, image evaluation method, and non-transitory computer readable medium
US11080322B2 (en) Search methods, servers, and systems
US20170139875A1 (en) Converting electronic documents having visible objects
US20150169508A1 (en) Obfuscating page-description language output to thwart conversion to an editable format
KR101516213B1 (en) Responsive Web Generating Method By Converting Document To Responsive Web
CN110795914A (en) Method and device for converting PDF document into picture and electronic equipment
CN110929479A (en) Method and device for converting PDF scanning piece, electronic equipment and storage medium
CN110362790B (en) Font file processing method and device, electronic equipment and readable storage medium
CN110807300A (en) Image processing method and device, electronic equipment and medium
CN114911753A (en) Method and device for generating presentation document, electronic equipment and storage medium
CN110059563B (en) Text processing method and device
CN112784527A (en) Document merging method and device and electronic equipment
CN108595569B (en) File path copying method, file path copying device and mobile terminal
CN112464618A (en) Method and device for paging document data, storage medium and electronic equipment
CN112069132A (en) Attachment online preview method, device, equipment and medium
CN112433778A (en) Mobile equipment page display method and device, electronic equipment and storage medium
CN110929048A (en) Bookmark generation method and device, electronic equipment and storage medium
CN109634537B (en) Segmentation printing method and transaction terminal
CN111191427A (en) PDF document annotation method and device and electronic equipment
KR101458155B1 (en) Apparatus and method for generating edited document
CN110941589A (en) Picture exporting method and device, electronic equipment and readable storage medium
CN113568578B (en) Picture processing method and device, electronic equipment and readable storage medium
CN113112395B (en) Picture processing method, device and storage medium

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