boazsegev / combine_pdf

A Pure ruby library to merge PDF files, number pages and maybe more...
MIT License
733 stars 154 forks source link

LIbreOffice / Scribus & embedding fonts #203

Closed MarcWeber closed 2 years ago

MarcWeber commented 2 years ago

Scribus PDF Versions 1.3 1.4 1.5 LibreOffice evince in properties shows embedded fonts (subset) But

        fonts = CombinePDF.new("scribus.pdf").fonts(true)
        puts fonts.inspect

shows empty array ? I tried false/true Library version is latest installed by gem.

Sample PDF I wanted to get fonts from: https://mawercer.de/tmp/tmp/scribus.pdf

boazsegev commented 2 years ago

Hi @MarcWeber ,

Thank you for opening this issue. The concern was that the page Resources data in your file was a reference and should have been dereferenced (but wasn't).

I am pushed a fix, and will publish soon.

I hope this helps.

Good luck, Bo.

MarcWeber commented 2 years ago

Works. but only with (false).

          if (limit_to_type0 || f[:Subtype] == :Type0) && f[:Type] == :Font && !fonts_array.include?(f)

My results: Scribus created PDF Preferences -> Fonts -> [ ] Subset by that font Didn't find ToUnicode object for {:Type=>:F.... -> failure

libre office:

script.rb:30:in []': no implicit conversion of Symbol into Integer (TypeError) from script.rb:30:inblock (2 levels) in fonts' from script.rb:29:in each' from script.rb:29:inblock in fonts' from script.rb:22:in each' from script.rb:22:infonts' from script.rb:46:in `

'

I monkey patched that function line 30 is: f = f[:referenced_object] if f[:referenced_object]

Adding this guard makes it work:

    r.values.each do |f|
      next if f.class == Integer

Now I have an ü and the turkish special umlauts :) Job complet. Thank you very much!

Libre Office file pdf file: https://mawercer.de/tmp/tmp/lo.pdf

I was close to trying pdfbox or itext.