In my program I am trying to convert HTML page to .png file by tacking a screen shot form the html file.
in my System I have installed python 3.8
, wkhtmltopdf library
and added these 2 commands to path variable.
My python Script given bellow.
import sys
import imgkit
options ={'crop-h': '200','crop-w': '375','crop-x': '0','crop-y': '0','disable-smart-width': '','zoom':1.0}
imgkit.from_file(sys.argv[1],sys.argv[2], options=options)
I am getting a screen short given below. but the image was missing in it, the figure actually need a bar code in right and logo on top. it is not visible in the final out put. I have
i tried to do this from console I am getting the error below. from my java program I am calling this program using following code.
String[] cmd = { "python", htmlToPdfScriptLocation, tempHTML.getAbsolutePath(), tempImagePath };
Process p = Runtime.getRuntime().exec(cmd);
try {
p.waitFor();// wait until the image generation process has terminated
logger.debug("HTML to img conversion sucessfull.");
} catch (InterruptedException e) {
e.printStackTrace();
logger.debug("ERROR in html to img Conversion.");
}
Having no error. the Only issue is in the barcode and logo are not visible. The question is
'crop-h': '200','crop-w': '375','crop-x': '0','crop-y': '0','disable-smart-width': '','zoom':1.0, "enable-local-file-access": ''
}
It is due to the default value of access to the local file is false. The issue can solved by using "enable-local-file-access": ''