Embedded fonts different across runs
See original GitHub issueI’ve noticed that if I generate the same PDF twice in a row, the output is different because the fonts get embedded with some kind of random prefix. For example, if I keep the CreationDate
and ModDate
fixed by setting the metadata:
doc.info.CreationDate = new Date(Date.parse('2018-09-15'));
doc.info.ModDate = new Date(Date.parse('2018-09-15'));
Then if I produce the same document twice it will contain diffs like these:
--- /tmp/one.hex 2018-09-17 18:32:54.000000000 +0200
+++ /tmp/two.hex 2018-09-17 18:33:00.000000000 +0200
@@ -37,7 +37,7 @@
00000240: 3e0a 656e 646f 626a 0a31 3320 3020 6f62 >.endobj.13 0 ob
00000250: 6a0a 3c3c 0a2f 5479 7065 202f 466f 6e74 j.<<./Type /Font
00000260: 4465 7363 7269 7074 6f72 0a2f 466f 6e74 Descriptor./Font
-00000270: 4e61 6d65 202f 4552 4841 564e 2b50 6c61 Name /ERHAVN+Pla
+00000270: 4e61 6d65 202f 444b 4a49 4c57 2b50 6c61 Name /DKJILW+Pla
00000280: 7966 6169 7244 6973 706c 6179 2d52 6567 yfairDisplay-Reg
00000290: 756c 6172 0a2f 466c 6167 7320 340a 2f46 ular./Flags 4./F
000002a0: 6f6e 7442 426f 7820 5b2d 3636 3820 2d32 ontBBox [-668 -2
@@ -52,7 +52,7 @@
00000330: 6a0a 3c3c 0a2f 5479 7065 202f 466f 6e74 j.<<./Type /Font
00000340: 0a2f 5375 6274 7970 6520 2f43 4944 466f ./Subtype /CIDFo
00000350: 6e74 5479 7065 320a 2f42 6173 6546 6f6e ntType2./BaseFon
-00000360: 7420 2f45 5248 4156 4e2b 506c 6179 6661 t /ERHAVN+Playfa
+00000360: 7420 2f44 4b4a 494c 572b 506c 6179 6661 t /DKJILW+Playfa
00000370: 6972 4469 7370 6c61 792d 5265 6775 6c61 irDisplay-Regula
00000380: 720a 2f43 4944 5379 7374 656d 496e 666f r./CIDSystemInfo
00000390: 203c 3c0a 2f52 6567 6973 7472 7920 2841 <<./Registry (A
@@ -66,8 +66,8 @@
00000410: 3e3e 0a65 6e64 6f62 6a0a 3620 3020 6f62 >>.endobj.6 0 ob
00000420: 6a0a 3c3c 0a2f 5479 7065 202f 466f 6e74 j.<<./Type /Font
00000430: 0a2f 5375 6274 7970 6520 2f54 7970 6530 ./Subtype /Type0
-00000440: 0a2f 4261 7365 466f 6e74 202f 4552 4841 ./BaseFont /ERHA
-00000450: 564e 2b50 6c61 7966 6169 7244 6973 706c VN+PlayfairDispl
+00000440: 0a2f 4261 7365 466f 6e74 202f 444b 4a49 ./BaseFont /DKJI
+00000450: 4c57 2b50 6c61 7966 6169 7244 6973 706c LW+PlayfairDispl
00000460: 6179 2d52 6567 756c 6172 0a2f 456e 636f ay-Regular./Enco
00000470: 6469 6e67 202f 4964 656e 7469 7479 2d48 ding /Identity-H
00000480: 0a2f 4465 7363 656e 6461 6e74 466f 6e74 ./DescendantFont
@@ -76,7 +76,7 @@
000004b0: 656e 646f 626a 0a31 3720 3020 6f62 6a0a endobj.17 0 obj.
000004c0: 3c3c 0a2f 5479 7065 202f 466f 6e74 4465 <<./Type /FontDe
000004d0: 7363 7269 7074 6f72 0a2f 466f 6e74 4e61 scriptor./FontNa
-000004e0: 6d65 202f 4e52 474a 5454 2b51 7561 7474 me /NRGJTT+Quatt
+000004e0: 6d65 202f 4c4f 4554 5a54 2b51 7561 7474 me /LOETZT+Quatt
000004f0: 726f 6365 6e74 6f0a 2f46 6c61 6773 2034 rocento./Flags 4
00000500: 0a2f 466f 6e74 4242 6f78 205b 2d33 3020 ./FontBBox [-30
00000510: 2d32 3630 2031 3131 3620 3834 395d 0a2f -260 1116 849]./
@@ -90,7 +90,7 @@
00000590: 6a0a 3c3c 0a2f 5479 7065 202f 466f 6e74 j.<<./Type /Font
000005a0: 0a2f 5375 6274 7970 6520 2f43 4944 466f ./Subtype /CIDFo
000005b0: 6e74 5479 7065 320a 2f42 6173 6546 6f6e ntType2./BaseFon
-000005c0: 7420 2f4e 5247 4a54 542b 5175 6174 7472 t /NRGJTT+Quattr
+000005c0: 7420 2f4c 4f45 545a 542b 5175 6174 7472 t /LOETZT+Quattr
000005d0: 6f63 656e 746f 0a2f 4349 4453 7973 7465 ocento./CIDSyste
000005e0: 6d49 6e66 6f20 3c3c 0a2f 5265 6769 7374 mInfo <<./Regist
000005f0: 7279 2028 4164 6f62 6529 0a2f 4f72 6465 ry (Adobe)./Orde
@@ -116,8 +116,8 @@
00000730: 0a3e 3e0a 656e 646f 626a 0a39 2030 206f .>>.endobj.9 0 o
00000740: 626a 0a3c 3c0a 2f54 7970 6520 2f46 6f6e bj.<<./Type /Fon
00000750: 740a 2f53 7562 7479 7065 202f 5479 7065 t./Subtype /Type
-00000760: 300a 2f42 6173 6546 6f6e 7420 2f4e 5247 0./BaseFont /NRG
-00000770: 4a54 542b 5175 6174 7472 6f63 656e 746f JTT+Quattrocento
+00000760: 300a 2f42 6173 6546 6f6e 7420 2f4c 4f45 0./BaseFont /LOE
+00000770: 545a 542b 5175 6174 7472 6f63 656e 746f TZT+Quattrocento
00000780: 0a2f 456e 636f 6469 6e67 202f 4964 656e ./Encoding /Iden
00000790: 7469 7479 2d48 0a2f 4465 7363 656e 6461 tity-H./Descenda
000007a0: 6e74 466f 6e74 7320 5b31 3820 3020 525d ntFonts [18 0 R]
@@ -125,7 +125,7 @@
000007c0: 2052 0a3e 3e0a 656e 646f 626a 0a32 3120 R.>>.endobj.21
000007d0: 3020 6f62 6a0a 3c3c 0a2f 5479 7065 202f 0 obj.<<./Type /
000007e0: 466f 6e74 4465 7363 7269 7074 6f72 0a2f FontDescriptor./
-000007f0: 466f 6e74 4e61 6d65 202f 4355 4845 5252 FontName /CUHERR
+000007f0: 466f 6e74 4e61 6d65 202f 4f59 4441 4e43 FontName /OYDANC
00000800: 2b50 6c61 7966 6169 7244 6973 706c 6179 +PlayfairDisplay
00000810: 2d42 6f6c 640a 2f46 6c61 6773 2034 0a2f -Bold./Flags 4./
00000820: 466f 6e74 4242 6f78 205b 2d37 3034 202d FontBBox [-704 -
@@ -140,7 +140,7 @@
000008b0: 626a 0a3c 3c0a 2f54 7970 6520 2f46 6f6e bj.<<./Type /Fon
000008c0: 740a 2f53 7562 7479 7065 202f 4349 4446 t./Subtype /CIDF
000008d0: 6f6e 7454 7970 6532 0a2f 4261 7365 466f ontType2./BaseFo
-000008e0: 6e74 202f 4355 4845 5252 2b50 6c61 7966 nt /CUHERR+Playf
+000008e0: 6e74 202f 4f59 4441 4e43 2b50 6c61 7966 nt /OYDANC+Playf
000008f0: 6169 7244 6973 706c 6179 2d42 6f6c 640a airDisplay-Bold.
00000900: 2f43 4944 5379 7374 656d 496e 666f 203c /CIDSystemInfo <
00000910: 3c0a 2f52 6567 6973 7472 7920 2841 646f <./Registry (Ado
@@ -165,7 +165,7 @@
00000a40: 3130 2030 206f 626a 0a3c 3c0a 2f54 7970 10 0 obj.<<./Typ
00000a50: 6520 2f46 6f6e 740a 2f53 7562 7479 7065 e /Font./Subtype
00000a60: 202f 5479 7065 300a 2f42 6173 6546 6f6e /Type0./BaseFon
-00000a70: 7420 2f43 5548 4552 522b 506c 6179 6661 t /CUHERR+Playfa
+00000a70: 7420 2f4f 5944 414e 432b 506c 6179 6661 t /OYDANC+Playfa
00000a80: 6972 4469 7370 6c61 792d 426f 6c64 0a2f irDisplay-Bold./
00000a90: 456e 636f 6469 6e67 202f 4964 656e 7469 Encoding /Identi
00000aa0: 7479 2d48 0a2f 4465 7363 656e 6461 6e74 ty-H./Descendant
(These diffs produced by dumping the hex with xxd one.pdf > one.hex
and then comparing with diff -U 3 {one,two}.hex
.)
It would be nice if running the same generation process twice in a row with the same inputs produced the exact same output (byte for byte). I’m committing these build artifacts to a gh-pages branch, and the churn in the PDFs is making the commits noisier than they need to be.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Some fonts are not embedded when you save a PowerPoint ...
Under Preserve fidelity when sharing this presentation, select the Embed fonts in the file check box. Select OK, and then select Save.
Read more >Embedded Fonts | Documents for Word, .NET Edition
GcWord provides extensive API to enable users to define custom fonts, embed them in the Word document, apply them to the runs and...
Read more >Embedding Fonts in PowerPoint: Not just for PCs any more!
But when you embed a font into your PowerPoint file, that font moves along with the file, meaning it can be opened on...
Read more >How to Embed Fonts in PDFs (and Why You Need to Do It)
How to embed fonts in PDF using Adobe programs · Click on the File menu, and choose Print · Click Adobe PDF ·...
Read more >wpf - Embedded fonts works for designer but not for application
I think, you have to add the font file to your project and set its BuildAction to Resource. · It is added as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The ‘xx’ was just a placeholder for actual date
I think the best solution would be to generate a string from a hash of the font data. That way it should be unique to the font and also consistent across runs.