I am trying to print out thousands of PDFs to a printer called "Print To PDF" this means it will create a new PDF document from an old one.
You may be wondering why I'm doing this and that is because when I print out the new PDF it removes any text boxes implemented onto the PDF.
I have a problem however, when I run my script it say's Save as and asks me to give it a filename which is correct however I'm wondering if there's any way I can tell it to automatically give it a preset filename to save as ?
I don't think it's possible however I thought i'd ask to see if any geniuses can think of something.
Please see my code below:
import os
import sys
import win32print
import win32api
files_to_print = []
for pdf in os.listdir('.'):
filename_no_ext, ext = os.path.splitext(pdf)
if ext.lower() == '.pdf':
if pdf not in files_to_print:
files_to_print.append(pdf)
for filename in files_to_print:
CurrentPrinter = win32print.GetDefaultPrinter()
win32api.ShellExecute (0, "print", filename, CurrentPrinter, ".", 0)
win32print.SetDefaultPrinter(CurrentPrinter)
If you have any ideas at all please let me know as I am seriously puzzled on this.