I am using wkhtmltopdf.exe for converting html to pdf using python. The pop-up window of wkhtmltopdf.exe making it very difficult for me to work on any other things while running it. I have to convert around 200K+ files and have to work on something else simultaneously. But its really not letting me to work on anything else.
Is there a way of stopping this or running it in background? I really appreciate your help.
PS. Sorry I am new to it, don't know any other way to stop it.
I am using wkhtmltox-0.12.2.2_msvc2013-win64 software
pythonw.exeto start your script (works with
.pywextension for your your script (works with
In the second case make sure the
.pyw extension is handled by pythonw.exe (right click your
.pyw script >
Open With and make sure
pythonw.exe is the default handler for
You can also pass the
CREATE_NO_WINDOW flag to the
creationflags argument if you use
subprocess.Popen to start your executable. This flag is a flag that can be passed to the Win32 CreateProcess API and is documented here.
Here's an example that doesn't create any console on my computer (make sure to name it with a
.pyw extension) :
#!/usr/local/bin/python3 # -*- coding: utf8 -*- import subprocess import urllib.parse as urlparse # import urlparse for python 2.x CREATE_NO_WINDOW = 0x08000000 # do not create a new window ! def is_url(url): parts = urlparse.urlsplit(url) return parts.scheme and parts.netloc def main(url, output): print(url, output) if not is_url(url): return -1 proc = subprocess.Popen(["wkhtmltopdf.exe", url, output], creationflags=CREATE_NO_WINDOW) proc.wait() return proc.returncode if __name__ == "__main__": url = "https://www.example.com" output = r"c:tmpexample.pdf" rval = main(url, output) sys.exit(rval)