mirror of
https://github.com/Elvanos/fantasia-archive.git
synced 2024-09-30 00:56:59 +13:00
PDFkit fixes
This commit is contained in:
parent
08b161baf3
commit
a5ded58d3e
1 changed files with 9 additions and 11 deletions
|
@ -308,6 +308,9 @@ import RobotoBold from "src/assets/fonts/Roboto-Bold.ttf"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class ExportProject extends DialogBase {
|
export default class ExportProject extends DialogBase {
|
||||||
|
RobotoRegular = RobotoRegular
|
||||||
|
RobotoBold = RobotoBold
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* React to dialog opening request
|
* React to dialog opening request
|
||||||
*/
|
*/
|
||||||
|
@ -549,7 +552,10 @@ export default class ExportProject extends DialogBase {
|
||||||
|
|
||||||
// PDF
|
// PDF
|
||||||
if (this.selectedExportFormat === "Adobe Reader - PDF") {
|
if (this.selectedExportFormat === "Adobe Reader - PDF") {
|
||||||
this.exportFile_PDF(exportObject, exportPath)
|
const normalFontContents = fs.readFileSync(path.resolve(__dirname, "../../assets/fonts/Roboto-Regular.ttf"))
|
||||||
|
const boldFontContents = fs.readFileSync(path.resolve(__dirname, "../../assets/fonts/Roboto-Bold.ttf"))
|
||||||
|
|
||||||
|
this.exportFile_PDF(exportObject, exportPath, normalFontContents, boldFontContents)
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.sleep(5)
|
await this.sleep(5)
|
||||||
|
@ -914,7 +920,7 @@ export default class ExportProject extends DialogBase {
|
||||||
fs.writeFileSync(`${documentDirectory}/${exportFileName}.md`, mdContent)
|
fs.writeFileSync(`${documentDirectory}/${exportFileName}.md`, mdContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
exportFile_PDF (input: I_ExportObject, exportPath: string) {
|
exportFile_PDF (input: I_ExportObject, exportPath: string, normalFontContents : any, boldFontContents: any) {
|
||||||
const { documentDirectory, exportFileName } = this.fixExportPaths(exportPath, input)
|
const { documentDirectory, exportFileName } = this.fixExportPaths(exportPath, input)
|
||||||
|
|
||||||
const textFont = 11
|
const textFont = 11
|
||||||
|
@ -928,14 +934,6 @@ export default class ExportProject extends DialogBase {
|
||||||
paragraphGap: 8
|
paragraphGap: 8
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalFont = RobotoRegular
|
|
||||||
const boldFont = RobotoBold
|
|
||||||
|
|
||||||
console.log(path.resolve(__dirname, "../../assets/fonts/Roboto-Regular.ttf"))
|
|
||||||
|
|
||||||
const normalFontContents = fs.readFileSync(path.resolve(__dirname, "../../assets/fonts/Roboto-Regular.ttf"))
|
|
||||||
const boldFontContents = fs.readFileSync(path.resolve(__dirname, "../../assets/fonts/Roboto-Bold.ttf"))
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||||
const doc: I_PDFKitDocument = new PDFkit({ size: "A4" })
|
const doc: I_PDFKitDocument = new PDFkit({ size: "A4" })
|
||||||
|
|
||||||
|
@ -1034,7 +1032,7 @@ export default class ExportProject extends DialogBase {
|
||||||
wysiwygOptions.underline = node.attrs.underline
|
wysiwygOptions.underline = node.attrs.underline
|
||||||
|
|
||||||
// Bold
|
// Bold
|
||||||
doc.font((node?.attrs?.bold) ? boldFont : normalFont)
|
doc.font((node?.attrs?.bold) ? "Roboto-Bold" : "Roboto-Regular")
|
||||||
|
|
||||||
// Heading font sizing
|
// Heading font sizing
|
||||||
if (node?.attrs?.hasHeadingFontSize) {
|
if (node?.attrs?.hasHeadingFontSize) {
|
||||||
|
|
Loading…
Reference in a new issue