I am using PDFtron.jar in java my application to convert html to pdf every thing is working fine except bootstrap css are not rendering while converting (PDFTron do not understand bootstrap css while converting into pdf) for eg below code is not understood by pdftron and I am getting both div in my pdf.
<div class="col-xs-12 info-details visible-xs">Visible for xs screen</div>
<div class="col-xs-12 info-details hidden-xs">Visible for non xs screen</div>
Below is the code to convert htmlToPdf
if (System.getProperty("java.library.path").indexOf(support.config.getTomcatHome() + File.separator + "lib") == -1)
{
System.setProperty("java.library.path", System.getProperty("java.library.path") + File.pathSeparatorChar + support.config.getTomcatHome() + File.separator
+ "lib" + File.pathSeparatorChar + support.config.getTomcatHome() + File.separator
+ "lib" + File.separator + "PDFNet.jar");
java.lang.reflect.Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
fieldSysPath.setAccessible(true);
fieldSysPath.set(null, null);
Util.Log("PDFNet.jar loaded");
}
OS = System.getProperty("os.name").toLowerCase();
PdfViewerLicense.initialize();
PDFNet.setTempPath(pdfFolderPath+File.separator);
doc = new PDFDoc();
converter = new HTML2PDF();
if(OS.indexOf("win") < 0)
{
HTML2PDF.setModulePath(support.config.getTomcatHome() + File.separator + "lib" + File.separator +"html2pdf.so" );
}
converter.setLandscape(false);
converter.setPaperSize(PrinterMode.e_A4);
converter.insertFromHtmlString(html);
if (converter.convert(doc)){
doc.save(output_pdf_path, SDFDoc.e_linearized, null);
result = true;
}else {
Util.Log("PDFTron Conversion failed. HTTP Code: " + converter.getHTTPErrorCode() + "\n" + converter.getLog());
}
}
My XSL html head
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro" rel="stylesheet">
<TITLE> PDFTron </TITLE>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</HEAD>