1
0
Fork 0

add single-page pdf export

This commit is contained in:
Enoch Riese 2023-08-06 18:24:14 +00:00
parent bf417a201f
commit 2867b9c340
6 changed files with 83 additions and 45 deletions

View file

@ -0,0 +1,23 @@
import { Pdf, mmToPoints } from './pdf.mjs'
import SVGtoPDF from 'svg-to-pdfkit'
/**
* Basic exporter for a single-page pdf containing the rendered pattern.
* This generates a PDF that is the size of the pattern and has no additional frills*/
export class SinglePdfMaker {
pdf
svg
constructor({ svg, pageSettings }) {
this.pdf = Pdf({ size: pageSettings.size.map((s) => s * mmToPoints) })
this.svg = svg
}
async makePdf() {
await SVGtoPDF(this.pdf, this.svg)
}
async toBlob() {
return this.pdf.toBlob()
}
}