gettalong / hexapdf

Versatile PDF creation and manipulation for Ruby
https://hexapdf.gettalong.org
Other
1.21k stars 69 forks source link

Exception when using CLI fonts command #265

Closed robertp closed 10 months ago

robertp commented 11 months ago
hexapdf fonts tardigrade-dietary-preferences.pdf
 page name                                     type         encoding   emb sub     size       oid
-------------------------------------------------------------------------------------------------
    1 RFDHQF+GandhariUnicode-Italic            Type 1C      Custom     yes yes     524B      58,0
    1 TICTSB+NewCenturySchlbk-Bold             Type 1C      Custom     yes yes    5959B      59,0
    1 VLBFUX+NewCenturySchlbk-Italic           Type 1C      WinAnsi    yes yes    6708B      60,0
    1 XOFRWT+NewCenturySchlbk-Roman            Type 1C      Custom     yes yes    8621B      61,0
    1 DCTYIR+ArialMT                           TrueType     WinAnsi    yes yes    29.2K       1,0
Problem encountered: undefined method `ressources' for #<HexaPDF::Type::Form [68, 0] value={:Subtype=>:Form, :BBox=>[0.0, 782.362, 595.276, 0.0], :Resources=>{:ExtGState=>{:GS0=>#<HexaPDF::Reference [63, 0]>}}, :Filter=>:FlateDecode, :Length=>80, :Matrix=>[1.0, 0.0, 0.0, 1.0, 0.0, 0.0]}>
Did you mean?  resources
--> The problem might indicate a faulty PDF or a bug in HexaPDF.
--> Please report this at https://github.com/gettalong/hexapdf/issues - thanks!

When I manually edit lib/hexapdf/cli/fonts.rb line 130 to correct the error, it works:

xobj.ressources[:Font]&.each(&font_proc) -> xobj.resources[:Font]&.each(&font_proc):

hexapdf fonts tardigrade-dietary-preferences.pdf
 page name                                     type         encoding   emb sub     size       oid
-------------------------------------------------------------------------------------------------
    1 RFDHQF+GandhariUnicode-Italic            Type 1C      Custom     yes yes     524B      58,0
    1 TICTSB+NewCenturySchlbk-Bold             Type 1C      Custom     yes yes    5959B      59,0
    1 VLBFUX+NewCenturySchlbk-Italic           Type 1C      WinAnsi    yes yes    6708B      60,0
    1 XOFRWT+NewCenturySchlbk-Roman            Type 1C      Custom     yes yes    8621B      61,0
    1 DCTYIR+ArialMT                           TrueType     WinAnsi    yes yes    29.2K       1,0
    2 PCEVOJ+NewCenturySchlbk-Roman-SC800      Type 1C      WinAnsi    yes yes    2622B      71,0
    2 QGOBCH+GandhariUnicode-Roman             Type 1C      Custom     yes yes    1205B      72,0
    6 NZFJMN+NewCenturySchlbk-BoldItalic       Type 1C      WinAnsi    yes yes    2435B      83,0
    7 LWBXKR+Calibri-BoldItalic                Type 1C      WinAnsi    yes yes    3810B      88,0
    7 LWBXKR+Calibri-Bold                      Type 1C      WinAnsi    yes yes    2120B      89,0
    7 MVQDYP+Calibri                           Type 1C      WinAnsi    yes yes    6013B      90,0
    8 JTCLIV+Calibri-LightItalic               Type 1C      WinAnsi    yes yes    3998B      94,0
    8 KSRRWT+Calibri-LightItalic               Type 1C      WinAnsi    yes yes    2473B      95,0
    8 LWBXKR+Calibri-Light                     Type 1C      WinAnsi    yes yes    6067B      96,0
    8 JTCLIV+Calibri-Light                     Type 1C      WinAnsi    yes yes    5956B      97,0
   12 IPSFUX+GandhariUnicode-Bold              Type 1C      Custom     yes yes     622B     106,0