0
私は自分のアプリケーションでPDFtron.jarを使用していますが、pdfへのhtml変換はすべてブート時にはうまくいきますcssは変換中にレンダリングしませんpdfへの変換中にcss)pdftronによって理解されない私のpdfの両方divを得ている。以下はPDFTron(XSL Java)を使用してhtml2pdfでブートストラップCSSをレンダリングする方法
<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>
メモリが提供している場合、HTML2PDFは、外部リソースをつかむことはできません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());
}
}
私の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>
私はここでPHPを使用しますか? – pise
ああ、悪いです。私はその質問を見たときに私がPHPタグに入っていると思った。ちょうどJavaの等価コードを使用してください - https://stackoverflow.com/questions/2586975/how-to-use-curl-in-java – Scoots
申し訳ありませんが、このスタイルはXSLファイルに書かれていませんでした – pise