Exemplo n.º 1
0
 def format(self, document):
     # use a dummy document to bypass encryption
     from reportlab.pdfbase.pdfdoc import DummyDoc, PDFDictionary, PDFString, PDFName
     dummy = DummyDoc()
     dict = {"Filter": PDFName("Standard"),
             "O": hexText(self.O), #PDFString(self.O),
             "U": hexText(self.U), #PDFString(self.U),
             "P": self.P}
     if self.revision == 3:
         dict['Length'] = 128
         dict['R'] = 3
         dict['V'] = 2
     else:
         dict['R'] = 2
         dict['V'] = 1
     pdfdict = PDFDictionary(dict)
     return pdfdict.format(dummy)
Exemplo n.º 2
0
    def format(self, document):
        # use a dummy document to bypass encryption
        from reportlab.pdfbase.pdfdoc import DummyDoc, PDFDictionary, PDFString, PDFName
        dummy = DummyDoc()

        dict = {
            "Filter": PDFName("Standard"),
            "O": hexText(self.O),  #PDFString(self.O),
            "U": hexText(self.U),  #PDFString(self.U),
            "P": self.P
        }

        if self.revision == 5:
            dict['Length'] = 256
            dict['R'] = 5
            dict['V'] = 5
            dict['O'] = hexText(self.O)
            dict['U'] = hexText(self.U)
            dict['OE'] = hexText(self.OE)
            dict['UE'] = hexText(self.UE)
            dict['Perms'] = hexText(self.Perms)
            dict['StrF'] = PDFName("StdCF")
            dict['StmF'] = PDFName("StdCF")
            stdcf = {
                "Length": 32,
                "AuthEvent": PDFName("DocOpen"),
                "CFM": PDFName("AESV3")
            }
            cf = {"StdCF": PDFDictionary(stdcf)}

            dict['CF'] = PDFDictionary(cf)

        elif self.revision == 3:
            dict['Length'] = 128
            dict['R'] = 3
            dict['V'] = 2
        else:
            dict['R'] = 2
            dict['V'] = 1
        pdfdict = PDFDictionary(dict)
        return pdfdict.format(dummy)