Module: HexaPDF::Filter::BrotliDecode
- Defined in:
- lib/hexapdf/filter/brotli_decode.rb
Overview
Implements the Brotli filter using the brotli library which must be installed manually.
The BrotliDecode specification is not yet available as a standard but will be in the near future. Therefore it is recommended to wait using it for encoding streams until most of the PDF ecosystem has support for it.
See: HexaPDF::Filter
Class Method Summary collapse
-
.decoder(source, options = nil) ⇒ Object
See HexaPDF::Filter.
-
.encoder(source, options = nil) ⇒ Object
See HexaPDF::Filter.
Class Method Details
.decoder(source, options = nil) ⇒ Object
See HexaPDF::Filter
Note that the brotli gem currently doesn’t support a streaming decoder. This means that the whole source must be read and decoded at once.
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/hexapdf/filter/brotli_decode.rb', line 58 def self.decoder(source, = nil) fib = Fiber.new do data = Filter.string_from_source(source) data.empty? ? data: Brotli.inflate(data) end if && [:Predictor] Predictor.decoder(fib, ) else fib end end |
.encoder(source, options = nil) ⇒ Object
See HexaPDF::Filter
As with ::decoder a usable streaming encoder is not available.
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/hexapdf/filter/brotli_decode.rb', line 74 def self.encoder(source, = nil) if && [:Predictor] source = Predictor.encoder(source, ) end Fiber.new do Brotli.deflate(Filter.string_from_source(source), quality: HexaPDF::GlobalConfiguration['filter.brotli.compression']) end end |