Disclosure of Invention
The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
The embodiment of the invention provides a file processing method and device, a computer storage medium and a terminal, which can realize batch compression processing on document contents contained in a PDF file.
The embodiment of the invention provides a file processing method, when two or more portable document format PDF files need to be compressed, the method comprises the following steps:
determining document contents to be compressed in each PDF file;
and performing batch compression processing on the PDF files according to the determined document contents to be compressed in each PDF file.
Optionally, before determining the document content to be compressed in each PDF file, the method further includes:
it is determined whether the number of PDF files requiring compression processing is greater than or equal to two.
Optionally, the determining the document content to be compressed in each PDF file includes:
displaying the document content options which can be compressed and contained in each PDF file through a preset interactive interface;
selecting the displayed document content options to determine document contents to be compressed in each PDF file;
wherein the document content options include one or more of the following: unused fonts, invalid bookmarks, invalid links, invalid application data, compressible images.
Optionally, before performing batch compression processing on the PDF files, the method further includes:
and setting a storage path of each PDF file after the compression processing.
Optionally, before determining the document content to be compressed in each PDF file, the method further includes:
and calculating and displaying the compression ratio of the PDF file when each item of document content in the PDF file is compressed.
On the other hand, an embodiment of the present invention further provides a file processing apparatus, including: a determination unit and a compression processing unit; wherein,
the determination unit is used for: when two or more portable document format PDF files need to be compressed, determining the document content needing to be compressed in each PDF file;
the compression processing unit is used for: and performing batch compression processing on the PDF files according to the determined document contents to be compressed in each PDF file.
Optionally, the determining unit is further configured to:
it is determined whether the number of PDF files requiring compression processing is greater than or equal to two.
Optionally, the determining unit is specifically configured to:
displaying the document content options which can be compressed and contained in each PDF file through a preset interactive interface;
selecting the displayed document content options to determine document contents to be compressed in each PDF file;
wherein the document content options include one or more of the following: unused fonts, invalid bookmarks, invalid links, invalid application data, compressible images.
Optionally, the apparatus further includes a setting unit, configured to:
and setting a storage path of each PDF file after the compression processing.
Optionally, the apparatus further comprises a reference unit, configured to:
and calculating and displaying the compression ratio of the PDF file when each item of document content in the PDF file is compressed.
In still another aspect, an embodiment of the present invention further provides a computer storage medium, where computer-executable instructions are stored in the computer storage medium, and the computer-executable instructions are used to execute the above file processing method.
In another aspect, an embodiment of the present invention further provides a terminal, including: a memory and a processor; wherein,
the processor is configured to execute program instructions in the memory;
the program instructions read on the processor to perform the following operations:
when two or more portable document format PDF files need to be compressed,
determining document contents to be compressed in each PDF file;
and performing batch compression processing on the PDF files according to the determined document contents to be compressed in each PDF file.
Compared with the related art, the technical scheme of the application comprises the following steps: when two or more portable document format PDF files need to be compressed, determining the document content needing to be compressed in each PDF file; and performing batch compression processing on the PDF files according to the determined document contents to be compressed in each PDF file. The embodiment of the invention realizes the batch compression processing of the document contents contained in the PDF file, and realizes the rapid compression of the file on the basis of ensuring the file compression efficiency.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
The steps illustrated in the flow charts of the figures may be performed in a computer system such as a set of computer-executable instructions. Also, while a logical order is shown in the flow diagrams, in some cases, the steps shown or described may be performed in an order different than here.
Fig. 1 is a flowchart of a file processing method according to an embodiment of the present invention, and as shown in fig. 1, when two or more portable document format PDF files need to be compressed, the method includes:
step 101, determining document contents to be compressed in each Portable Document Format (PDF) file;
and 102, performing batch compression processing on the PDF files according to the determined document contents to be compressed in each PDF file.
Optionally, before determining the document content to be compressed in each PDF file, the method according to the embodiment of the present invention further includes:
it is determined whether the number of PDF files requiring compression processing is greater than or equal to two.
Optionally, the determining the document content to be compressed in each PDF file in the embodiment of the present invention includes:
displaying the document content options which can be compressed and contained in each PDF file through a preset interactive interface;
selecting the displayed document content options to determine document contents to be compressed in each PDF file;
wherein the document content options include one or more of the following: unused fonts, invalid bookmarks, invalid links, invalid application data, compressible images.
It should be noted that, in the embodiments of the present invention, PDF attribute information may be analyzed with reference to a related technology, and whether a font is used, whether a bookmark is invalid, whether a link is invalid, whether application data is not used, or the like is determined; in addition, the performing of the compression process includes: deleting unused fonts; deleting invalid bookmarks and/or links; deleting invalid application data; layer merging, image stitching, or other processes that may reduce storage resource usage for a compressible image (e.g., an image comprising multiple layers); the embodiment of the invention can also intercept the image in the PDF file by a screenshot mode of the image containing the plurality of layers, and replace the image containing the plurality of layers in the PDF file with the intercepted image.
In addition, the embodiment of the present invention may also set the corresponding compression level according to the compression ratio of the document content item, for example, setting the compression level includes: minimum, standard and high-definition, and different compression levels correspond to preset document content options. Fig. 2 is a schematic diagram illustrating setting of compression levels according to an embodiment of the present invention, and as shown in fig. 2, for a plurality of PDF files, the compression levels of the PDF files are respectively set, and before determining the document contents to be compressed in the PDF files, the compression ratios of the PDF files when performing compression processing on the document contents in the PDF files are calculated and displayed. The embodiment of the invention can calculate and display the compression ratio corresponding to each compression grade; furthermore, the embodiment of the invention can calculate and display the size of the original PDF file and the size of the compressed PDF file corresponding to each compression level; or a reduced file size during the compression process, etc.
Optionally, before performing batch compression processing on the PDF files, the method in the embodiment of the present invention further includes:
and setting a storage path of each PDF file after the compression processing.
It should be noted that the PDF file after compression processing in the embodiment of the present invention may be stored in the same storage path as the PDF file before compression, or may be stored in another preset area; further, if the PDF file after compression processing and the PDF file before compression are stored in the same storage path, the PDF file after compression processing may be named with reference to the related art.
Optionally, before determining the document content to be compressed in each PDF file, the method according to the embodiment of the present invention further includes:
and calculating and displaying the compression ratio of the PDF file when each item of document content in the PDF file is compressed.
It should be noted that, after the embodiment of the present invention displays the compression ratio of the PDF file when performing compression processing on each document content in the PDF file, the embodiment of the present invention may determine the document content to be compressed in each PDF file based on the displayed information.
Compared with the related art, the technical scheme of the application comprises the following steps: when two or more portable document format PDF files need to be compressed, determining the document content needing to be compressed in each PDF file; and performing batch compression processing on the PDF files according to the determined document contents to be compressed in each PDF file. The embodiment of the invention realizes the batch compression processing of the document contents contained in the PDF file, and realizes the rapid compression of the file on the basis of ensuring the file compression efficiency.
Fig. 3 is a block diagram of a file processing apparatus according to an embodiment of the present invention, as shown in fig. 3, including: a determination unit and a compression processing unit; wherein,
the determination unit is used for: when two or more portable document format PDF files need to be compressed, determining the document content needing to be compressed in each PDF file;
the compression processing unit is used for: and performing batch compression processing on the PDF files according to the determined document contents to be compressed in each PDF file.
Optionally, the determining unit is further configured to:
it is determined whether the number of PDF files requiring compression processing is greater than or equal to two.
Optionally, the determining unit is specifically configured to:
displaying the document content options which can be compressed and contained in each PDF file through a preset interactive interface;
selecting the displayed document content options to determine document contents to be compressed in each PDF file;
wherein the document content options include one or more of the following: unused fonts, invalid bookmarks, invalid links, invalid application data, compressible images.
It should be noted that, in the embodiments of the present invention, PDF attribute information may be analyzed with reference to a related technology, and whether a font is used, whether a bookmark is invalid, whether a link is invalid, whether application data is not used, or the like is determined; in addition, the performing of the compression process includes: deleting unused fonts; deleting invalid bookmarks and/or links; deleting invalid application data; layer merging, image stitching, or other processes that may reduce storage resource usage for a compressible image (e.g., an image comprising multiple layers); the embodiment of the invention can also intercept the image in the PDF file by a screenshot mode of the image containing the plurality of layers, and replace the image containing the plurality of layers in the PDF file with the intercepted image.
Optionally, the apparatus further includes a setting unit, configured to:
and setting a storage path of each PDF file after the compression processing.
It should be noted that the PDF file after compression processing in the embodiment of the present invention may be stored in the same storage path as the PDF file before compression, or may be stored in another preset area; further, if the PDF file after compression processing and the PDF file before compression are stored in the same storage path, the PDF file after compression processing may be named with reference to the related art.
Optionally, the apparatus further comprises a reference unit, configured to:
and calculating and displaying the compression ratio of the PDF file when each item of document content in the PDF file is compressed.
It should be noted that, after the embodiment of the present invention displays the compression ratio of the PDF file when performing compression processing on each document content in the PDF file, the embodiment of the present invention may determine the document content to be compressed in each PDF file based on the displayed information.
Compared with the related art, the technical scheme of the application comprises the following steps: when two or more portable document format PDF files need to be compressed, determining the document content needing to be compressed in each PDF file; and performing batch compression processing on the PDF files according to the determined document contents to be compressed in each PDF file. The embodiment of the invention realizes the batch compression processing of the document contents contained in the PDF file, and realizes the rapid compression of the file on the basis of ensuring the file compression efficiency.
The embodiment of the invention also provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used for executing the file processing method.
An embodiment of the present invention further provides a terminal, including: a memory and a processor; wherein,
the processor is configured to execute program instructions in the memory;
the program instructions read on the processor to perform the following operations:
when two or more portable document format PDF files need to be compressed,
determining document contents to be compressed in each PDF file;
and performing batch compression processing on the PDF files according to the determined document contents to be compressed in each PDF file.
It will be understood by those skilled in the art that all or part of the steps of the above methods may be implemented by a program instructing associated hardware (e.g., a processor) to perform the steps, and the program may be stored in a computer readable storage medium, such as a read only memory, a magnetic or optical disk, and the like. Alternatively, all or part of the steps of the above embodiments may be implemented using one or more integrated circuits. Accordingly, each module/unit in the above embodiments may be implemented in hardware, for example, by an integrated circuit to implement its corresponding function, or in software, for example, by a processor executing a program/instruction stored in a memory to implement its corresponding function. The present invention is not limited to any specific form of combination of hardware and software.
Although the embodiments of the present invention have been described above, the above description is only for the convenience of understanding the present invention, and is not intended to limit the present invention. It will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.