Skip to content

Commit

Permalink
Merge pull request #241 from s1seven/embed-json-into-pdf
Browse files Browse the repository at this point in the history
feat: embed json certificate into pdf
  • Loading branch information
christophbuehler authored Mar 1, 2024
2 parents 6810f52 + a3592b7 commit 7ffabb1
Show file tree
Hide file tree
Showing 61 changed files with 893 additions and 576 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ npm install
npm run build
```

Make sure you have installed ImageMagick and GhostScript on your system. This is required for testing the PDF generation.

```sh
# MacOS
brew install graphicsmagick
brew install ghostscript
# Linux
sudo apt-get install graphicsmagick
sudo apt-get install ghostscript
```

## Development

When working on changes that affects multiple packages, you should rebuild them when they are declared as dependencies in order for those changes to be effective.
Expand Down Expand Up @@ -144,13 +155,13 @@ npm run fixtures:interfaces -- -s ../CoA-schemas/schema.json -o packages/generat
To generate `template_hbs.html` (HTML certificate generated from Handlebars template), from the root directory, run the following command, updating the version number and schema name :

```sh
npm run fixtures:html -- -c fixtures/CoA/v1.0.0/valid_cert.json -o fixtures/CoA/v1.0.0/template_hbs.html -t fixtures/CoA/v1.0.0/translations.json -T ../CoA-schemas/template.hbs -e fixtures/CoA/v1.0.0/extra_translations.json -p ../CoA-schemas/partials-map.json
npm run fixtures:html -- -c fixtures/CoA/v1.0.0/valid_cert.json -o fixtures/CoA/v1.0.0/valid_cert.html -t fixtures/CoA/v1.0.0/translations.json -T ../CoA-schemas/template.hbs -e fixtures/CoA/v1.0.0/extra_translations.json -p ../CoA-schemas/partials-map.json
```

For EN10168

```sh
npm run fixtures:html -- -c fixtures/EN10168/v0.4.1/valid_cert.json -o fixtures/EN10168/v0.4.1/template_hbs.html -t fixtures/EN10168/v0.4.1/translations.json -T ../EN10168-schemas/template.hbs -p ../EN10168-schemas/partials-map.json
npm run fixtures:html -- -c fixtures/EN10168/v0.4.1/valid_cert.json -o fixtures/EN10168/v0.4.1/valid_cert.html -t fixtures/EN10168/v0.4.1/translations.json -T ../EN10168-schemas/template.hbs -p ../EN10168-schemas/partials-map.json
```

If external translations are not needed, remove the `-e` command from the above command.
Expand All @@ -163,7 +174,7 @@ If you get an error that a partial could not be loaded, make sure that the full
To generate `valid_cert.pdf` (PDF certificate generated from JS generator), from the root directory, run the following command, updating the version number and schema name :

```sh
npm run fixtures:pdf -- -c fixtures/CoA/v1.0.0/valid_cert.json -o fixtures/CoA/v1.0.0/valid_cert.pdf -t fixtures/CoA/v1.0.0/translations.json -g ../CoA-schemas/generate-pdf.min.js -s ../CoA-schemas/generate-pdf.styles.json -e fixtures/CoA/v1.0.0/extra_translations.json
npm run fixtures:pdf -- -c fixtures/CoA/v1.1.0/valid_cert.json -o fixtures/CoA/v1.1.0/valid_cert.pdf -t fixtures/CoA/v1.1.0/translations.json -g ../CoA-schemas/generate-pdf.min.js -s ../CoA-schemas/generate-pdf.styles.json -e fixtures/CoA/v1.1.0/extra_translations.json

# or using remote resources
npm run fixtures:pdf -- -c fixtures/EN10168/v0.3.0/valid_cert.json -o fixtures/EN10168/v0.3.0/valid_cert.pdf -t 'fixtures/EN10168/v0.3.0/translations.json' -g 'https://schemas.s1seven.com/en10168-schemas/v0.3.0/generate-pdf.min.js' -s 'https://schemas.s1seven.com/en10168-schemas/v0.3.0/generate-pdf.styles.json'
Expand Down
6 changes: 3 additions & 3 deletions fixtures/CoA/v1.0.0/valid_cert.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ <h3>Green Plastics AG</h3>
<th class='table-cells' colspan='4'>
Kunde / Customer
</th>
<th class='table-cells' colspan='6'>
Warenempfänger / Recipient
</th>
<th class='table-cells' colspan='6'>
Warenempfänger / Recipient
</th>
</tr>
<tr class='table-rows'>
<td class='table-cells' colspan='4'>
Expand Down
Binary file modified fixtures/CoA/v1.0.0/valid_cert.pdf
Binary file not shown.
Binary file modified fixtures/CoA/v1.1.0/valid_cert.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion fixtures/EN10168/v0.0.2/valid_cert.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@import url(https://fonts.googleapis.com/css?family=Lato:300,400,700);

html {
font-family: 'Lato', sans-serif;
font-family: "Lato", sans-serif;
font-size: 14px;
text-align: justify;
max-width: 2480px;
Expand Down
2 changes: 1 addition & 1 deletion fixtures/EN10168/v0.4.1/valid_cert.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="version" content="v1.0.0" />
<style rel="stylesheet" type="text/css">
@import url(https://fonts.googleapis.com/css?family=Lato:300,400,700);

html {
font-family: "Lato", sans-serif;
font-size: 14px;
Expand Down
Binary file modified fixtures/EN10168/v0.4.1/valid_cert.pdf
Binary file not shown.
Binary file added fixtures/fonts/NotoSans-Bold.ttf
Binary file not shown.
Binary file added fixtures/fonts/NotoSans-Italic.ttf
Binary file not shown.
Binary file added fixtures/fonts/NotoSans-Light.ttf
Binary file not shown.
Binary file added fixtures/fonts/NotoSans-Regular.ttf
Binary file not shown.
Binary file added fixtures/fonts/NotoSansSC-Bold.ttf
Binary file not shown.
Binary file added fixtures/fonts/NotoSansSC-Light.ttf
Binary file not shown.
Binary file added fixtures/fonts/NotoSansSC-Regular.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 7ffabb1

Please sign in to comment.