pdfkit实现在浏览器中创建pdf文档并预览下载效果代码
代码语言:html
所属分类:其他
代码描述:pdfkit实现在浏览器中创建pdf文档并预览下载效果代码
代码标签: pdfkit 浏览器 创建 pdf 文档 预览 下载
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/pdfkit.standalone.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/blob-stream.js"></script> <div>PDF Output <button onclick="download()">Download</button></div> <iframe width="100%" height="800px"></iframe> <script> const doc = new PDFDocument(); // pipe the document to a blob const stream = doc.pipe(blobStream()); // add your content to the document here, as usual doc.fontSize(25).text("Some text with standard font!", 100, 100); // Add another page doc. addPage(). fontSize(25). text("Here is some vector graphics...", 100, 100); // Draw a triangle doc. save(). moveTo(100, 150). lineTo(100, 250). lineTo(200, 250). fill("#FF3300"); // Apply some transforms and render an SVG path with the 'even-odd' fill rule doc. scale(0.6). translate(470, -380). pa.........完整代码请登录后点击上方下载按钮下载查看
网友评论0