Disclosure of Invention
The embodiment of the invention provides a color processing method, a device, equipment and a system of a PDF (Portable document Format) file, which solve the technical problems that in the prior art, the color of a printed file is distorted and cannot meet the originally set requirement.
In a first aspect, an embodiment of the present invention provides a method for processing a color of a PDF file, including:
acquiring a PDF file and analyzing the PDF file;
judging whether the color spaces of the pages and the transparent groups in the PDF file are the color spaces of the equipment or not;
if the color space of the page and/or the transparent group is not the equipment color space, converting the color space of the page and/or the transparent group into the equipment color space;
and generating a modified PDF file according to the converted color space.
Further, the method, as described above, converting the color space of the page and/or the transparent group into the device color space if the color space of the page and/or the transparent group is not the device color space, specifically includes:
if the color space of the page and/or the transparent group is not the equipment color space, judging whether the color space conversion decision information input by the user through the interface is the decision information for color space conversion;
and if the color space conversion decision information is decision information for color space conversion, converting the color space of the page and/or the transparent group into an equipment color space.
Further, the method as described above, if converting the color space of the transparent set into the device color space, further includes:
converting the color space of the non-black primitives in the transparent group to a device color space;
and keeping the color space of the black graphic elements in the transparent group as the original color space.
Further, the method as described above, after maintaining the color space of the black primitive in the transparent group as the original color space, further includes:
generating an operator corresponding to the black graphic element in the transparent group;
displaying the color attribute related information of the black graphic element according to the operator;
wherein the color attribute related information of the black primitive at least comprises:
the black primitive belongs to a single black primitive or a composite black primitive, and whether the black primitive is subjected to color space conversion or not is determined.
Further, the method as described above, after generating the modified PDF file according to the converted color space, further comprising:
converting the modified PDF file into an XML format file;
and outputting the XML format file.
In a second aspect, an embodiment of the present invention provides a color processing apparatus for a PDF file, including:
the PDF file acquisition module is used for acquiring a PDF file and analyzing the PDF file;
the color space judging module is used for judging whether the color spaces of the pages and the transparent groups in the PDF file are the device color spaces;
the color space conversion module is used for converting the color space of the page and/or the transparent group into the color space of the equipment if the color space of the page and/or the transparent group is not the color space of the equipment;
and the modified PDF file generating module is used for generating a modified PDF file according to the converted color space.
Further, in the apparatus as described above, the color space determining module is specifically configured to:
if the color space of the page and/or the transparent group is not the equipment color space, judging whether the color space conversion decision information input by the user through the interface is the decision information for color space conversion; and if the color space conversion decision information is decision information for color space conversion, converting the color space of the page and/or the transparent group into an equipment color space.
Further, the apparatus as described above, if the color space converting module converts the color space of the transparent set into the device color space, further includes: a primitive color space conversion module;
the primitive color space conversion module is used for converting the color space of the non-black primitive in the transparent group into an equipment color space; and keeping the color space of the black graphic elements in the transparent group as the original color space.
Further, the apparatus as described above, further comprising:
the operator generating module is used for generating an operator corresponding to the black graphic primitive in the transparent group;
the color attribute display module is used for displaying the color attribute related information of the black graphic element according to the operator;
wherein the color attribute related information of the black primitive at least comprises:
the black primitive belongs to a single black primitive or a composite black primitive, and whether the black primitive is subjected to color space conversion or not is determined.
Further, the apparatus as described above, further comprising:
the file format conversion module is used for converting the modified PDF file into an XML format file;
and the XML file output module is used for outputting the XML format file.
In a third aspect, an embodiment of the present invention provides an electronic device, including:
a memory, a processor, and a computer program;
wherein the computer program is stored in the memory and configured to be executed by the processor to implement the method of any of the first aspects.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, the computer program being executed by a processor to implement the method according to any one of the first aspect.
The embodiment of the invention provides a method, a device, equipment and a system for processing colors of a PDF (Portable document Format) file, which are used for acquiring the PDF file and analyzing the PDF file; judging whether the color spaces of the pages and the transparent groups in the PDF file are the color spaces of the equipment or not; if the color space of the page and/or the transparent group is not the device color space, converting the color space of the page and/or the transparent group into the device color space; and generating a modified PDF file according to the converted color space. Because the conversion of the color space is only carried out once for the page color space and the transparent group color space, namely, the page color space and the transparent group color space are converted into the equipment color space, the problem that the transparent group converts the color space into the page color space firstly when carrying out transparent calculation and converts the page color space into the repeated color space of the equipment color space when carrying out RIP processing is avoided, and therefore the color of the printed file can be effectively guaranteed to meet the original color, is not distorted and meets the original set requirement.
It should be understood that what is described in the summary above is not intended to limit key or critical features of embodiments of the invention, nor is it intended to limit the scope of the invention. Other features of the present invention will become apparent from the following description.
Detailed Description
Embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present invention are shown in the drawings, it should be understood that the present invention may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present invention. It should be understood that the drawings and the embodiments of the present invention are illustrative only and are not intended to limit the scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, and in the above-described drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used are interchangeable under appropriate circumstances such that the embodiments of the invention described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The embodiments of the present invention will be described with reference to the accompanying drawings.
Example one
Fig. 1 is a flowchart of a color processing method of a PDF file according to an embodiment of the present invention, and as shown in fig. 1, an execution main body of the color processing method of a PDF file according to the present embodiment is a color processing apparatus of a PDF file, the color processing apparatus of a PDF file may be integrated into an electronic device, and the electronic device may be a computer, a notebook computer, or other devices with independent computing and processing capabilities, and then the color processing method of a PDF file according to the present embodiment includes the following steps.
Step 101, obtaining a PDF file and analyzing the PDF file.
The PDF file is a file with a portable file format, is a file with an electronic file format, and comprises pages and graphic elements. And if the plurality of transparent primitives are overlapped, forming a transparent group by the plurality of transparent primitives, wherein the PDF file comprising the transparent primitives is a transparent file.
Specifically, in this embodiment, a PDF file is obtained, a page resource of the PDF file is scanned, whether the page resource includes a transparent attribute is determined, and if the page resource includes the transparent attribute, the transparent attribute of the page and the transparent attribute of the transparent group are obtained. A color space is included in the transparency property.
Step 102, judging whether the color space of the page and the transparent group in the PDF file is the equipment color space.
Specifically, the transparency attribute of the page is acquired, and it is checked whether or not the color space of the transparency attribute is a device color space, where the device color space is simply referred to as CMYK color space. And acquiring the transparent attribute of the transparent group, and checking whether the color space of the transparent attribute of the transparent group is the equipment color space.
The transparent group is formed by superposing a plurality of primitives.
And 103, if the color space of the page and/or the transparent group is not the device color space, converting the color space of the page and/or the transparent group into the device color space.
Specifically, in the present embodiment, if only the color space of the page is not the CMYK color space, only the color space of the page is converted into the CMYK color space. If only the color space of the transparent set is not the CMYK color space, only the color space of the transparent set is converted into the CMYK color space. If the color spaces of both the page and the transparent set are not the CMYK color spaces, the color spaces of both the page and the transparent set are converted into CMYK color spaces.
The color space of the original page may be an RGB color space or other color spaces. The color space of the transparent set may be any one of a CMYK color space, an RGB color space, a GRAY color space, and an LAB color space.
In this embodiment, after the color space of the page and/or the transparent group is converted into the device color space, the device color space is marked, identification information is allocated to the color space of the converted page and/or the transparent group, and the allocated identification information is recorded.
It can be understood that, after converting the color space of the page and/or the transparent group into the device color space, the color spaces of the page and the transparent group are both the device color space, so that the transparent calculation can be performed, and after completing the transparent calculation, the RIP process can be completed without performing the conversion of the color space.
And 104, generating a modified PDF file according to the converted color space.
Specifically, in this embodiment, the converted color space is obtained according to the identification information of the converted color space, and the modified PDF file is generated according to the converted color space.
It can be understood that, after converting the color space of the page and/or the transparent group into the device color space, if the content stream corresponding to the PDF file is changed, the changed content stream is recorded, and the modified content stream object is set to the current page object of the PDF file to form a part of the modified PDF file.
In the color processing method of the PDF file provided by this embodiment, the PDF file is obtained and analyzed; judging whether the color spaces of the pages and the transparent groups in the PDF file are the color spaces of the equipment or not; if the color space of the page and/or the transparent group is not the device color space, converting the color space of the page and/or the transparent group into the device color space; and generating a modified PDF file according to the converted color space. Because the conversion of the color space is only carried out once for the page color space and the transparent group color space, namely, the page color space and the transparent group color space are converted into the equipment color space, the problem that the transparent group converts the color space into the page color space firstly when carrying out transparent calculation and converts the page color space into the repeated color space of the equipment color space when carrying out RIP processing is avoided, and therefore the color of the printed file can be effectively guaranteed to meet the original color, is not distorted and meets the original set requirement.
Example two
Fig. 2 is a flowchart of a color processing method of a PDF file according to a second embodiment of the present invention, and as shown in fig. 2, the color processing method of a PDF file according to the present embodiment is further detailed in steps 103 to 104 on the basis of the color processing method of a PDF file according to the first embodiment of the present invention, and further includes converting a modified PDF file into an XML format file; in the step of outputting the XML format file, the color processing method of the PDF file provided in this embodiment includes the following steps.
Step 201, obtaining a PDF file, and analyzing the PDF file.
In this embodiment, the implementation manner of step 201 is the same as that of step 101 in the first embodiment of the present invention, and is not described in detail here.
Step 202, judging whether the color space of the page and the transparent group in the PDF file is the device color space, if so, ending, otherwise, executing step 203.
Step 203, determining whether the color space conversion decision information input by the user through the interface is the decision information for performing the color space conversion, if so, executing step 204, otherwise, ending.
Further, in this embodiment, the electronic device may provide an interface to the user through the interface whether to perform color conversion. And if the user selects the option for color conversion through the interface and confirms the option, the color processing device of the PDF file receives the input color space conversion decision information, namely the decision information for color space conversion. And if the user selects the option of not performing color conversion through the interface and confirms the option, the color processing device of the PDF file receives the input color space conversion decision information which is the decision information of not performing color space conversion.
Step 204, converting the color space of the page and/or the transparent group into a device color space.
Further, in this embodiment, if the color space conversion decision information is decision information for performing color space conversion, the color space of the page and/or the transparent group is converted into the device color space.
In the color processing method of the PDF file provided in this embodiment, if the color space of the page and/or the transparent group is not the device color space, when the color space of the page and/or the transparent group is converted into the device color space, it is determined whether color space conversion decision information input by a user through an interface is decision information for performing color space conversion; and if the color space conversion decision information is decision information for color space conversion, converting the color space of the page and/or the transparent group into the equipment color space. Whether color space conversion is carried out or not can be selected according to the requirements of a user on the printing colors of the PDF file, the freedom of printing the PDF files with different color requirements is improved, and the user experience of printing the PDF files with different color requirements is improved.
Step 205, if the color space of the transparent group is converted into the device color space, converting the color space of the non-black primitive in the transparent group into the device color space; and keeping the color space of the black graphic elements in the transparent group as the original color space.
Further, in this embodiment, the transparent group includes a plurality of superimposed primitives, and colors of the plurality of primitives may be different. If the original color space of the transparent group is not the device color space, the color space of the transparent group is converted into the device color space, then the color space of the non-black primitive is obtained, and the color space of the non-black primitive is converted into the device color space. While the color space of the black primitives in the transparent set is preserved. After the color space of the black primitive of the transparent group is reserved, the black primitive which is originally single black cannot be processed into the black primitive which is complex black after the RIP processing is carried out on the PDF file, and the black primitive which is originally complex black cannot be processed into the black primitive which is single black.
Wherein if the color space of the black primitive is the GRAY color space, the ink amount is 0%; if the color space is an RGB color space, the ink amount of each color is that R is G and B is 0 percent; if the color space is a CMYK color space, the amount of each color ink is C ═ M ═ Y ═ K ═ 100%, or C ═ M ═ Y ═ 0%, and K ═ 100%.
In the color processing method of the PDF file provided in this embodiment, if the color space of the transparent group is converted into the device color space, the color space of the non-black primitive in the transparent group is converted into the device color space; the color space of the black primitive in the transparent group is kept as the original color space, the black primitive which is originally single black cannot be processed into the black primitive which is single black after the PDF file is processed by RIP, the black primitive which is originally double black cannot be processed into the black primitive which is single black, the black primitive which is sensitive to the change of the channel number can meet the original color setting requirement, and the color effect of the PDF file is further improved.
It is understood that after the color space of the page and/or the transparent group is converted, the marking is performed, and the identification information is allocated to the color space of the converted page and/or the transparent group, and the allocated identification information is recorded in the resource dictionary. And the color space of the non-black primitive in the transparent group is converted into the equipment color space and then marked, identification information is distributed to the color space of the non-black primitive, and the distributed identification information is recorded.
Further, in this embodiment, after completing the color space conversion of the page and/or the transparent group and the non-black primitive, according to the mark and the recorded identification information, it is determined whether the content stream needs to be modified, if the content stream needs to be modified, the content stream is modified, the modified content stream is recorded, and the modified content stream is set in the page object of the PDF file.
And step 206, generating an operator corresponding to the black primitive in the transparent group, and displaying the color attribute related information of the black primitive according to the operator.
Wherein, the color attribute related information of the black primitive at least comprises:
the color space type of the black primitive, the black primitive belongs to a single black primitive or a composite black primitive, and whether the black primitive is subjected to color space conversion or not is determined.
Further, in this embodiment, a pair of operators corresponding to the black primitive in the transparent group is generated, where the pair of operators includes a BDC operator and an EMC operator, where the BDC operator is a start operator and the EMC operator is an end operator, and a dictionary may be newly constructed by adding some settings of color attribute related information for operating on the current black primitive through the BDC operator, where the color attribute related information at least includes: and displaying the color attribute related information of the black primitive to a user by calling the BDC operator, wherein the black primitive belongs to a single black primitive or a composite black primitive, and whether the black primitive is subjected to color space conversion or not is judged. After the black graphic element is processed, the EMC operator is used for finishing the marking of the current black graphic element, and the processing of the next graphic element is not influenced.
Step 207, generating a modified PDF file according to the converted color space.
In this embodiment, the implementation manner of step 207 is the same as the implementation manner of step 104 in the first embodiment of the present invention, and details are not repeated here.
And 208, converting the modified PDF file into an XML format file, and outputting the XML format file.
Further, in this embodiment, the format of the modified PDF file is converted into an XML-format file, and a specific conversion method is not limited in this embodiment. And outputting the XML format file for the user to check.
In the color processing method of the PDF file provided by this embodiment, the modified PDF file is converted into an XML format file; and outputting an XML format file, wherein the page and/or the transparent group, the color space after the non-black primitive conversion and the color space kept by the black primitive can be more visually checked in the XML format file.
EXAMPLE III
Fig. 3 is a schematic structural diagram of a color processing apparatus for a PDF file according to an embodiment of the present invention, and as shown in fig. 3, the color processing apparatus for a PDF file according to the present embodiment includes: a PDF file obtaining module 31, a color space judging module 32, a color space converting module 33 and a modified PDF file generating module 34.
The PDF file obtaining module 31 is configured to obtain a PDF file, and analyze the PDF file. And the color space judging module 32 is configured to judge whether the color space of the page and the transparent group in the PDF file is the device color space. And a color space converting module 33, configured to convert the color space of the page and/or the transparent group into the device color space if the color space of the page and/or the transparent group is not the device color space. And a modified PDF file generating module 34, configured to generate a modified PDF file according to the converted color space.
The color processing apparatus for PDF files provided in this embodiment may execute the technical solution of the method embodiment shown in fig. 1, and the implementation principle and technical effect thereof are similar, and are not described herein again.
Fig. 4 is a schematic structural diagram of a color processing apparatus for a PDF file according to a second embodiment of the present invention, and as shown in fig. 4, the color processing apparatus for a PDF file according to the present embodiment is based on the color processing apparatus for a PDF file according to a third embodiment of the present invention, and further includes: a primitive color space conversion module 41, an operator generation module 42, a color attribute presentation module 43, a file format conversion module 44, and an XML file output module 45.
Further, the color space determining module 32 is specifically configured to:
if the color space of the page and/or the transparent group is not the equipment color space, judging whether the color space conversion decision information input by the user through the interface is the decision information for color space conversion; and if the color space conversion decision information is decision information for color space conversion, converting the color space of the page and/or the transparent group into the equipment color space.
Further, if the color space conversion module converts the color space of the transparent group into the device color space, the primitive color space conversion module 41 is configured to convert the color space of the non-black primitive in the transparent group into the device color space; and keeping the color space of the black graphic elements in the transparent group as the original color space.
Further, an operator generating module 42 is configured to generate an operator corresponding to the black primitive in the transparent group. And a color attribute exhibiting module 43, configured to exhibit the color attribute related information of the black primitive according to the operator.
Wherein, the color attribute related information of the black primitive at least comprises:
the color space type of the black primitive, the black primitive belongs to a single black primitive or a composite black primitive, and whether the black primitive is subjected to color space conversion or not is determined.
Further, the file format conversion module 44 is configured to convert the modified PDF file into an XML format file. And an XML file output module 45, configured to output an XML format file.
The color processing apparatus for PDF files provided in this embodiment may execute the technical solution of the method embodiment shown in fig. 2, and the implementation principle and technical effect thereof are similar, and are not described herein again.
EXAMPLE five
Fig. 5 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present invention, and as shown in fig. 5, the electronic device according to the present embodiment includes: a memory 51, a processor 52 and a computer program.
The computer program is stored in the memory 51 and configured to be executed by the processor 52 to implement the color processing method of the PDF file provided in the first embodiment of the present invention or the color processing method of the PDF file provided in the second embodiment of the present invention.
The relevant description may be understood by referring to the relevant description and effect corresponding to the steps in fig. 1 to fig. 2, and redundant description is not repeated here.
EXAMPLE six
A sixth embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the color processing method for a PDF file provided in the first embodiment of the present invention or the color processing method for a PDF file provided in the second embodiment of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of modules is merely a division of logical functions, and an actual implementation may have another division, for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form.
Modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware form, and can also be realized in a form of hardware and a software functional module.
Program code for implementing the methods of the present invention may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
Further, while operations are depicted in a particular order, this should be understood as requiring that such operations be performed in the particular order shown or in sequential order, or that all illustrated operations be performed, to achieve desirable results. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single implementation. Conversely, various features that are described in the context of a single implementation can also be implemented in multiple implementations separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.