Search code examples
javawkhtmltopdf

use wkhtmltopdf without creating file


All is in the question. In java I have created a process which will execute wkhtmltopdf but I need to give to an output file and I want to create the pdf and have it in a buffer without creating the file and then read it. Is it possible ?


Solution

  • wkhtmltopdf can be used as an executable or as a library. As a library you can get the output into memory. A snipplet from a c++ Wrapper for it:

    if(wkhtmltopdf_convert(conv))
    {
        // Get Output as buffer
       const unsigned char *data = nullptr;
       size_t length = wkhtmltopdf_get_output(conv, &data);
       ....
    }