问题描述
我正在用 html2pdf 生成 pdf,并且我已经设法生成了 pdf,但是现在我需要将此 pdf 发送到节点中的服务器或将其直接保存在我服务器上的文件夹中,现在 pdf 已下载到客户端指示的路径,但我需要在我的服务器上有一个副本,我尝试使用输出参数但我没有实现任何目标,这是我当前的代码:
document.addEventListener("DOMContentLoaded",() => {
// Escuchamos el click del botón
const $boton = document.querySelector("#btnCrearPdf");
$boton.addEventListener("click",() => {
const $elementoParaConvertir = document.body; // <-- Aquí puedes elegir cualquier elemento del DOM
html2pdf()
.set({
margin: 1,filename: 'documento.pdf',image: {
type: 'jpeg',quality: 0.98
},html2canvas: {
scale: 3,// A mayor escala,mejores gráficos,pero más peso
letterRendering: true,},jsPDF: {
unit: "in",format: "a3",orientation: 'portrait' // landscape o portrait
}
})
.from($elementoParaConvertir)
.save()
.output('./123123123.pdf','f')
.then(pdfResult => {
console.log(pdfResult);
})
.catch(err => console.log(err));
});
});
但我不知道如何将 pdf 发送到服务器或直接从前端保存,有谁知道我如何保存在我的服务器上生成的 pdf?非常感谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)