gpt4 book ai didi

javascript - 使用 Angular 4、jsPDF、html2canvas 从 HTML/CSS 字符串生成 PDF

转载 作者:行者123 更新时间:2023-11-30 14:40:31 24 4
gpt4 key购买 nike

我正在尝试使用 css 生成 pdf,但没有取得太大的成功。我有一个包含带有内联 css 的 html 的字符串,但是当我使用 jsPDF 时,生成的 PDF 不包含样式。我读到为了包含样式,我还应该使用 html2canvas,然后使用 jsPDF 添加图像。但是,这些都不适合我。

这是我的代码:

@Component({
selector: 'app-pdf-generator',
templateUrl: './pdf-generator.component.html',
styleUrls: ['./pdf-generator.component.css'],
host: { '[@routeAnimation]': 'true', 'style' : 'display:block;' }

onSubmit()
{
let servers = this.serversService.getServers();
var rows = this.buildServerListByOptions(servers)
var htmlText = this.buildPdfText(rows); //the final html string I want to render on a PDF file.


//Here I need to genereate a DOM element, create an image of it using html2canvas, and then save as PDF. I **don't** want the element to appear on the page though, only in the PDF file.

// doc.addImage(canvas, 0,0,100,100);
// doc.save('report.pdf')

尽管阅读了我在网上能找到的所有内容,但我仍然无法使用 html2canvas 库。我希望能提供与我的示例相关的代码示例(动态创建 DOM 元素、创建它的图像、添加到 PDF)或者使用 angular 生成具有 CSS 支持的 PDF 的另一种方法。

谢谢!

最佳答案

这里有一个生成 pdf 的例子供你引用。但是这里我没有使用 html2canvas 来做样式。希望对您有所帮助:

在 HTML 中:

<a class="page-link" style="  (click)="convert()">Generate PDF</a>

在 TS 文件中:

import * as jsPDF from 'jspdf';
import 'jspdf-autotable';

并使用下面的函数:

convert() {

var doc = new jsPDF();
var col = ["Id", "TypeID","Accnt","Amnt","Start","End","Contrapartida"];
var rows = [];

var imgData = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBaRXhpZgAATU0AKgAAAAgABQMBAAUAAAABAAAASgMDAAEAAAABAAAAAFEQAAEAAAABAQAAAFERAAQAAAABAAAOw1ESAAQAAAABAAAOwwAAAAAAAYagAACxj//bAEMABwUFBgUEBwYFBggHBwgKEQsKCQk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UUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9k='




var rowCountModNew = [
["1721079361", "0001", "2100074911", "200", "22112017", "23112017", "51696"],
["1721079362", "0002", "2100074912", "300", "22112017", "23112017", "51691"],
["1721079363", "0003", "2100074913", "400", "22112017", "23112017", "51692"],
["1721079364", "0004", "2100074914", "500", "22112017", "23112017", "51693"]
]


rowCountModNew.forEach(element => {
rows.push(element);

});



doc.addImage(imgData, 'JPEG', 90, 60, 20, 20);


doc.autoTable(col, rows);
doc.save('Test.pdf');
}

在表格前后添加文字:

convert() {       
var doc = new jsPDF();
var col = ["Id", "TypeID","Accnt","Amnt","Start","End","Contrapartida"];
var rows = [];
var imgData = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBaRXhpZgAATU0AKgAAAAgABQMBAAUAAAABAAAASgMDAAEAAAABAAAAAFEQAAEAAAABAQAAAFERAAQAAAABAAAOw1ESAAQAAAABAAAOwwAAAAAAAYagAACxj//bAEMABwUFBgUEBwYFBggHBwgKEQsKCQkKFQ8QDBEYFRoZGBUYFxseJyEbHSUdFxgiLiIlKCkrLCsaIC8zLyoyJyorKv/bAEMBBwgICgkKFAsLFCocGBwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKv/AABEIAPwBwAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APpGiiqWo6lFp8G+QFnP3UHU0AOuILiYlUuWt19Y1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RQAUUUUAFFFFABRRRQAUUUUAf/9k='


var rowCountModNew = [
["1721079361", "0001", "2100074911", "200", "22112017", "23112017", "51696"],
["1721079362", "0002", "2100074912", "300", "22112017", "23112017", "51691"],
["1721079363", "0003", "2100074913", "400", "22112017", "23112017", "51692"],
["1721079364", "0004", "2100074914", "500", "22112017", "23112017", "51693"]
]

rowCountModNew.forEach(element => {
rows.push(element);
});

doc.text(80, 20, 'Report Final');
doc.addImage(imgData, 'JPEG', 90, 40, 20, 20);
doc.autoTable(col, rows,{startY: 60});
doc.text(80, 130, 'Thank you');
doc.save('Test.pdf');
}

它看起来像:enter image description here

关于javascript - 使用 Angular 4、jsPDF、html2canvas 从 HTML/CSS 字符串生成 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49758455/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com