How to print a remote PDF file with gsprint (+python later on)?

45 Views Asked by At

I am currently trying to print a remote pdf with gsprint/ghostscript but ghostscript fails with a /undefinedfilename error.

The goal is to do this with python later on, however first I need to get the gsprint command working.

It works with a local file (no -sOutputFile required) but fails with a remote file. Is this even possible with gs or do I need to get the file with python first?

thanks

the gsprint command line I used:

M:\gs\gsprint.exe -ghostscript "M:\gs\bin\gswin32.exe" -printer "Samsung C1810 Series" -from 1 -to 3 -portrait -copies 1 -sOutputFile=output.pdf "https://www.nceas.ucsb.edu/sites/default/files/2020-04/colorPaletteCheatsheet.pdf"

and a python test to get the file (which actually fails with a 403)

import win32print
import win32api
import urllib.request

urllib.request.urlretrieve("https://www.nceas.ucsb.edu/sites/default/files/2020-04/colorPaletteCheatsheet.pdf", "M:\test.pdf")

EDIT: fixed the downloading by this:

url='https://www.nceas.ucsb.edu/sites/default/files/2020-04/colorPaletteCheatsheet.pdf'
r = requests.get(url, stream=True)

with open('M:/myfile.pdf', 'wb') as f:
    f.write(r.content)

still I wonder if it could work without this step

0

There are 0 best solutions below