View Source Mudbrick.Parser (mudbrick v0.9.0)
Parse documents generated with Mudbrick back into Elixir. Useful for testing.
Eventually this module may support documents generated with other PDF processors.
Summary
Functions
Extract text content from a Mudbrick-generated PDF. Will map glyphs back to their original characters.
Parse Mudbrick-generated iodata
into a Mudbrick.Document
.
Parse a section of a Mudbrick-generated PDF with a named parsing function. Mostly useful for debugging this parser.
Functions
Extract text content from a Mudbrick-generated PDF. Will map glyphs back to their original characters.
With compression
iex> import Mudbrick.TestHelper
...> import Mudbrick
...> new(compress: true, fonts: %{bodoni: bodoni_regular(), franklin: franklin_regular()})
...> |> page()
...> |> text({"hello, world!", underline: [width: 1]}, font: :bodoni)
...> |> text("hello in another font", font: :franklin)
...> |> Mudbrick.render()
...> |> Mudbrick.Parser.extract_text()
[ "hello, world!", "hello in another font" ]
Without compression
iex> import Mudbrick.TestHelper
...> import Mudbrick
...> new(fonts: %{bodoni: bodoni_regular(), franklin: franklin_regular()})
...> |> page()
...> |> text({"hello, world!", underline: [width: 1]}, font: :bodoni)
...> |> text("hello in another font", font: :franklin)
...> |> Mudbrick.render()
...> |> Mudbrick.Parser.extract_text()
[ "hello, world!", "hello in another font" ]
@spec parse(iodata()) :: Mudbrick.Document.t()
Parse Mudbrick-generated iodata
into a Mudbrick.Document
.
Minimal round-trip
iex> doc = Mudbrick.new()
...> doc
...> |> Mudbrick.render()
...> |> Mudbrick.Parser.parse()
doc
Parse a section of a Mudbrick-generated PDF with a named parsing function. Mostly useful for debugging this parser.