This project is read-only.

How to rasterize PDF data as base64 instead of a file

Oct 11, 2013 at 8:31 PM
I'm generating PDF data and transmitting it as base64 to another api. Is there a way to rasterize that data with GhostScript without writing out a temp file?
Oct 12, 2013 at 9:26 AM
Ghostscript has couple of options where to write the result output:

1) It can write directly to a file (disk)
2) It can redirect output and write the result to the %stdout and/or %stderr (memory)
3) It can write to an anonymous pipe (memory)

The first option is the most common (standard) option.
The second option needs stdout and stderror redirection (not handy).
The third option is the most preferable one if you want to get your result as byte array stored in memory and convert it to a base64.

Here is an example I wrote on how to implement the third option: