add single-page pdf export
This commit is contained in:
parent
bf417a201f
commit
2867b9c340
6 changed files with 83 additions and 45 deletions
|
@ -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()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue