To-be-printed file processing method and device, electronic equipment and storage medium
By optimizing the special attribute objects in the to-printed file, the problem of generating a large number of instructions in the to-printed file is solved, and the parsing efficiency and printing speed of the image forming device are improved.
Patent Information
- Application Number
- CN202411797715.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-07-19
- Filing Date
- 2024-12-06
- Publication Date
- 2025-05-06
AI Technical Summary
Objects with special attributes in the file to be printed generate a large number of instructions, which causes the image forming device to take more time to parse the print job, increasing the working intensity.
By identifying the image objects, graphic objects and text objects in the file to be printed, the target objects with preset attributes (such as image objects with preset data amount, transparency objects, mask objects, gradient objects, bold text objects), including methods such as reducing resolution, data flattening, data compression, removing mask objects, and mixing on white background.
Simplify the file to be printed, reduce the amount of data, reduce the number of instructions when converted into a format that can be recognized by the image forming device, and reduce the analysis workload of the image forming device, thereby improving the analysis efficiency and improving the printing speed.
Smart Images

Figure CN119937945A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image forming technology, and in particular to a method and device for processing a file to be printed, an electronic device, and a storage medium. Background Art
[0002] The image forming apparatus performs image forming jobs such as generating, printing, receiving and sending image data, and examples of the image forming apparatus include printers, scanners, copiers, fax machines, and multi-function peripherals (MFP) that perform the above functions in a single device.
[0003] Before executing an image forming job, the user needs to convert the file to be printed into a file in a format recognizable by the image forming device (such as a PCL file) and send it to the image forming device for printing.
[0004] When the file to be printed contains objects with special attributes, the objects with special attributes will generate a large number of instructions during the process of converting the format of the file to be printed into a format recognizable by the image forming device. When the image forming device receives a print job (such as the PCL file mentioned above), the image forming device needs to spend a lot of time to parse the instructions, resulting in a longer time-consuming execution of the print job and increased intensity of the image forming work. Summary of the invention
[0005] The embodiments of the present application provide a method and device for processing a file to be printed, an electronic device and a storage medium. The method for processing a file to be printed can at least solve the problem of generating a large number of instructions for objects with special attributes in the file to be printed.
[0006] In a first aspect, an embodiment of the present application provides a method for processing a file to be printed, the method comprising: obtaining a file to be printed; identifying an object to be processed contained in the file to be printed, the object to be processed comprising at least one of an image object, a graphic object and a text object; when it is identified that the object to be processed contains a target object with preset attributes, optimizing at least the object to be processed of the file to be printed to obtain a processed print file.
[0007] In one possible implementation, the target object with preset attributes includes at least one of an image object with a preset data amount, a solid color object in an image object, a transparency object in a graphic object, a mask object in a graphic object, a gradient object in a graphic object, and a bold text object in a text object, wherein the transparency object includes a semi-transparent object, a fully transparent object, and an opaque object.
[0008] In one possible implementation, when the target object with preset attributes is an image object with a preset data amount, optimizing the target object includes: reducing the resolution of the image object; or flattening the data of the image object; or compressing the data of the image object.
[0009] In a possible implementation manner, when the target object with the preset attribute is a pure color object in an image object, optimizing the target object includes: sending the pure color object in the image object as a 1-bit mask image.
[0010] In one possible implementation, when the target object with preset attributes is a transparency object in a graphic object, optimizing the target object includes: when the transparency object is the semi-transparency object, synthesizing the semi-transparency object by rendering the original image; or, after the semi-transparency object is rendered, using white background blending to simulate the semi-transparency effect.
[0011] In a possible implementation, before obtaining the file to be printed, the method further includes:
[0012] Set the processing method of the file to be printed according to the user's selection.
[0013] In a possible implementation, setting a method for processing files to be printed according to user selection includes:
[0014] If the processing mode selected by the user is the object-by-object recognition mode, the method for processing the file to be printed as claimed in claim 1 is executed.
[0015] In a possible implementation manner, when the target object with preset attributes is a mask object in a graphic object, optimizing the target object includes: removing the mask object.
[0016] In a possible implementation manner, the removing the mask object includes:
[0017] When the mask object is used to cover part of the content in the image, the mask object is removed by cropping; or when the mask object is used to control the transparency of the underlying image, the mask object is tiled and overlaid.
[0018] In a possible implementation, when the target object with preset attributes is a gradient object in a graphic object, the optimization processing of the target object includes: rendering the gradient object into a gradient image by overlaying effects from an original image.
[0019] In a possible implementation, when the target object with preset attributes is a bold text object, optimizing the target object includes: converting the bold text object into a preset text format with a smaller data volume.
[0020] In a second aspect, an embodiment of the present application provides a device for processing files to be printed, comprising an acquisition module for acquiring files to be printed; an identification module for identifying objects to be processed contained in the files to be printed, wherein the objects to be processed include at least one of image objects, graphic objects and text objects; a judgment module for judging whether the objects to be processed include target objects with preset attributes; and a processing module for optimizing at least the objects to be processed in the files to be printed when the objects to be processed include the target objects with preset attributes, so as to obtain a processed print file.
[0021] In a third aspect, an embodiment of the present application further provides an electronic device, which may include a processor and a memory, wherein the memory is used to store at least one instruction, and when the instruction is loaded and executed by the processor, the method for processing a file to be printed provided in the first aspect is implemented.
[0022] In a fourth aspect, an embodiment of the present application further provides an image forming device, which is communicatively connected to an electronic device, and after the electronic device completes the method for processing a file to be printed according to the first aspect, performs a printing operation on the processed print file.
[0023] In a fifth aspect, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for processing a file to be printed provided in the first aspect is implemented.
[0024] Through the above technical solution, before converting the file to be printed into a file in a format recognizable by an image forming device, by optimizing the target object with preset attributes in the file to be printed, the file to be printed can be simplified and the data volume of the file to be printed can be reduced, thereby reducing the number of instructions generated when the file to be printed is converted into a file in a format recognizable by an image forming device, reducing the parsing workload of the image forming device, thereby improving the parsing efficiency and achieving an increase in printing speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0026] Figure 1 A flowchart of a method for processing a file to be printed provided in one embodiment of the present application;
[0027] Figure 2 A schematic diagram of a target object optimization process flow provided by an embodiment of the present application;
[0028] Figure 3 A schematic diagram of a rendering effect provided for an embodiment of the present application;
[0029] Figure 4 A schematic diagram of a rendering mode setting interface provided by an embodiment of the present application;
[0030] Figure 5 A schematic diagram of a drive framework at a drive format conversion level provided for an embodiment of the present application;
[0031] Figure 6 A schematic diagram of the structure of a device for processing files to be printed is provided for one embodiment of the present application;
[0032] Figure 7 A schematic diagram of the structure of a device for processing files to be printed provided in another embodiment of the present application; DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0034] Figure 1 A flowchart of a method for processing a file to be printed provided in one embodiment of the present application.
[0035] Reference Figure 1 As shown, the method may include the following process:
[0036] S101: Obtain a file to be printed.
[0037] In some embodiments, the user terminal can obtain the file to be printed in response to the user operation, wherein the user terminal includes but is not limited to a computer, a personal computer, a laptop computer, a tablet computer, a network server, a mobile phone, a personal digital assistant, an intelligent wearable device, a printing auxiliary device connected between a client and an image forming device, etc. The file to be printed is a file converted from an initial file to a preset format, wherein the initial file can include different formats, such as WORD, EXCEL, PPT, PDF (Portable Document Format), etc. The preset format of the file to be printed includes PDF but is not limited to PDF format. In some embodiments, the format of the file to be processed can be: OFD, PostScript format with an extension of PS, PDF, PCL6, PCL, GDI, etc.
[0038] In some embodiments, some applications of electronic devices (such as office software WPS) can also directly generate files to be printed in a preset format. Correspondingly, in S101, applications of electronic devices (such as print drivers but not limited to them) can directly obtain files to be printed in a preset format without format conversion.
[0039] In addition, in some embodiments, the electronic device may also receive a file to be printed sent by an external device or a network server, or receive an initial file (such as an initial file in a format such as WORD) sent by an external device (such as another external electronic device) or a network server, and convert the initial file into a preset format (such as through WPS office software) to obtain a file to be printed in a preset format (such as a file to be printed in a PDF format). In addition, in some embodiments, the electronic device may also generate an initial file, which is provided to an external device or a network server and converted into a file to be printed in a preset format (such as a file to be printed in a PDF format), and the file to be printed in a preset format is returned to the electronic device, thereby the electronic device obtains the file to be printed.
[0040] S102: Identify an object to be processed contained in the file to be printed, where the object to be processed includes at least one of an image object, a graphic object and a text object.
[0041] In some embodiments, the file to be printed can be analyzed to identify the objects to be processed contained in the file to be printed, that is, at least one of an image object, a graphic object, and a text object. For example, when the file to be printed is in PDF format, the objects to be processed contained in the file to be printed can be identified by using a PDF recognition and analysis module or by calling other applications that can implement PDF recognition and analysis. Exemplarily, PDFium determines through analysis and processing that the objects to be processed contained in the file to be printed in the PDF format include image objects, graphic objects, and text objects. It should be noted that the present application does not limit the method for identifying the objects to be processed contained in the file to be printed. In other embodiments, identification can also be performed in other ways.
[0042] S103: When it is identified that the objects to be processed include a target object with a preset attribute, optimizing processing is performed on at least one object to be processed of the file to be printed to obtain a processed print file.
[0043] In some embodiments, the target object with preset attributes may include: at least one of an image object with preset data volume, a transparency object in a graphic object, a mask object in a graphic object, a gradient object in a graphic object, and a bold text object in a text object. The transparency object includes a semi-transparent object, a fully transparent object, and an opaque object.
[0044] In some embodiments, when the target object with preset attributes includes an image object, it can be further determined whether all the identified image objects include an image object with a preset data volume. When an image object with a preset data volume is identified, it is determined that there is an image object to be optimized. The image object with a preset data volume can specifically be an image object with a data volume greater than a first threshold. Exemplarily, the first threshold can be 10Mb, that is, image objects greater than 10Mb are all image objects with a preset data volume. It should be noted that the first threshold can be customized based on user needs, and the present application does not limit the size of the first threshold.
[0045] When the target object with preset attributes includes a graphic object, it can be further determined whether all the identified graphic objects include a transparency object, a mask object or a gradient object. When a transparency object, a mask object or a gradient object is identified, it is determined that there is a graphic object to be optimized.
[0046] When it is recognized that the objects to be processed include text objects, it can be further determined whether all the recognized text objects include bold text objects. When it is recognized that bold text objects are included, it is determined that there are text objects to be optimized.
[0047] In some embodiments, when it is identified that the objects to be processed include a target object with preset attributes (i.e., an image object, a graphic object, or a text object to be optimized), the target object can be optimized by a renderer to simplify the file to be printed. Exemplarily, the renderer that optimizes the target object can be a PCL renderer.
[0048] Figure 2 A schematic diagram of a target object optimization process flow provided for one embodiment of the present application.
[0049] Reference Figure 2 As shown, when the object to be processed includes an image object with a preset data volume, the renderer can be called to perform optimization processing on the image with the preset data volume.
[0050] In some embodiments, the renderer may perform resolution reduction processing on an image object with a preset data volume to achieve optimization of the image with the preset data volume. Specifically, in some images with a relatively large resolution or scanned files, when the data volume of an image object with a preset data volume is greater than a first threshold, it affects both data transmission and printer parsing. The size of the image data volume is closely related to the resolution of the image. In one embodiment, the renderer may perform resolution reduction processing on an image with a preset data volume to reduce the image data volume. By performing resolution reduction optimization processing, after the resolution is optimized, the image data volume can be greatly reduced, thereby improving the parsing efficiency and achieving an effective increase in the printing speed.
[0051] In other embodiments, the renderer may flatten an image object with a preset data volume to optimize the image object with a preset data volume. Specifically, for a tiled background image, the image size may have an image width and / or image height that is larger than a preset size, which affects data transmission and printer parsing. In one embodiment, the renderer may flatten the image data to reduce the image data volume. Among them, the image width and / or image height that exceeds the preset size may be reduced by flattening, so that the processed image width or image height is optimized. In one embodiment, it may also be possible to tile it at the target area size by means of vectors at the PCL level to reduce the image data volume, thereby improving parsing efficiency and further increasing printing speed.
[0052] In other embodiments, data compression processing can also be performed on image objects with a preset data volume to achieve optimization of image objects with a preset data volume. In one embodiment, the image data can be compressed by a single-line DeltaRow compression method. It can be understood by those skilled in the art that DeltaRow is one of the compression data methods specified in the PCL6 language. The PCL6 language also specifies compression algorithms such as RLE and HPEG. If the printer supports the PCL6 language, it generally supports the DeltaRow compression method. In another embodiment, the image data can also be compressed by a multi-line DeltaRow compression method. The single-line DeltaRow compression is optimized to a multi-line DeltaRow compression. The multi-line DeltaRow compression can improve the compression ratio compared to the single-line DeltaRow compression. In another embodiment, the image data can also be compressed by a JPEG compression method. The compression ratio of JPEG compression is also higher than that of other compression methods. By compressing the image object with a preset data volume by the above compression method, the final data volume of the image object can be reduced, thereby improving the parsing efficiency and achieving an increase in printing speed.
[0053] Reference Figure 2As shown, in the scene of optimizing the image object, there may be pure color objects in the image object. When there are pure color objects, if they are still rendered in the original way, a large amount of data will be generated, and if there is a background image, the background image may be disturbed. To overcome the above problems, in some embodiments, when optimizing an image object, it can be determined whether the image corresponds to a solid color image. If it is not a solid color image, it is rendered in a conventional manner. When the image object is solid color, the solid color object in the image object can be sent as a 1-bit mask image. Specifically, when the image object is a solid color object (that is, the image object has only one RGB value), the original bitmap in the rgb.bmp format is sent as a 1bit.bmp bitmap, and the black value in the 1bit bitmap is set to the set RGB value (that is, the RGB value of the solid color object). Those skilled in the art can know that the bitmap is a standard image file format in the Windows operating system, and can be classified according to pixel depth: 1bit bitmap (2 colors), 4bit bitmap (16 colors), 8bit bitmap (256 colors), 16bit bitmap (65536 colors-high color), 24bit bitmap (16.7 million colors-true color), 32bit bitmap (16.7 million colors-enhanced true color). 1bit bitmap format means that the bitmap has at most two colors, which are black and white by default, and these two colors can also be customized. A bitmap file consists of four parts: a bitmap file header, a bitmap information header, a color palette, and a bitmap data (image data, Data Bits or Data Body) array. There are two palette items in the color palette of a 1bit bitmap, and the two palette items are respectively called index 0 and index 1. Each bit in the image data array represents a pixel. If the bit is 0, the RGB value of index 0 is used when displayed, and if the bit is 1, the RGB value of index 1 is used when displayed. Exemplarily, the original RGB pure color image object in the pdf file input to the processing module is 15552 bytes. After being converted to a 1bit index map, the image size becomes 648 bytes. In this embodiment, the index 1 of the palette in the 1bit bitmap is set to the RGB value of the pure color image, which can reduce the final data volume of the image object, thereby improving the parsing efficiency and realizing the improvement of printing speed.
[0054] Reference Figure 2As shown, in some special cases, the data of graphic objects is too complex, such as transparency objects, mask objects and gradient objects in documents, which will cause the printer to parse slowly. Therefore, when rendering graphic objects, complex objects are identified and specially processed. When the objects to be processed include transparency objects, mask objects or gradient objects, they can be optimized by the renderer to reduce the data volume of the corresponding graphic objects, thereby improving parsing efficiency and achieving an increase in printing speed.
[0055] In the application scenario, the language recognizable by the image forming device (such as PCL printing language) has no transparency channel. If it is rendered in the normal mode, the parser will simulate semi-transparency in a complex way, and the data complexity is very high. In some embodiments, transparent objects are processed in different ways. When the target object with preset attributes is a semi-transparent object in the graphic object, the semi-transparent object can be synthesized by the renderer through the original image rendering, but the fully transparent object and the opaque object are not synthesized. Among them, the synthesis through the original image rendering can be to convert the multi-layer graphic object into multiple single-layer graphic objects, and then mix the general path processing through the Blend command. It should be noted that in this embodiment, the Blend command is used to mix the semi-transparent object with other objects. For ease of understanding, the path is explained below. In PCL, the three basic objects are: text, graphics, and images, and the path refers to the graphic object, which will not be repeated below. Then, by converting multiple layers into multiple single layers, the layers are reduced, thereby achieving the effect of reducing the amount of data, and then the parsing efficiency can be improved, and the printing speed can be improved.
[0056] In some embodiments, when the target object with preset attributes is a semi-transparent object in a graphic object, the optimization processing of the target object includes: when the transparency object is a semi-transparent object, not only can the semi-transparent object be synthesized by rendering the original image, but also after the semi-transparent object is rendered, white background blending can be used to simulate the semi-transparent effect.
[0057] Specifically, in the related art, if there is a semi-transparent object in the document to be printed, when the document of such semi-transparent object is converted from PDF or other formats to PCL6 format during the printing process, the conventional practice is to render the entire page as an image. The reason is that the PCL6 language has no alpha channel (α Channel or Al pha Channel), and it is impossible to render the transparency attribute alone. For ease of understanding, the alpha channel is first explained below. The alpha channel (α Channel or Al pha Channel) refers to the transparency and semi-transparency of an image. It stores the transparency information of the image. It can be understood that the value range of the alpha channel is usually from 0 to 255, where 0 represents complete transparency (that is, the pixel is completely invisible), 255 represents complete opacity (that is, the pixel is completely visible), and other values represent different degrees of transparency. Transparency represents the degree of mixing of a pixel when it is superimposed on other pixels, thereby achieving the transparent effect of the image. In the related art, when a document with a semi-transparent object is converted from a PDF format to a PCL6 format during printing, since the PCL6 language has no alpha channel, that is, it is impossible to render the transparency attribute alone, the result is a poor image effect, and the semi-transparent image effect cannot be perfectly presented. In addition, the print format file data volume generated according to the related art is large, which easily causes the printer's performance to be slow and the image to be poor, resulting in a poor user experience. In response to the above problems, an embodiment of the present application provides a method for processing semi-transparent objects. Specifically, in a certain analysis, it is determined whether there is a semi-transparent object in the document based on parameters. If a semi-transparent object is found in the document, after the semi-transparent object in the document is rendered, a white background blending is used to simulate the semi-transparent effect. To facilitate understanding, the use of white background mixing is explained below. Using white background mixing requires operations on the background color to be mixed, the alpha value of the original image, and the RGB value of the original image. The final mixed color value is obtained through operation. Assume that Merge_color represents the final output color value, back_color represents the background color to be mixed, source_alpha represents the alpha value of the original image, and source_color represents the RGB value of the original image. The operation method is: Merge_color = back_color⊙source_alpha⊙source_color, wherein ⊙ represents a certain operation method. In the embodiment of the present application, since a white background is required, the background color to be mixed is white, that is, back_color is white.
[0058] See also Figure 3 , is a schematic diagram of a rendering effect provided by an embodiment of the present application. Figure 3As shown in a in the figure, the document to be printed is an image with semi-transparency. After adding a white background, the rendering effect of the semi-transparent object is as follows Figure 3 As shown in b, it can be seen that when the semi-transparent object is rendered using the processing method of this embodiment, the image quality of the semi-transparent object will not be reduced, and the processed semi-transparent object can present a corresponding semi-transparent effect, which meets the user's imaging expectations.
[0059] And because the print data generated by this method is object-based rendering data, compared with conventional practices, it can effectively reduce the amount of data and will not reduce the image quality. For example, in a certain experiment, a 10-page PDF file carrying a semi-transparent object was rendered, and the size of the PRN file obtained by converting the PDF file into a print file using conventional methods was more than 600 megabytes, while the size of the PRN file obtained after rendering by the embodiment of the present application was only more than 20 megabytes. For ease of understanding, the PRN file is described below. The PRN file is a format for saving print tasks as files. This file format is a plain text file that contains various commands and data of the print task. Therefore, the size of the PRN file reflects to a certain extent the amount of data obtained after rendering the file to be printed. In actual operation, the user may not want to process the file to be printed in an object-based rendering manner. Therefore, the embodiment of the present application provides a method for setting the method for processing the file to be printed according to the user's selection, and provides an interface for the user to select the rendering method in the print driver interface.
[0060] See also Figure 4 , Figure 4 A schematic diagram of a rendering mode setting interface provided for an embodiment of the present application. In the print driver interface, the user can make relevant settings by himself. In the embodiment of the present application, the rendering mode setting can be entered by clicking "Image Quality". Exemplarily, there are three rendering modes: automatic recognition, page-by-page recognition, and object-by-object recognition. If the user chooses automatic recognition, the optimal solution automatically determined by the algorithm is used for rendering. For example, if the algorithm determines that object-by-object recognition is a better rendering method, object-by-object recognition is used for rendering; if the user chooses page-by-page recognition, page-by-page recognition is used for rendering. It should be noted that page-by-page recognition is a conventional rendering method. That is to say, if page-by-page recognition is selected, the objects to be processed contained in the file to be printed will not be recognized, and different objects will not be processed differently; if the user chooses object-by-object recognition, it will be rendered in an object-by-object manner, that is, the following is executed. Figure 1-2 In some embodiments, the default rendering mode is automatic recognition, that is, no special operation is required by the user, and the optimal solution automatically determined by the algorithm is directly used for rendering. The user can also switch the rendering mode to page-by-page recognition or object-by-object recognition.
[0061] It can be understood that through the content of this embodiment, the user can choose to process different objects in the document differently, or can choose to render in a conventional manner, or can choose to let the algorithm determine the best rendering method on its own, providing users with personalized rendering options and improving the user experience.
[0062] In some embodiments, the optimization processing of the gradient image can be the same as or similar to the optimization method of the semi-transparent object, that is, the optimization is performed by rendering and synthesizing the original image to reduce the layers. For example, when the target object with preset attributes is a gradient object in a graphic object, the gradient object can be rendered as a gradient image by the renderer by overlaying the effect from the original image, and combined with the alpha channel, ARGB is used to achieve the gradient effect. Those skilled in the art can understand that ARGB is a color mode, that is, the RGB color mode with the alpha (transparency) channel added. Since the use of ARGB to achieve the gradient effect has one more transparency information than using only RGB, the gradient effect can be presented more completely, which meets the user's expectations for the imaging effect.
[0063] Since the mask object is simulated in the form of a large number of Bezier curves under conventional printing, the amount of data is large, so it takes a certain amount of time to parse, resulting in a slow parsing process. In some embodiments, when the object to be processed includes a mask object, the mask object that meets the preset conditions can be eliminated by the renderer, thereby reducing the number of layers of the corresponding graphics of the file to be printed, thereby reducing the final data volume of the object, and ultimately achieving an increase in printing speed.
[0064] In some embodiments, removing mask objects that meet preset conditions may specifically include:
[0065] In one embodiment, when a mask object is used to cover part of the content in an image, for example, when a mask object is used to cover an image so that the image displays a preset shape or text after masking, the mask object portion in the target image can be cropped to achieve the removal of the mask object. The cropping of the mask object can reduce complexity, improve parsing efficiency, and increase printing speed.
[0066] In other embodiments, compared with some mask objects that do not meet the preset conditions, the mask objects that do not meet the preset conditions can also be tiled and overlaid to achieve a corresponding mask effect. For example, when the mask object is used to control the transparency of the underlying image, the mask object can be tiled and overlaid to achieve a mask effect of controlling the transparency of the underlying image, while reducing the amount of data, improving parsing efficiency, and increasing printing speed.
[0067] Reference Figure 2As shown, when the target object with preset attributes is a bold text object among text objects, the target object is optimized and the bold text object is converted into a preset text format with a smaller data volume. Exemplarily, the optimization of the target object can be performed by a renderer.
[0068] In general scenarios, for special font types, a large number of curves will be used to simulate specific text by default, resulting in complex parsing. In some embodiments, when rendering bold text, the text information can be parsed through the FreeType open source library, and the bold text can be converted into a preset text format with a smaller data volume as needed. Those skilled in the art can understand that FreeType is a font engine that provides a unified interface to access multiple font format files. The above format conversion method will not affect the printing performance, and reduces the situation where text objects are rendered as complex curves, thereby reducing the complexity of parsing and improving the printing speed.
[0069] In some embodiments, the preset text format with smaller data volume may be: Bitmap font, Out line font (also known as Vector font), PostScript type1, type3, TrueType, OpenType and other Out line fonts, Stroke fonts, etc.
[0070] In some embodiments, after the above-mentioned optimization processing is completed on the file to be printed, the optimized file can be converted into a file in a format recognizable by the image forming device. For example, the file to be printed is in PDF format, and the PDF format file is converted into PCL format. Among them, the format conversion module commonly used by the PCL driver when performing the format conversion from PDF to PCL is the ghostscript module. When rendering complex documents, the generated PRN data may be too complex or the amount of data may be too large, thereby affecting the printing performance. In addition, due to its own design reasons, the ghostscript module has poor scalability, and it is difficult to optimize it based on performance, image and other issues.
[0071] In some embodiments, to overcome the above problems, a processing module (such as a PDFium module) can be used for format conversion, and secondary development can be performed based on it, and the file format conversion module can be combined to implement the conversion process from PDF to PCL.
[0072] Figure 5 A schematic diagram of a drive framework at the drive format conversion level provided for one embodiment of the present application.
[0073] Reference Figure 5 As shown, before converting the PDF file into a PCL file, you can Figure 1-2 The method for processing a file to be printed provided in the embodiment shown in the figure optimizes the processing of the file to be printed. For example, Figure 5 The Libpdfium shown outputs the PDF file to be processed. After the PDF file is processed by PDFRender, PDFRender outputs the parsed PDF object, and then the relevant module converts the parsed PDF object into a PCL file. It can be understood that before converting the file to be printed into a format file recognizable by the printer, the file to be printed is processed first, thereby reducing the data volume of the file to be printed, which can reduce the complexity of the subsequent file parsing into PCL files, improve the efficiency of file format conversion, and then improve the printing speed and user experience. Furthermore, the optimized file to be printed can be converted into a first print file, wherein the first print file can be a file in a format recognizable by an image forming device (such as a printer), exemplarily a file in PCL format.
[0074] The method for processing a file to be printed in the embodiment of the present application can also be run on an electronic device, which includes but is not limited to a computer, a personal computer, a laptop, a tablet computer, a network server, a mobile phone, a personal digital assistant, a smart wearable device, a printing auxiliary device connected between a client and an image forming device, etc. The image forming device may include: a copier, a printer, a fax machine, or a multifunction peripheral (MFP) that integrates the functions of a copier, a printer, and a fax machine into a single system, etc.
[0075] Figure 6 A schematic diagram of the structure of an electronic device provided for one embodiment of the present application.
[0076] Reference Figure 6 As shown, the electronic device may include a processor 401 and a memory 402, and the memory 402 is used to store at least one instruction, and the instruction is loaded and executed by the processor 401 to implement the method for processing a file to be printed provided in any embodiment of the present application. In some embodiments, the electronic device includes but is not limited to a computer, a personal computer, a laptop computer, a tablet computer, a network server, a mobile phone, a personal digital assistant, a smart wearable device, a printing auxiliary device connected between a client and an image forming device, etc. The image forming device may include: a copier, a printer, a fax machine, or a multifunction peripheral (MFP) that integrates the functions of a copier, a printer, and a fax machine into a single system, etc.
[0077] Figure 7 A schematic diagram of the structure of a device for processing files to be printed provided in another embodiment of the present application.
[0078] Reference Figure 7 As shown, the device for processing files to be printed may include:
[0079] The acquisition module 501 is used to acquire the file to be printed;
[0080] The identification module 502 is used to identify the to-be-processed object contained in the to-be-printed file, where the to-be-processed object includes at least one of an image object, a graphic object and a text object;
[0081] A determination module 503 is used to determine whether the objects to be processed include a target object with a preset attribute; and
[0082] The processing module 504 is used to optimize at least the object to be processed of the file to be printed to obtain a processed print file when the object to be processed includes a target object with a preset attribute.
[0083] In some embodiments, the target object with preset attributes includes at least one of an image object with a preset data amount, a solid color object in an image object, a transparency object in a graphic object, a mask object in a graphic object, a gradient object in a graphic object, and a bold text object in a text object, wherein the transparency object includes a semi-transparent object, a fully transparent object, and an opaque object.
[0084] In some embodiments, when the target object with preset attributes is an image object with a preset data amount, optimizing the target object includes: calling the processing module 504 to reduce the resolution of the image object; or calling the processing module 504 to flatten the data of the image object; or calling the processing module 504 to compress the data of the image object.
[0085] In some embodiments, when the target object with preset attributes is a transparency object in a graphic object, optimizing the target object includes: when the transparency object is a semi-transparency object, calling the processing module 504 to synthesize the semi-transparency object by rendering the original image; or, after the semi-transparency object is rendered, using white background mixing to simulate the semi-transparency effect.
[0086] In some embodiments, when the target object with preset attributes is a mask object in a graphic object, optimizing the target object includes: calling the processing module 504 to remove the mask object.
[0087] In some embodiments, calling the processing module 504 to remove the mask object includes: when the mask object is used to cover part of the content in the image, removing the mask object by cropping; or when the mask object is used to control the transparency of the underlying image, tiling and overlaying the mask object.
[0088] In some embodiments, when the target object with preset attributes is a gradient object in a graphic object, optimizing the target object includes: calling the processing module 504 to render the gradient object from the original image into a gradient image by effect overlay. When the target object with preset attributes is a bold text object in a text object, optimizing the target object includes: calling the processing module 504 to convert the bold text object into a preset text format with a smaller data volume.
[0089] An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method for processing a file to be printed provided by any embodiment of the present application is implemented.
[0090] It should be noted that the terminals involved in the embodiments of the present application may include but are not limited to personal computers (PCs), personal digital assistants (PDAs), wireless handheld devices, tablet computers, mobile phones, MP3 players, MP4 players, etc.
[0091] It is understandable that the application may be an application program (naturalApp) installed on the terminal, or may also be a web page program (webApp) of a browser on the terminal, and this embodiment of the present application does not limit this.
[0092] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0093] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0094] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0095] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0096] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (Processor) to perform some steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.
[0097] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
[0098] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for processing a file to be printed, characterized in that: Applied to a user terminal, the method comprises: Get the file to be printed; Identifying an object to be processed contained in the file to be printed, wherein the object to be processed includes at least one of an image object, a graphic object and a text object; When it is identified that the objects to be processed include target objects with preset attributes, at least one of the objects to be processed in the file to be printed is optimized to obtain a processed print file.
2. The method according to claim 1, characterized in that The target object with preset attributes includes at least one of an image object with a preset data amount, a solid color object in an image object, a transparency object in a graphic object, a mask object in a graphic object, a gradient object in a graphic object, and a bold text object in a text object, wherein the transparency object includes a semi-transparent object, a fully transparent object, and an opaque object.
3. The method according to claim 2, characterized in that When the target object with preset attributes is an image object with preset data volume, performing optimization processing on the target object includes: Performing resolution reduction processing on the image object; or performing data flattening processing on the image object; or Perform data compression processing on the image object.
4. The method according to claim 2, characterized in that: When the target object with preset attributes is a pure color object in an image object, performing optimization processing on the target object includes: The pure color object in the image object is sent down as a 1-bit mask image.
5. The method according to claim 2, characterized in that: When the target object with preset attributes is a transparency object in a graphic object, performing optimization processing on the target object includes: When the transparency object is the semi-transparency object, the semi-transparency object is synthesized by rendering the original image; or, After the semi-transparent object is rendered, a white background blending is used to simulate the semi-transparent effect.
6. The method according to claim 2, characterized in that Before obtaining the file to be printed, the method further includes: Set the processing method of the file to be printed according to the user's selection.
7. The method according to claim 6, characterized in that The method for setting the processing method of the file to be printed according to the user's selection includes: If the processing mode selected by the user is the object-by-object recognition mode, the method for processing the file to be printed as claimed in claim 1 is executed.
8. The method according to claim 2, characterized in that: When the target object with preset attributes is a mask object in a graphic object, the optimizing process for the target object includes: Cull the mask object.
9. The method according to claim 8, characterized in that The removing of the mask object comprises: When the mask object is used to cover part of the content in the image, the mask object is removed by cropping; or When the mask object is used to control the transparency of the underlying image, a tiled overlay process is performed on the mask object.
10. The method according to claim 2, characterized in that When the target object with preset attributes is a gradient object in a graphic object, the optimizing process for the target object includes: The gradient object is rendered into a gradient image by overlaying the original image with effects.
11. The method according to claim 2, characterized in that When the target object with preset attributes is a bold text object among text objects, the optimizing process for the target object includes: The bold text object is converted into a preset text format with a smaller data volume.
12. A device for processing files to be printed, characterized in that: The device comprises: An acquisition module, used to acquire files to be printed; An identification module, used for identifying an object to be processed contained in the file to be printed, wherein the object to be processed includes at least one of an image object, a graphic object and a text object; A judging module, used to judge whether the objects to be processed include a target object with a preset attribute; and The processing module is used for optimizing at least the object to be processed of the file to be printed to obtain a processed print file when the object to be processed includes the target object with preset attributes.
13. An electronic device, characterized in that: The electronic device comprises: A processor and a memory, wherein the memory is used to store at least one instruction, and when the instruction is loaded and executed by the processor, the method for processing a file to be printed as described in any one of claims 1 to 11 is implemented.
14. An image forming device, characterized in that: The image forming device is communicatively connected with the electronic device, and after the electronic device completes the method according to any one of claims 1 to 11, the processed print file is printed.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for processing a file to be printed as described in any one of claims 1 to 11 is implemented.
Citation Information
Cited By
File printing method, device and equipment based on stylus printer and storage medium
CN120669935A