Patent Publication Number: US-11036888-B2

Title: Method for protecting PDF document page-by-page

Description:
FIELD OF THE INVENTION 
     The present invention relate to the technical field of digital rights management, and particularly to a method for protecting a PDF document page-by-page. 
     BACKGROUND 
     Digital Rights Management (DRM) realizes protection of digital contents with a certain calculation method, to prevent illegal copying of the digital contents or to make copying difficult or costly, so that a user must be authorized to use the digital contents finally, and the use of digital contents by the user is performed under the constraints specified by a DRM system. 
     At present, because the PDF document is protected by performing overall protection or authorization on the whole document in general, it is impossible to perform individual copyright protection only on some contents of the document according to requirements. However, for some application requirements, it is often not necessary to pursue absolute security of the whole document, but a user may only hope to protect some contents of the document, or the user may see more contents only after performing certain operations, for example, may see more contents by registering or participating in user surveys. 
     Because of having a very clear concept of logical pages, the PDF document can be protected by taking logical pages as units. When some contents in the PDF document are protected, in general, it is necessary to split the original document, for example, each page is split into a document, and then the original PDF pages are protected in a method of protecting individual PDF documents. However, this method has a technical problem that the split page documents cannot be managed uniformly, so that it is inconvenient to distribute the documents. 
     SUMMARY 
     The present invention provides a method for protecting a PDF document page-by-page, to protect some pages of a PDF document. 
     To achieve the above object, the present invention provides a method for protecting a PDF document page-by-page, comprising the following steps: 
     S 11 : Writing a unique identifier A into a PDF document; 
     S 12 : Randomly generating a secret key B, uploading the unique identifier A and the secret key B to a server, and storing the secret key B in the server by taking the unique identifier A as an index; 
     S 13 : Traversing all page content stream objects in the PDF document, if a certain page content stream object is reused by a plurality of pages, copying the page content stream object according to the number of times that the page content stream object is reused, so that each page corresponds to an individual page content stream object; 
     S 14 : Establishing, in a memory, an index table from PDF page numbers to the page content stream objects; 
     S 15 : Searching for, according to a page number of a protected PDF page, a corresponding page content stream object from the index table; 
     S 16 : Encrypting stream data of the page content stream object searched in the previous step S 15 , by using the secret key B; and if the stream data further refers to another form object, then not encrypting the form object; 
     S 17 : Adding an encryption identifier C to an object dictionary of the encrypted page content stream object obtained in the previous step S 16 ; 
     S 18 : Because sizes of various protected PDF pages are different, respectively creating a cover layer with the same length and the same width as each of the various protected PDF pages, and naming all cover layers on the PDF pages as D; and 
     S 19 : Placing the cover layers on the top of the protected PDF pages respectively. 
     In one embodiment of the present invention, the cover layers are provided with text characters predefined by a document owner. 
     The present invention also provides a method for opening the PDF document protected according to the method for protecting a PDF document page-by-page, comprising the following steps: 
     S 21 : Traversing all page content stream objects in the PDF document, and judging, one by one, whether each page content stream object has the encryption identifier C; 
     S 22 : If the encryption identifier C does not exist in a page content stream object corresponding to a PDF page, indicating that the PDF page is not encrypted, and then directly parsing and displaying the PDF page; 
     S 23 : If the encryption identifier C does exist in a page content stream object corresponding to a PDF page, indicating that the PDF page is encrypted, acquiring the secret key B from the server according to the unique identifier A in the PDF document, decrypting the page content stream object by using the secret key B, and parsing and displaying the PDF page; and 
     S 24 : Removing the cover layers named as D on the protected PDF page. 
     The method for protecting a PDF document page-by-page can perform individual protection on some pages in the PDF document, and can guarantee the integrity of distribution of the PDF document, thereby facilitating unified management, and having strong practical value. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
       In order to more clearly explain the embodiments of the present invention or the technical solution in the prior art, the embodiments or drawings required in the description of the prior art will be briefly introduced below. Obviously, the drawings in the description below are only some embodiments of the present invention. Those ordinary skilled in the art may also obtain other drawings without contributing creative labor. 
         FIG. 1  is a flow chart showing a method for protecting a PDF document page-by-page provided in the present invention; and 
         FIG. 2  is a flow chart showing a method for opening the PDF document protected according to the method for protecting a PDF document page-by-page provided in the present invention. 
     
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     The technical solution in the embodiment of the present invention will be described clearly and completely below in combination with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those ordinary skilled in the art without contributing creative labor belong to the protection scope of the present invention. 
       FIG. 1  is a flow chart showing a method for protecting a PDF document page-by-page provided in the present invention, as shown in the Figure, the method for protecting a PDF document page-by-page of the present invention comprising the following steps: 
     S 11 : Writing a unique identifier A into a PDF document; 
     S 12 : Randomly generating a secret key B, uploading the unique identifier A and the secret key B to a server, and storing the secret key B in the server by taking the unique identifier A as an index; 
     S 13 : Traversing all page content stream objects in the PDF document, if a certain page content stream object is reused by a plurality of pages, copying the page content stream object according to the number of times that the page content stream object is reused, so that each page corresponds to an individual page content stream object; 
     S 14 : Establishing, in a memory, an index table from PDF page numbers to the page content stream objects; 
     S 15 : Searching for, according to a page number of a protected PDF page, a corresponding page content stream object from the index table; 
     S 16 : Encrypting stream data of the page content stream object searched in the previous step S 15 , by using the secret key B; and if the stream data further refers to another form object, then not encrypting the form object; 
     In this way, although absolute security of all data on the PDF pages is not guaranteed, a process of encryption and a process of decryption can be simple enough, and would be very suitable for protection scenarios with low security requirements; 
     S 17 : Adding an encryption identifier C to an object dictionary of the encrypted page content stream object obtained in the previous step S 16 ; 
     S 18 : Because sizes of various protected PDF pages are different, respectively creating a cover layer with the same length and the same width as each of the various protected PDF pages, and naming all cover layers on the PDF pages as D; 
     wherein the cover layers may be provided with text characters predefined by a document owner; the cover layers are used to cover original contents on the PDF pages, formats of the cover layers fully conform to a format standard of an open layer the PDF format, so that the cover layers may be removed by the user; however, because the page content steam object is encrypted, data of the PDF pages may be displayed as garbled characters; 
     S 19 : Placing the cover layers on the top of the protected PDF pages respectively. 
     The present invention also provides a method for opening the PDF document protected according to the method for protecting a PDF document page-by-page, as shown in  FIG. 2 , the method comprising the following steps: 
     S 21 : Traversing all page content stream objects in the PDF document, and judging, one by one, whether each page content stream object has the encryption identifier C; 
     S 22 : If the encryption identifier C does not exist in a page content stream object corresponding to a PDF page, indicating that the page is not encrypted, and then directly parsing and displaying the page; 
     S 23 : If the encryption identifier C does exist in a page content stream object corresponding to a PDF page, indicating that the page is encrypted, acquiring the secret key B from the server according to the unique identifier A in the PDF document, decrypting the page content stream object by using the secret key B, and parsing and displaying the PDF page; and 
     S 24 : Removing the cover layers named as D on the protected PDF page. 
     The method for protecting a PDF document page-by-page can perform individual protection on some pages in the PDF document, and can guarantee an integrity during distributing the PDF document, thereby facilitating unified management of the PDF document, and having a strong practical value. 
     It will be understood by those ordinary skilled in the art that: the drawings are only schematic diagrams of one embodiment, and the modules or processes in the drawings are not necessarily required for implementation of the present invention. 
     It will be understood by those ordinary skilled in the art that the modules in the device of the embodiment may be distributed in the device of the embodiment according to the description of the embodiment, or may be located in one or more devices different from that of the present embodiment by making corresponding changes. The modules of the above embodiment may be combined into one module or may be further split into multiple sub-modules. 
     Finally, it should be noted that: the above embodiments are only used for explaining the technical solution of the present invention, but are not used for limiting same; although the present invention is described in detail with reference to the foregoing embodiments, it will be understood by those skilled in the art that modifications may be made to the technical solutions described in the foregoing embodiments, or equivalent replacements may be made to some of the technical features thereof; and these modifications or replacements do not make the essence of corresponding technical solutions depart from spirit and scope of technical solution of the embodiments of the present invention.