Files
pdfme/packages/generator/__tests__/utils.ts
Kyohei Fukuda a3a2b0bdc6 [WIP] V4 (#427)
* Reconsider the internal data types and the template types (#389)

* Change SchemaForUI's data and readOnlyValue to content

* Fix bug

* Remove sampledata and instead always use content. & Use content regardless of readOnly or not. & Eliminate defaultValue and replace it with always using content.

* Change website template

* Fix placeholder bug

* Change generator test template

* Change content to optional

* Move getInputFromTemplate to common

* Remove columns

* Fix test

* move dynamictable.excalidraw

* remove idea dir

* New basePdf type and Support adding new pages to template (#394)

* Minor fix

* IMPL Support adding new pages to template #111

* Fix test

* Minor fix

* IMPL padding behavior

* Update snapshot

* Minor fix

* Update snapshot

* add i18n

* remove option from BlankPdf.padding

* Minor fix

* Minor fix

* format

* Add changeSchemas unit test (#403)

* Minor fix

* Add a version number to pdfme template from V4 onwards (#404)

* Impl

* Minor fix

* Padding move width (#407)

* Refactor position and size handling in helper.ts

* Fix bug

* Add DynamicTable Schema #332 (#408)

* [tmp] add some comment

* Update snapshot

* Add deploy-table script to package.json

* add new template for playground

* bug fix for form

* fix cell editing bug

* Fix Adding rows doesn't change the overall height of the table

* fix padding problem

* Fix build error

* Fix bug

* Minor fix

* Fix New lines not reflecting correctly

* minor fix

* Minor fix

* Change tableStyles def

* add i18n

* small bugfix

* FIx some TODO

* Remove japanese comment

* Minor fix

* Fix infinity loom for form

* fix save inputs bug

* fix window resize bug

* add skip for failing test and update snapshot

* Minor fix

* add presets for playground

* Minor fix

* Reconsider the internal data types and the template types (#389)

* Change SchemaForUI's data and readOnlyValue to content

* Fix bug

* Remove sampledata and instead always use content. & Use content regardless of readOnly or not. & Eliminate defaultValue and replace it with always using content.

* Change website template

* Fix placeholder bug

* Change generator test template

* Change content to optional

* Move getInputFromTemplate to common

* Remove columns

* Fix test

* move dynamictable.excalidraw

* remove idea dir

* New basePdf type and Support adding new pages to template (#394)

* Minor fix

* IMPL Support adding new pages to template #111

* Fix test

* Minor fix

* IMPL padding behavior

* Update snapshot

* Minor fix

* Update snapshot

* add i18n

* remove option from BlankPdf.padding

* Minor fix

* Minor fix

* format

* Add changeSchemas unit test (#403)

* Minor fix

* Add a version number to pdfme template from V4 onwards (#404)

* Impl

* Minor fix

* Padding move width (#407)

* Refactor position and size handling in helper.ts

* Fix bug

* Add DynamicTable Schema #332 (#408)

* [tmp] add some comment

* Update snapshot

* Add deploy-table script to package.json

* add new template for playground

* bug fix for form

* fix cell editing bug

* Fix Adding rows doesn't change the overall height of the table

* fix padding problem

* Fix build error

* Fix bug

* Minor fix

* Fix New lines not reflecting correctly

* minor fix

* Minor fix

* Change tableStyles def

* add i18n

* small bugfix

* FIx some TODO

* Remove japanese comment

* Minor fix

* Fix infinity loom for form

* fix save inputs bug

* fix window resize bug

* add skip for failing test and update snapshot

* Minor fix

* add presets for playground

* Minor fix

* Minor fix

* Update imports and fix font rendering

* Add a Left Sidebar for Placing Schemas #400 (#452)

* Remove original 'Add new field' Button

* add icon

* FIx drag position bug

* Minor fix

* Fix sidebar position

* Update snapshot

* Minor fix

* Update packages/ui/src/components/Designer/index.tsx

Co-authored-by: Peter Ward <pete@pennyblack.io>

---------

Co-authored-by: Peter Ward <pete@pennyblack.io>

* Fix test

* Improve left sidebar icon drop placement accuracy (#454)

* Fix Spanish translations for v4 (#463)

* Fix #431

* V4 (#467)

* feat: add french language

* feat: relecture

* feat: add french language

---------

Co-authored-by: regis <regis>

* Add French language option to playground

* rename table export name to tableBeta

---------

Co-authored-by: Peter Ward <pete@pennyblack.io>
Co-authored-by: Iker Diez <32014358+ikerd@users.noreply.github.com>
Co-authored-by: Régis <regis.charnace@leandco.fr>
2024-04-11 09:43:36 +09:00

48 lines
1.9 KiB
TypeScript

import { readFileSync } from 'fs';
import * as path from 'path';
import { Font } from '@pdfme/common';
const PDFParser = require('pdf2json');
const SauceHanSansJPData = readFileSync(path.join(__dirname, `/assets/fonts/SauceHanSansJP.ttf`));
const SauceHanSerifJPData = readFileSync(path.join(__dirname, `/assets/fonts/SauceHanSerifJP.ttf`));
const NotoSerifJPRegularData = readFileSync(
path.join(__dirname, `/assets/fonts/NotoSerifJP-Regular.otf`)
);
const NotoSansJPRegularData = readFileSync(
path.join(__dirname, `/assets/fonts/NotoSansJP-Regular.otf`)
);
const GloriaHallelujahRegularData = readFileSync(
path.join(__dirname, `/assets/fonts/GloriaHallelujah-Regular.ttf`)
);
const GreatVibesRegularData = readFileSync(
path.join(__dirname, `/assets/fonts/GreatVibes-Regular.ttf`)
);
const JuliusSansOneRegularData = readFileSync(
path.join(__dirname, `/assets/fonts/JuliusSansOne-Regular.ttf`)
);
export const getFont = (): Font => ({
SauceHanSansJP: { fallback: true, data: SauceHanSansJPData },
SauceHanSerifJP: { data: SauceHanSerifJPData },
'NotoSerifJP-Regular': { data: NotoSerifJPRegularData },
'NotoSansJP-Regular': { data: NotoSansJPRegularData },
'GloriaHallelujah-Regular': { data: GloriaHallelujahRegularData },
'GreatVibes-Regular': { data: GreatVibesRegularData },
'JuliusSansOne-Regular': { data: JuliusSansOneRegularData },
});
export const getPdf = (pdfFilePath: string) => {
const pdfParser = new PDFParser();
return new Promise((resolve, reject) => {
pdfParser.on('pdfParser_dataError', reject);
pdfParser.on('pdfParser_dataReady', resolve);
pdfParser.loadPDF(pdfFilePath);
});
};
const getPdfPath = (dir: string, fileName: string) =>
path.join(__dirname, `assets/pdfs/${dir}/${fileName}`);
export const getPdfTmpPath = (fileName: string) => getPdfPath('tmp', fileName);
export const getPdfAssertPath = (fileName: string) => getPdfPath('assert', fileName);