我有一张发票清单——我需要显示一个包含所有发票的打印对话框,然后用户可以将它们全部发送到打印机
I have a list of invoices - i need to display a print dialog with all invoices then the user can send them all to a printer
~html
click printSelectedInvoices();
~typescript
import * as pdfMake from 'pdfmake/build/pdfmake';
import * as pdfFonts from 'pdfmake/build/vfs_fonts';
printSelectedInvoices(){
invoiceArray.forEach((invoice) => {
var invoicePdf = {
// DESIGN
};
pdfMake.createPdf(invoicePdf).open({});
})
}
“目前,这是打开发票计数选项卡,可以单独打印。这应该是一个打印对话框,可以打印所有发票。有人知道怎么做吗?请帮帮我。”
安装 npm 模块:PDF-lib
npm i pdf-lib
import JsBarcode from 'jsbarcode/bin/JsBarcode'
import * as printJS from 'print-js';
import { PDFDocument } from 'pdf-lib'
invoiceJsArray.forEach(async (pdfs) => {
pdfMake.createPdf(pdfs).getBuffer(async function (buffer) {
const pdf = await PDFDocument.load(buffer);
const copiedPages = await mergedPdf.copyPages(pdf, pdf.getPageIndices());
copiedPages.forEach((page) => {
mergedPdf.addPage(page);
});
const mergedPdfFile = await mergedPdf.save();
const blob = new Blob([mergedPdfFile], { type: 'application/pdf' });
const url = window.URL.createObjectURL(blob);
// window.open(url);
printJS({
printable: url,
type: 'pdf',
})
})
});
~html
click printSelectedInvoices();
~typescript
import * as pdfMake from 'pdfmake/build/pdfmake';
import * as pdfFonts from 'pdfmake/build/vfs_fonts';
printSelectedInvoices(){
invoiceArray.forEach((invoice) => {
var invoicePdf = {
// DESIGN
};
pdfMake.createPdf(invoicePdf).open({});
})
}
“目前,这是打开发票计数选项卡,可以单独打印。这应该是一个打印对话框,可以打印所有发票。有人知道怎么做吗?请帮帮我。”
安装 npm 模块:PDF-lib
npm i pdf-lib
import JsBarcode from 'jsbarcode/bin/JsBarcode'
import * as printJS from 'print-js';
import { PDFDocument } from 'pdf-lib'
invoiceJsArray.forEach(async (pdfs) => {
pdfMake.createPdf(pdfs).getBuffer(async function (buffer) {
const pdf = await PDFDocument.load(buffer);
const copiedPages = await mergedPdf.copyPages(pdf, pdf.getPageIndices());
copiedPages.forEach((page) => {
mergedPdf.addPage(page);
});
const mergedPdfFile = await mergedPdf.save();
const blob = new Blob([mergedPdfFile], { type: 'application/pdf' });
const url = window.URL.createObjectURL(blob);
// window.open(url);
printJS({
printable: url,
type: 'pdf',
})
})
});