Primefaces jsPDF没有导出图形
您好,我正在jsf+primefaces中开发一个页面,我需要生成一些显示在上面的图形的报告,我使用的是jsPDF,但我无法将图形导出为pdf,它只显示图形字符串,但页面中的图形没有被导出Primefaces jsPDF没有导出图形,primefaces,export,jspdf,Primefaces,Export,Jspdf,您好,我正在jsf+primefaces中开发一个页面,我需要生成一些显示在上面的图形的报告,我使用的是jsPDF,但我无法将图形导出为pdf,它只显示图形字符串,但页面中的图形没有被导出 <ui:define name="body" > <h:form acceptcharset="ISO-8859-1" lang="pt_BR" class="form-pesquisa"> <script src="https://cdnjs.cloud
<ui:define name="body" >
<h:form acceptcharset="ISO-8859-1" lang="pt_BR" class="form-pesquisa">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.min.js"></script>
<script>
function gerarPDF() {
var pdf = new jsPDF('p', 'pt', 'letter');
// source can be HTML-formatted string, or a reference
// to an actual DOM element from which the text will be scraped.
source = $('#gerarPdf')[0];
alert(source);
// we support special element handlers. Register them with jQuery-style
// ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
// There is no support for any other type of selectors
// (class, of compound) at this time.
specialElementHandlers = {
// element with id of "bypass" - jQuery style selector
'#bypassme': function (element, renderer) {
// true = "handled elsewhere, bypass text extraction"
return true
}
};
margins = {
top: 80,
bottom: 60,
left: 40,
width: 522
};
// all coords and widths are in jsPDF instance's declared units
// 'inches' in this case
pdf.fromHTML(
source, // HTML string or DOM elem ref.
margins.left, // x coord
margins.top, { // y coord
'width': margins.width, // max width of content on PDF
'elementHandlers': specialElementHandlers
},
function (dispose) {
// dispose: object with X, Y of the last line add to the PDF
// this allow the insertion of new lines after html
pdf.save('Test.pdf');
}, margins);
}
</script>
<div id="gerarPdf">
<div class="form-content">
Grafico
<div class="form-row">
<div class="form-group col-xs-12" style="text-align:center;">
<p:lineChart model="#{relatorioIndividualController.lineModel}" style="width: 100%; height: 500px;"/>
</div>
</div>
</div>
</div>
<h:commandButton value="PDF" id="btnPDF" onclick="gerarPDF();"/>
</h:form>
</ui:define>
函数gerarPDF(){
var pdf=新的jsPDF(“p”、“pt”、“字母”);
//源可以是HTML格式的字符串或引用
//到实际的DOM元素,文本将从该元素中删除。
source=$('#gerarPdf')[0];
警报(来源);
//我们支持特殊的元素处理程序。用jQuery风格注册它们
//ID或节点名称的ID选择器。(“#iAmID”、“div”、“span”等)
//不支持任何其他类型的选择器
//(类,指化合物)此时。
SpecialElementHandler={
//id为“bypass”的元素-jQuery样式选择器
“#绕过我”:函数(元素、渲染器){
//true=“在别处处理,绕过文本提取”
返回真值
}
};
边距={
排名:80,
底数:60,
左:40,,
宽度:522
};
//所有坐标和宽度都以jsPDF实例声明的单位表示
//在本例中为“英寸”
pdf.fromHTML(
source,//HTML字符串或DOM元素引用。
margins.left,//x坐标
margins.top,{//y坐标
“宽度”:margins.width,//PDF上内容的最大宽度
“elementHandlers”:specialElementHandlers
},
功能(处置){
//dispose:将最后一行的X,Y添加到PDF中的对象
//这允许在html之后插入新行
保存('Test.pdf');
},利润率);
}
格拉菲科
页面
出口后
知道为什么它不导出图形吗?我必须使用其他jsPDF属性吗?客户端没有jsf,只有html、css、javascript、svg、canvas。。。sp检查PF图表是什么,并就此提出问题(或更改此问题)。您不想要导出示例:哪个将图表导出为图像或BASE64 URL?然后您可以简单地将其发送到JSPDF?客户端没有jsf,只有html、css、javascript、svg、canvas。。。sp检查PF图表是什么,并就此提出问题(或更改此问题)。您不想要导出示例:哪个将图表导出为图像或BASE64 URL?然后你可以把它发送到JSPDF?