app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import pyautogui import img2pdf # Taking Screenshot takeScreenshot = pyautogui.screenshot() # The path of Screenshot and r' is used for specifying raw string screenshotPath = r'screenshot.png' # Saving the screenshot in the given Path takeScreenshot.save(screenshotPath) # Opening Img file obj ImgFile = open(screenshotPath, "rb") # Opening the Pdf file obj PdfFile = open("output.pdf", "wb") # Converting Image File to PDF PdfFile.write(img2pdf.convert(ImgFile)) # Closing Image File Object ImgFile.close() # Closing PDF File Object PdfFile.close() |