Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having multiple pyfpdf object, hence creating empty pdf document. #106

Open
Puneet-Singh1996 opened this issue Jun 12, 2018 · 0 comments
Open

Comments

@Puneet-Singh1996
Copy link

Puneet-Singh1996 commented Jun 12, 2018

  from fpdf import FPDF 
  import multiprocessing
  from multiprocessing import Pool

  class pdf_gen():
    def __init__(self):
      pdf = self.pdf = FPDF()
      pdf.set_auto_page_break(True,0.1)

    def get_data_from_mysql(self):
      pdf = self.pdf
      # connection is established and result is stored in 'res'.
      dup = []
      dup.insert(0,res)
      z = tuple(dup)
      return z

    def mysql_to_pdf_data(self,*result) :
       try : 
         pdf = self.pdf 
         # Entered data need to be in pdf
         finally: 
         return pdf

   if __name__ == "__main__" :
     class_pdf_object = pdf_gen()
     pdf_object = FPDF()
     recover_data = class_pdf_object.get_data_from_mysql()
     pool = multiprocessing.Pool(multiprocessing_count())
     for recover_data_list in range(len(recover_data[0])):
       pdf = pool.map(class_pdf_object.mysql_to_pdf_data,recover_data[0])
       pool.close()
       pool.join()
     pdf_object.output('savefile.pdf','F')

In the above program, pdf_object is creating empty pdf file as the object in class needs to be passed for output. But, recover_data contains a list and each value is parsing and returning different object of pyfpdf. How should I create single output file. Any help would be appreciated. I know it can be done with the help pdf_object('savefile.pdf','S') as it return document as byteString.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant