Project work problems, Linux environment, using wkhtmltopdf to do HTML conversion to PDF download, the page exists picture, the converted PDF generated HTML can be used normally, the picture is normal, directly convert the generated HTML path to PDF image location, Always show blank;
Picture blank question, oneself also looked up a lot of information on the net, and did not get Ruyi result, can only retreat and seek the second oneself to find out;
own use of the solution, convenient for everyone to work with, will generate a static page template in the picture, the manual call method to convert to stream objects; in the page through To do output to get pictures;
/** * Picture converted to string * @param imgfile * @return * * /public static string Getimagestr (String imgfile) { C5/>inputstream in = null; byte[] data = null; try {in = new FileInputStream (imgfile); data = new byte[in.available ()]; In.read (data); In.close (); } catch (FileNotFoundException e) { e.printstacktrace (); } catch (IOException e) { e.printstacktrace (); c16/>} Base64encoder encoder = new Base64encoder (); return Encoder.encode (data); }
The method entry is the absolute path of the picture;
According to the specific situation of their own project analysis;
Wkhtmltopdf Project Issues convert small images to stream object page output