我想使用FlyingSaucer将包含阿拉伯字符的HTML页面转换为PDF文件,但生成的PDF不包含组合字符并向后打印输出.
HTML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body style="font-size:15px;font-family: Arial Unicode MS;">
<center style="font-size: 18px; font-family: Arial Unicode MS;">
<b>
<i style="font-family: Arial Unicode MS;">
جميع الحقوق<br />
</i>
</b>
</center>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
Java摘录:
String inputFile = "c:\\html.html";
String url = new File(inputFile).toURI().toURL().toString();
String outputFile = "c:\\html.pdf";
OutputStream os = new FileOutputStream(outputFile);
ITextRenderer renderer = new ITextRenderer();
renderer.getFontResolver().addFont("c://ARIALUNI.TTF", BaseFont.IDENTITY_H,BaseFont.EMBEDDED);
renderer.setDocument(url);
renderer.layout();
renderer.createPDF(os);
os.close();
Run Code Online (Sandbox Code Playgroud)
实际PDF结果: 
预期PDF结果: …
我试图将我的div转换为PDF.
这是我的HTML代码:
我可以下载它很好,但我想在PDF文件中显示Div浮动:左边与Div Float对齐:右边.
<script lang="javascript" type="text/javascript">
function run()
{
var pdf = new jsPDF('p', 'pt', 'letter'),
source = $('#content')[0],
margins = {
top: 40,
bottom: 40,
left: 40,
right: 40,
width: 522
};
pdf.fromHTML(
source,
margins.left,
margins.top,
{
'width': margins.width
},
function (dispose) {
pdf.save('Test.pdf');
},
margins
);
};
</script type = "text/javascript">Run Code Online (Sandbox Code Playgroud)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>html2pdf</title>
<body>
<div id="content" style = "width: 100px">
<div id = "name" style="float:right">
<div id ="rey"> Rey </div>
<div id …Run Code Online (Sandbox Code Playgroud)我想使用jsPDF.html将html页面转换为pdf,我正在使用以下代码:
savePdf () {
var pdf = new jsPDF({unit: 'mm', format: 'a4', orientation: 'portrait' })
pdf.html(document.getElementById('printable-cv'), {
callback: function (pdf) {
pdf.save('cv-a4.pdf');
}
})
}
Run Code Online (Sandbox Code Playgroud)
但是我得到了错误html2canvas not loaded:我忘了吗?我有html2canvas
“ html2canvas”:“ ^ 1.0.0-alpha.12”
我正在将vuejs与webpack一起使用。
在同一页面中,我当前正在使用带有以下代码的html2pdf:
savePdf0 () {
let opt = {
filename: 'cv.pdf',
enableLinks: true,
image: { type: 'jpeg', quality: 0.98 },
html2canvas: {
scale: 8,
useCORS: true,
width: 310,
letterRendering: true,
},
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
}
html2pdf().set(opt).from(document.getElementById('printable-cv')).save() …Run Code Online (Sandbox Code Playgroud)