mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.12k stars 9.94k forks source link

XFA Only some pages render #13597

Closed JDziurlaj closed 3 years ago

JDziurlaj commented 3 years ago

Attach (recommended) or Link to PDF file here: http://help.adobe.com/en_US/livecycle/11.0/SampleForms/941/Form.pdf

Steps to reproduce the problem:

  1. Enable XFA support
  2. Open form

What is the expected behavior? (add screenshot) Page 3 (of 4) renders image

What went wrong? (add screenshot) Only 3 pages total render in pdf.js

symtalha14 commented 3 years ago

Now it is rendering all 4 pages. Close this issue maybe.

Snuffleupagus commented 3 years ago

There's overlapping text/fields on the first page, possibly related to all of the font warnings:

Warning: XFA - Cannot find the font: HelveticaNeueLT Std pdf.worker.js:1104:13
Warning: XFA - Cannot find the font: HelveticaNeueLT Std Blk Cn pdf.worker.js:1104:13
Warning: XFA - Cannot find the font: ITC Franklin Gothic Std Book pdf.worker.js:1104:13
Warning: XFA - Cannot find the font: OCR A Std pdf.worker.js:1104:13
Warning: XFA - Cannot find the font: Times pdf.worker.js:1104:13
Warning: XFA - Cannot find the font: Universal Std News w Comm Pi pdf.worker.js:1104:13
Warning: XFA - Cannot find the font: ITC Zapf Dingbats Std pdf.worker.js:1104:13
Warning: XFA - Cannot find the font: HelveticaNeueLT Std Blk pdf.worker.js:1104:13
Warning: XFA - Cannot find the font: HelveticaNeueLT Std Bold Outln pdf.worker.js:1104:13
calixteman commented 3 years ago

config stream contains a map for font substitution:

<fontInfo>
  <embed>0</embed> <!-- 0|1 -->
    <!--defaultTypeface>MyriadPro-Regular</defaultTypeface-->
    <map>
      <!-- [0..n] Attributes: from='', to='' [0..n]  -->
      <equate force="0" from="Courier_*_*" to="Courier New_*_*"/>
      <equate force="0" from="CourierNew_*_*" to="Courier New_*_*"/>
      <equate force="0" from="Courier-New_*_*" to="Courier New_*_*"/>
      <equate force="0" from="MyriadPro_*_*" to="Myriad Pro_*_*"/>
      <equate force="0" from="MyriadPro-Regular_*_*" to="Myriad Pro_*_*"/>
      <equate force="0" from="MyriadPro-It_*_*" to="Myriad Pro_*_italic"/>
      <equate force="0" from="MyriadPro-SemiboldSemiCn_*_*" to="Arial Narrow_bold_*"/>
...

This pdf doesn't contain any fonts.

calixteman commented 3 years ago

We should probably always fallback on the fake myriad when the font isn't available.