简体   繁体   中英

EDIT: Can Ghostscript give me the binary data rather than output to a directory?

I currently have a Python script that runs a Ghostscript command to convert a PDF's first page to a PNG. However, right now the image just goes into one of my directories. Is it possible to have the Ghostscript output binary data so I can save that save to a database?

args = [
    "pdf2img", # actual value doesn't matter
    "-sOutputFile=testing.png",
    "-dNOPAUSE",
    "-dBATCH",
    "-sDEVICE=png256",
    "-sPAPERSIZE=a1",
    "-dPDFFitPage=true",
    "-dFirstPage=1",
    "-dLastPage=1",
    "testPDF.pdf"
    ]

ghostscript.Ghostscript(*args)

You can have Ghostscript pipe the output to stdout by saying -sOutputFile=%stdout. Other than that I can't think what you mean by 'give you the binary data'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM