DocRaptor

Elixir client for the DocRaptor HTML-to-PDF and XLS API.

Prefer document_content (with inlined CSS/assets) over document_url when developing against localhost — DocRaptor cannot fetch private hosts without a tunnel. See Development Testing & Localhost Servers.

Installation

def deps do
  [
    {:docraptor, "~> 0.1.0"}
  ]
end

Usage

Built on Req. High-level helpers cover the Python DocApi surface; advanced callers can attach to a %Req.Request{} directly.

{:ok, client} = DocRaptor.Client.new(api_key: "YOUR_API_KEY")
# test: true by default — watermarked, free quota

{:ok, %DocRaptor.Document{body: pdf, num_pages: pages}} =
  DocRaptor.create_doc(client, %{
    name: "hello.pdf",
    document_type: :pdf,
    document_content: "<html><body>Hello</body></html>"
  })

{:ok, %DocRaptor.AsyncJob{status_id: status_id}} =
  DocRaptor.create_async_doc(client, %{
    name: "hello.pdf",
    document_type: :pdf,
    document_content: "<html><body>Hello</body></html>"
  })

{:ok, document} = DocRaptor.await_async_doc(client, status_id)

Low-level Req pipeline

Req.new(method: :post, url: "/docs", json: body, decode_body: false)
|> DocRaptor.Client.attach(client)
|> Req.request()

Set test: false on the client (or per document) for production documents.