django_ocr_server/models.py
def create_pdf(self, admin_obj=None, request=None):
        """
        This function creates self.pdf.file if it is possible 2019-03-13
        :admin_obj: An admin instance of the model
        :request: A request instance of the current http request
        :return: None
        """
        self.is_saved()  # checking that instance of OCRedFile is saved, raise DoesNotSaved exception otherwise
        if self.can_create_pdf:
            content = self.file.file.read()
            self.file.file.seek(0)
            if 'image' in self.file_type:
                pdf_content = ocr_img2pdf(content)
                filename = set_pdffile_name(self, True)
                pdf = open(filename, 'wb')
                pdf.write(content)
                pdf.close()
                self.ocred_pdf.name = filename
                self.ocred_pdf_md5 = md5(pdf_content)
                OCRedFile.Counters.num_created_pdf += 1
                if admin_obj and request:
                    admin_obj.message_user(request,
                                           'PDF created')
            elif 'pdf' in self.file_type:
                filename = set_pdffile_name(self, True)
                ocr_pdf(content, filename)
                self.ocred_pdf.name = filename
                self.ocred_pdf_md5 = md5(read_binary_file(filename))
                OCRedFile.Counters.num_created_pdf += 1
                if admin_obj and request:
                    admin_obj.message_user(request,
                                           'PDF created')
            super(OCRedFile, self).save()

        This function creates self.pdf.file if it is possible 2019-03-13
        :admin_obj: An admin instance of the model
        :request: A request instance of the current http request
        :return: None
        
This function creates self.pdf.file if it is possible 2019-03-13
This function creates self . pdf . file if it is possible 2019 - 03 - 13
def create_pdf(self, admin_obj=None, request=None):
        self.is_saved()  
        if self.can_create_pdf:
            content = self.file.file.read()
            self.file.file.seek(0)
            if 'image' in self.file_type:
                pdf_content = ocr_img2pdf(content)
                filename = set_pdffile_name(self, True)
                pdf = open(filename, 'wb')
                pdf.write(content)
                pdf.close()
                self.ocred_pdf.name = filename
                self.ocred_pdf_md5 = md5(pdf_content)
                OCRedFile.Counters.num_created_pdf += 1
                if admin_obj and request:
                    admin_obj.message_user(request,
                                           'PDF created')
            elif 'pdf' in self.file_type:
                filename = set_pdffile_name(self, True)
                ocr_pdf(content, filename)
                self.ocred_pdf.name = filename
                self.ocred_pdf_md5 = md5(read_binary_file(filename))
                OCRedFile.Counters.num_created_pdf += 1
                if admin_obj and request:
                    admin_obj.message_user(request,
                                           'PDF created')
            super(OCRedFile, self).save()
def create_pdf ( self , admin_obj = None , request = None ) : self . is_saved ( ) if self . can_create_pdf : content = self . file . file . read ( ) self . file . file . seek ( 0 ) if 'image' in self . file_type : pdf_content = ocr_img2pdf ( content ) filename = set_pdffile_name ( self , True ) pdf = open ( filename , 'wb' ) pdf . write ( content ) pdf . close ( ) self . ocred_pdf . name = filename self . ocred_pdf_md5 = md5 ( pdf_content ) OCRedFile . Counters . num_created_pdf += 1 if admin_obj and request : admin_obj . message_user ( request , 'PDF created' ) elif 'pdf' in self . file_type : filename = set_pdffile_name ( self , True ) ocr_pdf ( content , filename ) self . ocred_pdf . name = filename self . ocred_pdf_md5 = md5 ( read_binary_file ( filename ) ) OCRedFile . Counters . num_created_pdf += 1 if admin_obj and request : admin_obj . message_user ( request , 'PDF created' ) super ( OCRedFile , self ) . save ( )
This function creates self.pdf.file if it is possible 2019-03-13
This function creates self . pdf . file if it is possible 2019 - 03 - 13
"""
        This function creates self.pdf.file if it is possible 2019-03-13
        :admin_obj: An admin instance of the model
        :request: A request instance of the current http request
        :return: None
        """ # checking that instance of OCRedFile is saved, raise DoesNotSaved exception otherwise
None
self
admin_obj
request
admin_obj
An admin instance of the model
An admin instance of the model
request
A request instance of the current http request
A request instance of the current http request