2

I tried generating a sample pdf file using the below code. I believe a pdf has been generated, but I can't view it. How can I view this pdf and how to export it. I am new to databricks. Please help to find a solution. Thanks

from fpdf import FPDF

class PDF(FPDF):    
  pass

pdf = PDF()          
pdf.add_page()            
pdf.output('test.pdf','F')          
pdf_w=210       
pdf_h=297      

class PDF(FPDF):          
    def lines(self):         
        self.rect(5.0, 5.0, 200.0,287.0)

 
Kiran
  • 21
  • 1
  • 2
  • You already saved it, just look for the `test.pdf` you have created – Green Feb 18 '21 at 16:25
  • 1
    @Green Thank you for the response. But, that is where I have doubt. How can I view that pdf? How to see the content in the test.pdf file I created. Thanks – Kiran Feb 18 '21 at 17:02

1 Answers1

0

When you using such commands the file will be created on the local filesystem, and will be destroyed when you terminate the cluster. To prevent that, you can put the file onto the Databricks File System (DBFS), for example, as /dbfs/mnt/..../file.pdf - after that file could be retrieved using databricks-cli, or something like this. (The /dbfs/ mount doesn't work on community edition with DBR 7.+!)

Another way to dbutils.fs.cp command to copy local file to DBFS, like:

dbutils.fs.cp("file:/path/to/file.pdf", "dbfs:/my.file.pdf")
Alex Ott
  • 80,552
  • 8
  • 87
  • 132