Python silent print PDF to specific printer

前端 未结 5 1021
花落未央
花落未央 2020-12-08 06:02

I have a PDF document and I want to print it with my python app.

I have tried the solution in here (Print PDF document with python\'s win32print module?) but when I

5条回答
  •  有刺的猬
    2020-12-08 06:30

    If you want to print specific pages and some other parameters, you should specify them in the parameters of gsprint as follows:

    import win32print
    import win32api
    
    GHOSTSCRIPT_PATH = "C:\\path\\to\\GHOSTSCRIPT\\bin\\gswin32.exe"
    GSPRINT_PATH = "C:\\path\\to\\GSPRINT\\gsprint.exe"
    
    params = '-ghostscript "'+ GHOSTSCRIPT_PATH  +'" -printer "'+currentprinter+'" -from 1 -to 3 -landscape -copies 1 "1.pdf "'
    print(params)
    
    win32api.ShellExecute(0, 'open', GSPRINT_PATH, params, '.',0)
    

提交回复
热议问题