Skip to content

Referência da API Elixir

O PDF Oxide oferece bindings idiomáticos para Elixir, apoiados por um NIF sobre a ABI C do pdf_oxide. A extração com uso intensivo de CPU roda em dirty CPU schedulers, de modo que nunca bloqueia a BEAM, e os handles nativos são liberados pelo garbage collector (ou de forma antecipada via a função *_close/1 correspondente).

# mix.exs
def deps do
  [{:pdf_oxide, "~> 0.3.69"}]
end

Para a API Rust, consulte a Referência da API Rust. Para Python, consulte a Referência da API Python. Para detalhes de tipos, consulte Tipos e Enums.

Convenções

  • Toda função pública vive no único módulo PdfOxide.
  • As funções retornam {:ok, value} ou {:error, code} (um código de erro inteiro); a exceção Error carrega code e op.
  • Os índices de página são baseados em 0.
  • Coordenadas e retângulos estão em pontos do espaço do usuário do PDF (origem no canto inferior esquerdo), salvo indicação em contrário.
  • Os canais de cor são floats no intervalo 0.01.0 (DeviceRGB).
  • Códigos de format de imagem/renderização: 0 = PNG, 1 = JPEG.

Structs

Estes structs envolvem handles de recursos nativos ou dados decodificados retornados pelas funções abaixo.

Struct Finalidade
PdfOxide.Document Um handle de PDF aberto para leitura/extração
PdfOxide.Pdf Um handle de PDF construído (a partir de criação/conversão)
PdfOxide.DocumentEditor Um handle mutável de edição de PDF
PdfOxide.Page Uma visão leve de uma única página baseada em 0
PdfOxide.DocumentBuilder Um builder de criação de PDF
PdfOxide.PageBuilder Um builder de criação de página iniciado a partir de um DocumentBuilder
PdfOxide.EmbeddedFont Uma fonte TTF/OTF carregada para incorporação
PdfOxide.Certificate Certificado X.509 + chave privada para assinatura
PdfOxide.SignatureInfo Uma assinatura de PDF analisada
PdfOxide.Timestamp Um token de carimbo de tempo RFC 3161 analisado
PdfOxide.TsaClient Um cliente de Autoridade de Carimbo de Tempo (TSA) RFC 3161
PdfOxide.Dss Um handle de Document Security Store
PdfOxide.PdfAResult / PdfUaResult / PdfXResult Resultados de validação
PdfOxide.UaStats Contagens de elementos de acessibilidade
PdfOxide.Barcode Um código de barras ou QR code gerado/decodificado
PdfOxide.OcrEngine Um handle de mecanismo de OCR
PdfOxide.Renderer Um renderizador de páginas reutilizável
PdfOxide.ElementList Uma lista opaca de elementos de página
PdfOxide.Error Exceção com code e op

Structs de dados

Struct Campos
PdfOxide.Bbox x, y, width, height
PdfOxide.Char character (codepoint), bbox, font_name, font_size
PdfOxide.Word text, bbox, font_name, font_size, bold
PdfOxide.TextLine text, bbox, word_count
PdfOxide.Table row_count, col_count, has_header, cells
PdfOxide.Font name, type, encoding, embedded, subset
PdfOxide.Image width, height, bits_per_component, format, colorspace, data
PdfOxide.Annotation type, subtype, content, author, rect, border_width
PdfOxide.Path bbox, stroke_width, has_stroke, has_fill, operation_count
PdfOxide.FormField name, value, type, read_only, required
PdfOxide.SearchResult text, page, bbox
PdfOxide.RenderedImage ref, width, height, data

Document — Abertura

PdfOxide.open(path)                          # {:ok, %Document{}}
PdfOxide.open_with_password(path, password)  # open an encrypted PDF
PdfOxide.open_from_bytes(bytes)              # open from an in-memory binary
PdfOxide.open_from_docx_bytes(bytes)         # open a DOCX as a Document
PdfOxide.open_from_pptx_bytes(bytes)         # open a PPTX as a Document
PdfOxide.open_from_xlsx_bytes(bytes)         # open an XLSX as a Document
PdfOxide.close(handle)                       # free a Document/Pdf/DocumentEditor handle

Document — Informações

PdfOxide.page_count(doc)            # number of pages
PdfOxide.version(doc)              # %{major: _, minor: _}
PdfOxide.encrypted?(doc)          # whether the document is encrypted
PdfOxide.structure_tree?(doc)     # whether it has a logical structure tree
PdfOxide.authenticate(doc, password)  # authenticate an encrypted document
PdfOxide.has_xfa?(doc)            # whether the document carries XFA forms
PdfOxide.source_bytes(doc)        # the original source PDF bytes
PdfOxide.page_width(doc, page)    # page width in points
PdfOxide.page_height(doc, page)   # page height in points
PdfOxide.page_rotation(doc, page) # page rotation in degrees

Document — Extração de Texto

PdfOxide.extract_text(doc, page)        # reading-order text for a page
PdfOxide.to_plain_text(doc, page)       # plain text for a page
PdfOxide.to_markdown(doc, page)         # Markdown for a page
PdfOxide.to_html(doc, page)             # HTML for a page
PdfOxide.to_plain_text_all(doc)         # plain text for the whole document
PdfOxide.to_markdown_all(doc)           # Markdown for the whole document
PdfOxide.to_html_all(doc)               # HTML for the whole document
PdfOxide.extract_structured_json(doc, page)  # structured page content as JSON
PdfOxide.extract_chars(doc, page)       # [%Char{}] with positioning + font metadata
PdfOxide.extract_words(doc, page)       # [%Word{}] with layout/style
PdfOxide.extract_text_lines(doc, page)  # [%TextLine{}]
PdfOxide.extract_tables(doc, page)      # [%Table{}]
PdfOxide.cell(table, row, col)          # 0-based cell text from a %Table{}
PdfOxide.extract_text_auto(doc, page)   # auto-pick the best extraction path for a page
PdfOxide.extract_all_text(doc)          # auto-extract text across all pages
PdfOxide.extract_page_auto(doc, page, options_json \\ "")  # auto-extract one page (JSON options)

Document — Extração por Região

PdfOxide.extract_text_in_rect(doc, page, x, y, w, h)    # text inside a rectangle
PdfOxide.extract_words_in_rect(doc, page, x, y, w, h)   # [%Word{}] inside a rectangle
PdfOxide.extract_lines_in_rect(doc, page, x, y, w, h)   # [%TextLine{}] inside a rectangle
PdfOxide.extract_tables_in_rect(doc, page, x, y, w, h)  # [%Table{}] inside a rectangle
PdfOxide.extract_images_in_rect(doc, page, x, y, w, h)  # [%Image{}] inside a rectangle

Document — Fontes, Imagens, Anotações, Caminhos

PdfOxide.embedded_fonts(doc, page)    # [%Font{}] used on a page
PdfOxide.embedded_images(doc, page)   # [%Image{}] with raw bytes
PdfOxide.page_annotations(doc, page)  # [%Annotation{}]
PdfOxide.extract_paths(doc, page)     # [%Path{}] vector paths

Document — Classificação de Páginas e Limpeza

PdfOxide.classify_page(doc, page)              # classify a single page
PdfOxide.classify_document(doc)                # classify the whole document
PdfOxide.erase_header(doc, page)               # erase the detected header on a page
PdfOxide.erase_footer(doc, page)               # erase the detected footer on a page
PdfOxide.erase_artifacts(doc, page)            # erase detected page artifacts
PdfOxide.remove_headers(doc, threshold \\ 0.5) # remove repeating headers document-wide
PdfOxide.remove_footers(doc, threshold \\ 0.5) # remove repeating footers document-wide
PdfOxide.remove_artifacts(doc, threshold \\ 0.5) # remove repeating artifacts document-wide

Document — Busca

PdfOxide.search(doc, page, term, case_sensitive)      # [%SearchResult{}] on one page
PdfOxide.search_all(doc, term, case_sensitive)        # [%SearchResult{}] across all pages
PdfOxide.search_results_to_json(doc, term, case_sensitive \\ false)  # results as JSON

Document — Auxiliares de Visão de Página

PdfOxide.page(doc, index)   # a lightweight %Page{} view of a 0-based page
PdfOxide.text(page)         # extracted text for a %Page{}
PdfOxide.markdown(page)     # Markdown for a %Page{}
PdfOxide.html(page)         # HTML for a %Page{}
PdfOxide.plain_text(page)   # plain text for a %Page{}

Document — Estrutura e Metadados

PdfOxide.outline(doc)        # the document outline / bookmarks
PdfOxide.page_labels(doc)    # page label ranges
PdfOxide.xmp_metadata(doc)   # XMP metadata
PdfOxide.plan_split_by_bookmarks(doc, options_json \\ "")  # plan a split by bookmarks

Document — Saída para Office

PdfOxide.to_docx(doc)   # convert the document to DOCX bytes
PdfOxide.to_pptx(doc)   # convert the document to PPTX bytes
PdfOxide.to_xlsx(doc)   # convert the document to XLSX bytes

Document — Formulários

PdfOxide.form_fields(doc)                              # [%FormField{}]
PdfOxide.export_form_data_to_bytes(doc, format_type \\ 0)  # export form data (FDF/XFDF) to bytes
PdfOxide.import_form_data(doc, data_path)             # import form data from a file path
PdfOxide.form_import_from_file(doc, filename)         # import form data from a file

Document — Acessores de Anotações

PdfOxide.annotation_color(doc, page, index)              # annotation RGB colour
PdfOxide.annotation_creation_date(doc, page, index)      # creation date
PdfOxide.annotation_modification_date(doc, page, index)  # modification date
PdfOxide.annotation_hidden?(doc, page, index)            # hidden flag
PdfOxide.annotation_marked_deleted?(doc, page, index)    # marked-deleted flag
PdfOxide.annotation_printable?(doc, page, index)         # printable flag
PdfOxide.annotation_read_only?(doc, page, index)         # read-only flag
PdfOxide.link_annotation_uri(doc, page, index)           # URI of a Link annotation
PdfOxide.text_annotation_icon_name(doc, page, index)     # icon name of a Text annotation
PdfOxide.highlight_quad_points_count(doc, page, index)   # quad-point count of a Highlight
PdfOxide.highlight_quad_point(doc, page, index, quad_index)  # one quad point of a Highlight
PdfOxide.annotations_to_json(doc, page)                  # all annotations as JSON

Document — Lista de Elementos

PdfOxide.page_elements(doc, page)             # {:ok, %ElementList{}} of page elements
PdfOxide.element_count(list)                  # number of elements
PdfOxide.element_type(list, index)            # element type code
PdfOxide.element_text(list, index)            # element text
PdfOxide.element_rect(list, index)            # element rectangle
PdfOxide.elements_to_json(list)               # the element list as JSON
PdfOxide.element_list_close(list)             # free the element list handle
PdfOxide.font_size(doc, page, index)          # font size of a page font entry
PdfOxide.fonts_to_json(doc, page)             # page fonts as JSON

Document — Renderização

PdfOxide.render_page(doc, page_index, format \\ 0)              # render a page to image bytes
PdfOxide.render_page_zoom(doc, page_index, zoom, format \\ 0)   # render at a zoom factor
PdfOxide.render_page_thumbnail(doc, page_index, size, format \\ 0)  # render a square thumbnail
PdfOxide.render_page_with_options(doc, page, opts \\ [])        # render with dpi/background/jpeg_quality opts
PdfOxide.render_page_with_options_ex(doc, page, excluded_layers, opts \\ [])  # render, suppressing OCG layers
PdfOxide.render_page_region(doc, page, crop_x, crop_y, crop_width, crop_height, format \\ 0)  # render a region
PdfOxide.render_page_fit(doc, page, w, h, format \\ 0)          # render to fit w×h pixels
PdfOxide.render_page_raw(doc, page, dpi \\ 150)                 # render to a raw RGBA8888 buffer
PdfOxide.renderer(dpi \\ 150, format \\ 0, quality \\ 85, anti_alias \\ true)  # reusable %Renderer{}
PdfOxide.renderer_close(renderer)                              # free a renderer handle
PdfOxide.estimate_render_time(doc, page)                       # estimated render time (ms)

As opções de palavra-chave de render_page_with_options/3: :dpi, :format, :background ({r, g, b, a}), :transparent_background, :render_annotations, :jpeg_quality.

Document — OCR

PdfOxide.ocr_engine(det_model_path, rec_model_path, dict_path)  # build an %OcrEngine{}
PdfOxide.ocr_engine_close(engine)                # free an OCR engine handle
PdfOxide.ocr_page_needs_ocr(doc, page)           # whether a page needs OCR
PdfOxide.ocr_extract_text(doc, page, engine \\ nil)  # OCR text (default or custom engine)

Document — Assinaturas (leitura e assinatura)

PdfOxide.sign(doc, certificate, reason \\ "", location \\ "")  # sign the document in place
PdfOxide.signature_count(doc)            # number of signatures
PdfOxide.signature(doc, index)           # {:ok, %SignatureInfo{}}
PdfOxide.verify_all_signatures(doc)      # verify every signature
PdfOxide.document_has_timestamp?(doc)    # whether the document is timestamped
PdfOxide.document_dss(doc)               # {:ok, %Dss{}} document security store
PdfOxide.convert_to_pdf_a(doc, level)    # convert the document to PDF/A (also accepts a %DocumentEditor{})

Document — Validação

PdfOxide.validate_pdf_a(doc, level)    # {:ok, %PdfAResult{}}
PdfOxide.validate_pdf_ua(doc, level)   # {:ok, %PdfUaResult{}}
PdfOxide.validate_pdf_x(doc, level)    # {:ok, %PdfXResult{}}

PdfOxide.pdf_a_compliant?(result)      # PDF/A compliance flag
PdfOxide.pdf_a_errors(result)          # list of PDF/A errors
PdfOxide.pdf_a_warning_count(result)   # PDF/A warning count
PdfOxide.pdf_a_close(result)           # free the result handle

PdfOxide.pdf_ua_accessible?(result)    # PDF/UA accessibility flag
PdfOxide.pdf_ua_errors(result)         # list of PDF/UA errors
PdfOxide.pdf_ua_warnings(result)       # list of PDF/UA warnings
PdfOxide.pdf_ua_stats(result)          # %UaStats{} element counts
PdfOxide.pdf_ua_close(result)          # free the result handle

PdfOxide.pdf_x_compliant?(result)      # PDF/X compliance flag
PdfOxide.pdf_x_errors(result)          # list of PDF/X errors
PdfOxide.pdf_x_close(result)           # free the result handle

DocumentEditor — Abertura e Informações

PdfOxide.open_editor(path)              # {:ok, %DocumentEditor{}}
PdfOxide.open_editor_from_bytes(bytes)  # open an editor from a binary
PdfOxide.editor_close(editor)           # free the editor handle

PdfOxide.editor_page_count(editor)      # number of pages
PdfOxide.editor_version(editor)         # %{major: _, minor: _}
PdfOxide.editor_modified?(editor)       # whether the editor has unsaved changes
PdfOxide.editor_source_path(editor)     # the editor's source path
PdfOxide.get_producer(editor)           # the /Producer metadata value
PdfOxide.set_producer(editor, value)    # set /Producer
PdfOxide.get_creation_date(editor)      # the /CreationDate value
PdfOxide.set_creation_date(editor, date)  # set /CreationDate

DocumentEditor — Páginas e Geometria

PdfOxide.delete_page(editor, page_index)             # delete a page
PdfOxide.move_page(editor, from, to)                 # move a page
PdfOxide.rotate_page_by(editor, page, degrees)       # add to a page's rotation
PdfOxide.rotate_all_pages(editor, degrees)           # rotate all pages
PdfOxide.set_page_rotation(editor, page, degrees)    # set absolute rotation
PdfOxide.get_page_rotation(editor, page)             # get current rotation
PdfOxide.crop_margins(editor, left, right, top, bottom)  # crop all page margins
PdfOxide.get_page_crop_box(editor, page)             # get the CropBox as %Bbox{}
PdfOxide.set_page_crop_box(editor, page, x, y, w, h) # set the CropBox
PdfOxide.get_page_media_box(editor, page)            # get the MediaBox as %Bbox{}
PdfOxide.set_page_media_box(editor, page, x, y, w, h)  # set the MediaBox

DocumentEditor — Apagamento e Redação

PdfOxide.erase_region(editor, page, x, y, w, h)        # queue a rectangular erase
PdfOxide.erase_regions(editor, page, rects)            # queue several erase rectangles
PdfOxide.clear_erase_regions(editor, page)             # clear queued erases on a page
PdfOxide.apply_page_redactions(editor, page)           # apply queued redactions on a page
PdfOxide.apply_all_redactions(editor)                  # apply all queued redactions
PdfOxide.page_marked_for_redaction?(editor, page)      # whether a page has redactions queued
PdfOxide.unmark_page_for_redaction(editor, page)       # clear a page's redaction mark
PdfOxide.redaction_add(editor, page, x1, y1, x2, y2, r, g, b)  # queue a redaction rectangle with fill
PdfOxide.redaction_count(editor, page)                 # number of queued redactions on a page
PdfOxide.redaction_apply(editor, scrub_metadata \\ false, r \\ 0.0, g \\ 0.0, b \\ 0.0)  # apply redactions
PdfOxide.redaction_scrub_metadata(editor)              # strip Info/XMP/JS/embedded files only

DocumentEditor — Achatamento de Anotações

PdfOxide.flatten_annotations(editor, page)         # flatten annotations on a page
PdfOxide.flatten_all_annotations(editor)           # flatten annotations document-wide
PdfOxide.page_marked_for_flatten?(editor, page)    # whether a page is marked for flatten
PdfOxide.unmark_page_for_flatten(editor, page)     # clear a page's flatten mark

DocumentEditor — Formulários

PdfOxide.set_form_field_value(editor, name, value)   # set a form field value
PdfOxide.flatten_forms(editor)                       # flatten all form fields
PdfOxide.flatten_forms_on_page(editor, page_index)   # flatten forms on a page
PdfOxide.flatten_warnings_count(editor)              # number of flatten warnings
PdfOxide.flatten_warning(editor, index)              # one flatten warning message
PdfOxide.import_fdf_bytes(editor, bytes)             # import FDF form data bytes
PdfOxide.import_xfdf_bytes(editor, bytes)            # import XFDF form data bytes

DocumentEditor — Mesclagem, Incorporação e Códigos de Barras

PdfOxide.merge_from(editor, source_path)             # merge pages from a PDF file
PdfOxide.merge_from_bytes(editor, bytes)             # merge pages from a PDF binary
PdfOxide.embed_file(editor, name, bytes)             # attach a file to the PDF
PdfOxide.extract_pages_to_bytes(editor, pages)       # extract a page subset to a new PDF binary
PdfOxide.add_barcode_to_page(editor, page, barcode, x, y, width, height)  # stamp a %Barcode{} on a page

DocumentEditor — Salvamento

PdfOxide.editor_save(editor, path)                                  # save to a file
PdfOxide.editor_save_to_bytes(editor)                               # serialize to a binary
PdfOxide.editor_save_to_bytes_with_options(editor, compress, garbage_collect, linearize)  # save with options
PdfOxide.editor_save_encrypted(editor, path, user_password, owner_password)  # save AES-256 encrypted to a file
PdfOxide.editor_save_encrypted_to_bytes(editor, user_password, owner_password)  # save encrypted to a binary

Criação de Pdf (em uma etapa)

PdfOxide.from_markdown(md)        # build a PDF from Markdown
PdfOxide.from_html(html)          # build a PDF from HTML
PdfOxide.from_text(text)          # build a PDF from plain text
PdfOxide.from_image(path)         # build a single-page PDF from an image file
PdfOxide.from_image_bytes(bytes)  # build a single-page PDF from image bytes
PdfOxide.from_html_css(html, css, font_bytes \\ <<>>)            # build from HTML + CSS + one font
PdfOxide.from_html_css_with_fonts(html, css, fonts)             # build from HTML + CSS + [{family, bytes}]
PdfOxide.merge(paths)             # merge several PDF files into one
PdfOxide.save(pdf, path)          # write a %Pdf{} or %RenderedImage{} to a path
PdfOxide.to_bytes(pdf)            # serialize a built %Pdf{} to a binary
PdfOxide.pdf_page_count(pdf)      # page count of a built %Pdf{}

DocumentBuilder

PdfOxide.builder()                                    # {:ok, %DocumentBuilder{}}
PdfOxide.builder_set_title(builder, title)            # set the title
PdfOxide.builder_set_author(builder, author)          # set the author
PdfOxide.builder_set_subject(builder, subject)        # set the subject
PdfOxide.builder_set_keywords(builder, keywords)      # set the keywords
PdfOxide.builder_set_creator(builder, creator)        # set the creator
PdfOxide.builder_on_open(builder, script)             # set a document-open JavaScript action
PdfOxide.builder_language(builder, lang)              # set the document language
PdfOxide.builder_tagged_pdf_ua1(builder)              # enable Tagged PDF / PDF/UA-1 output
PdfOxide.builder_role_map(builder, custom, standard)  # map a custom structure role to a standard one
PdfOxide.builder_register_embedded_font(builder, name, font)  # register an %EmbeddedFont{} (consumes it)
PdfOxide.builder_letter_page(builder)                 # start a US-Letter page → {:ok, %PageBuilder{}}
PdfOxide.builder_a4_page(builder)                     # start an A4 page → {:ok, %PageBuilder{}}
PdfOxide.builder_page(builder, width, height)         # start a custom-size page
PdfOxide.builder_build(builder)                       # build the PDF to a binary
PdfOxide.builder_save(builder, path)                  # save the built PDF to a file
PdfOxide.builder_save_encrypted(builder, path, user_password, owner_password)  # save encrypted to a file
PdfOxide.builder_to_bytes_encrypted(builder, user_password, owner_password)    # save encrypted to a binary
PdfOxide.builder_close(builder)                       # free the builder handle

PageBuilder — Texto e Layout

PdfOxide.page_font(pb, name, size)         # set the active font and size
PdfOxide.page_at(pb, x, y)                 # move the cursor to (x, y)
PdfOxide.page_text(pb, text)               # draw text at the cursor
PdfOxide.page_heading(pb, level, text)     # draw a heading (level 1–6)
PdfOxide.page_paragraph(pb, text)          # draw a wrapped paragraph
PdfOxide.page_space(pb, points)            # advance vertical space
PdfOxide.page_horizontal_rule(pb)          # draw a horizontal rule
PdfOxide.page_columns(pb, column_count, gap_pt, text)  # flow text into columns
PdfOxide.page_footnote(pb, ref_mark, note_text)        # add a footnote
PdfOxide.page_newline(pb)                  # break to a new line
PdfOxide.page_inline(pb, text)             # append inline text
PdfOxide.page_inline_bold(pb, text)        # append inline bold text
PdfOxide.page_inline_italic(pb, text)      # append inline italic text
PdfOxide.page_inline_color(pb, r, g, b, text)  # append inline coloured text
PdfOxide.page_text_in_rect(pb, x, y, w, h, text, align)  # draw aligned text inside a rectangle
PdfOxide.page_new_page_same_size(pb)       # start a new page of the same size
PdfOxide.page_link_url(pb, url)             # add a URL link over the last element
PdfOxide.page_link_page(pb, page_index)     # add a link to another page
PdfOxide.page_link_named(pb, destination)   # add a named-destination link
PdfOxide.page_link_javascript(pb, script)   # add a JavaScript-action link
PdfOxide.page_on_open(pb, script)           # page-open JavaScript action
PdfOxide.page_on_close(pb, script)          # page-close JavaScript action
PdfOxide.page_field_keystroke(pb, script)   # field keystroke JavaScript
PdfOxide.page_field_format(pb, script)      # field format JavaScript
PdfOxide.page_field_validate(pb, script)    # field validate JavaScript
PdfOxide.page_field_calculate(pb, script)   # field calculate JavaScript

PageBuilder — Anotações

PdfOxide.page_highlight(pb, r, g, b)            # highlight the last element
PdfOxide.page_underline(pb, r, g, b)            # underline the last element
PdfOxide.page_strikeout(pb, r, g, b)            # strike out the last element
PdfOxide.page_squiggly(pb, r, g, b)             # squiggly-underline the last element
PdfOxide.page_sticky_note(pb, text)             # add a sticky note at the cursor
PdfOxide.page_sticky_note_at(pb, x, y, text)    # add a sticky note at (x, y)
PdfOxide.page_watermark(pb, text)               # add a text watermark
PdfOxide.page_watermark_confidential(pb)        # add a CONFIDENTIAL watermark
PdfOxide.page_watermark_draft(pb)               # add a DRAFT watermark
PdfOxide.page_stamp(pb, type_name)              # add a rubber-stamp annotation
PdfOxide.page_freetext(pb, x, y, w, h, text)    # add a free-text annotation

PageBuilder — Widgets de Formulário

PdfOxide.page_text_field(pb, name, x, y, w, h, default_value \\ "")        # text field
PdfOxide.page_checkbox(pb, name, x, y, w, h, checked)                      # checkbox
PdfOxide.page_combo_box(pb, name, x, y, w, h, options, selected \\ "")     # combo box
PdfOxide.page_radio_group(pb, name, values, xs, ys, ws, hs, selected \\ "")  # radio group
PdfOxide.page_push_button(pb, name, x, y, w, h, caption)                   # push button
PdfOxide.page_signature_field(pb, name, x, y, w, h)                        # signature field

PageBuilder — Gráficos

PdfOxide.page_rect(pb, x, y, w, h)                       # stroke a rectangle outline
PdfOxide.page_filled_rect(pb, x, y, w, h, r, g, b)       # draw a filled rectangle
PdfOxide.page_line(pb, x1, y1, x2, y2)                   # draw a line
PdfOxide.page_stroke_rect(pb, x, y, w, h, width, r, g, b)  # stroke a rectangle with width/colour
PdfOxide.page_stroke_line(pb, x1, y1, x2, y2, width, r, g, b)  # stroke a line with width/colour
PdfOxide.page_stroke_rect_dashed(pb, x, y, w, h, width, r, g, b, dash, phase)  # dashed rectangle
PdfOxide.page_stroke_line_dashed(pb, x1, y1, x2, y2, width, r, g, b, dash, phase)  # dashed line

PageBuilder — Imagens e Códigos de Barras

PdfOxide.page_image(pb, bytes, x, y, w, h)                  # place an image from bytes
PdfOxide.page_image_with_alt(pb, bytes, x, y, w, h, alt_text)  # place an image with alt text
PdfOxide.page_image_artifact(pb, bytes, x, y, w, h)         # place an image marked as an artifact
PdfOxide.page_barcode_1d(pb, barcode_type, data, x, y, w, h)  # draw a 1-D barcode
PdfOxide.page_barcode_qr(pb, data, x, y, size)              # draw a QR code

PageBuilder — Tabelas

PdfOxide.page_table(pb, n_columns, widths, aligns, n_rows, cells, has_header)  # draw a static table
PdfOxide.page_streaming_table_begin(pb, n_columns, headers, widths, aligns, repeat_header)  # open a streaming table
PdfOxide.page_streaming_table_begin_v2(pb, n_columns, headers, widths, aligns, repeat_header, mode, sample_rows, min_w, max_w, max_rowspan)  # streaming table with width mode
PdfOxide.page_streaming_table_set_batch_size(pb, batch_size)   # set the auto-flush batch size
PdfOxide.page_streaming_table_pending_row_count(pb)            # rows buffered but not flushed
PdfOxide.page_streaming_table_batch_count(pb)                  # number of flushed batches
PdfOxide.page_streaming_table_push_row(pb, cells)              # push a row
PdfOxide.page_streaming_table_push_row_v2(pb, cells, rowspans) # push a row with per-cell rowspans
PdfOxide.page_streaming_table_flush(pb)                        # flush buffered rows
PdfOxide.page_streaming_table_finish(pb)                       # finish the streaming table

PageBuilder — Commit

PdfOxide.page_done(pb)   # commit the page to its parent builder (consumes the handle)
PdfOxide.page_close(pb)  # drop the page builder without committing

EmbeddedFont

PdfOxide.font_from_file(path)          # load a TTF/OTF font from a file
PdfOxide.font_from_bytes(bytes, name \\ "")  # load a font from bytes
PdfOxide.font_close(font)              # free the font handle

Certificate

PdfOxide.certificate_from_bytes(bytes, password \\ "")  # load a PKCS#12 certificate
PdfOxide.certificate_from_pem(cert_pem, key_pem)        # load a PEM certificate + key
PdfOxide.certificate_subject(cert)    # subject DN
PdfOxide.certificate_issuer(cert)     # issuer DN
PdfOxide.certificate_serial(cert)     # serial number
PdfOxide.certificate_validity(cert)   # validity window
PdfOxide.certificate_valid?(cert)     # whether the certificate is currently valid
PdfOxide.certificate_close(cert)      # free the certificate handle

Assinatura (bytes brutos)

PdfOxide.sign_bytes(bytes, certificate, reason \\ "", location \\ "")  # sign raw PDF bytes
PdfOxide.sign_bytes_pades(bytes, certificate, level, tsa_url \\ "", opts \\ [])       # PAdES-sign raw bytes
PdfOxide.sign_bytes_pades_opts(bytes, certificate, level, tsa_url \\ "", opts \\ [])  # PAdES-sign via options struct
PdfOxide.add_timestamp(pdf_data, sig_index, tsa_url)  # add a document timestamp to a signature

level de sign_bytes_pades/5: 0 = B-B, 1 = B-T, 2 = B-LT. Chaves de opts: :reason, :location, :certs, :crls, :ocsps.

SignatureInfo

PdfOxide.signature_signer_name(sig)        # the signer's name
PdfOxide.signature_reason(sig)             # the signing reason
PdfOxide.signature_location(sig)           # the signing location
PdfOxide.signature_time(sig)               # the signing time
PdfOxide.signature_certificate(sig)        # {:ok, %Certificate{}}
PdfOxide.signature_pades_level(sig)        # the PAdES level
PdfOxide.signature_has_timestamp?(sig)     # whether the signature is timestamped
PdfOxide.signature_timestamp(sig)          # {:ok, %Timestamp{}}
PdfOxide.signature_add_timestamp(sig, timestamp)  # attach a timestamp
PdfOxide.signature_verify(sig)             # verify the signature
PdfOxide.signature_verify_detached(sig, bytes)  # verify with a detached messageDigest check
PdfOxide.signature_close(sig)              # free the signature handle

Timestamp

PdfOxide.timestamp_parse(bytes)            # parse an RFC 3161 token → {:ok, %Timestamp{}}
PdfOxide.timestamp_token(ts)               # the raw token bytes
PdfOxide.timestamp_message_imprint(ts)     # the message imprint
PdfOxide.timestamp_time(ts)                # the timestamp time
PdfOxide.timestamp_serial(ts)              # the serial number
PdfOxide.timestamp_tsa_name(ts)            # the TSA name
PdfOxide.timestamp_policy_oid(ts)          # the policy OID
PdfOxide.timestamp_hash_algorithm(ts)      # the hash algorithm
PdfOxide.timestamp_verify(ts)              # verify the timestamp
PdfOxide.timestamp_close(ts)               # free the timestamp handle

TsaClient

PdfOxide.tsa_client(url, opts \\ [])                       # build a TSA client
PdfOxide.tsa_request_timestamp(client, data)              # request a timestamp over data
PdfOxide.tsa_request_timestamp_hash(client, hash, hash_algo)  # request a timestamp over a hash
PdfOxide.tsa_close(client)                                # free the TSA client handle

Chaves de opts de tsa_client/2: :username, :password, :timeout, :hash_algo, :use_nonce, :cert_req.

Dss (Document Security Store)

PdfOxide.dss_cert_count(dss)    # number of certificates
PdfOxide.dss_crl_count(dss)     # number of CRLs
PdfOxide.dss_ocsp_count(dss)    # number of OCSP responses
PdfOxide.dss_vri_count(dss)     # number of VRI entries
PdfOxide.dss_cert(dss, index)   # one certificate (DER)
PdfOxide.dss_crl(dss, index)    # one CRL (DER)
PdfOxide.dss_ocsp(dss, index)   # one OCSP response (DER)
PdfOxide.dss_close(dss)         # free the DSS handle

Códigos de Barras (independentes)

PdfOxide.generate_qr_code(data, error_correction \\ 1, size_px \\ 256)  # generate a QR code → %Barcode{}
PdfOxide.generate_barcode(data, format \\ 0, size_px \\ 256)            # generate a 1-D/2-D barcode
PdfOxide.barcode_data(barcode)          # the encoded data string
PdfOxide.barcode_format(barcode)        # the format code
PdfOxide.barcode_confidence(barcode)    # decode confidence (0.0–1.0)
PdfOxide.barcode_png(barcode, size_px \\ 256)  # render to PNG bytes
PdfOxide.barcode_svg(barcode, size_px \\ 256)  # render to an SVG string
PdfOxide.barcode_close(barcode)         # free the barcode handle

Logging, Configuração e Criptografia

PdfOxide.set_log_level(level)        # set the library log level
PdfOxide.get_log_level()             # get the current log level

PdfOxide.crypto_active_provider()    # the active crypto provider name
PdfOxide.crypto_cbom()               # the cryptographic bill of materials
PdfOxide.crypto_inventory()          # the crypto algorithm inventory
PdfOxide.crypto_policy()             # the current crypto policy
PdfOxide.crypto_fips_available()     # whether a FIPS provider is available
PdfOxide.crypto_use_fips()           # switch to the FIPS provider
PdfOxide.crypto_set_policy(spec)     # set the crypto policy from a spec string

PdfOxide.model_manifest()                  # the bundled OCR/model manifest
PdfOxide.prefetch_available()              # whether model prefetch is available
PdfOxide.prefetch_models(languages_csv \\ "")  # prefetch OCR models for given languages
PdfOxide.set_max_ops_per_stream(limit)         # cap content-stream operations per stream
PdfOxide.set_preserve_unmapped_glyphs(preserve)  # toggle preservation of unmapped glyphs

Exemplo Completo

# --- Extraction ---
{:ok, doc} = PdfOxide.open("input.pdf")
count = PdfOxide.page_count(doc)

text = PdfOxide.extract_text(doc, 0)
{:ok, chars} = PdfOxide.extract_chars(doc, 0)
{:ok, tables} = PdfOxide.extract_tables(doc, 0)

# Search
results = PdfOxide.search_all(doc, "configuration", false)

# --- Creation ---
{:ok, pdf} = PdfOxide.from_markdown("# Report\n\nGenerated by PDF Oxide.")
:ok = PdfOxide.save(pdf, "report.pdf")

# --- Builder ---
{:ok, b} = PdfOxide.builder()
PdfOxide.builder_set_title(b, "Invoice")
{:ok, pb} = PdfOxide.builder_a4_page(b)
PdfOxide.page_font(pb, "Helvetica", 12)
PdfOxide.page_at(pb, 72, 720)
PdfOxide.page_text(pb, "Hello, world")
PdfOxide.page_done(pb)
PdfOxide.builder_save(b, "invoice.pdf")

# --- Editing ---
{:ok, ed} = PdfOxide.open_editor("document.pdf")
PdfOxide.rotate_all_pages(ed, 90)
PdfOxide.set_form_field_value(ed, "name", "John Doe")
PdfOxide.editor_save(ed, "output.pdf")
PdfOxide.editor_close(ed)

Other Language Bindings

O PDF Oxide oferece bindings nativos para todos os principais ecossistemas: Rust, Python, Node.js, WASM, C#, Golang, Java, PHP, Ruby, C++, Swift, Kotlin, Dart, R, Julia, Zig, Scala, Clojure e Objective-C.

Próximos Passos