Skip to content

Довідник Elixir API

PDF Oxide надає ідіоматичні Elixir-біндинги поверх NIF, побудованого на C ABI pdf_oxide. Операції, навантажені на CPU, виконуються на dirty CPU schedulers, тож вони ніколи не блокують BEAM, а нативні дескриптори звільняються збирачем сміття (або явно — відповідною функцією *_close/1).

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

Довідник Rust API дивіться у Rust API Reference. Довідник Python API — у Python API Reference. Деталі типів — у Types & Enums.

Угоди

  • Усі публічні функції знаходяться в єдиному модулі PdfOxide.
  • Функції повертають {:ok, value} або {:error, code} (ціле число — код помилки); виняток Error містить code і op.
  • Індекси сторінок починаються з 0.
  • Координати та прямокутники задаються в координатах простору користувача PDF (точки, початок координат у нижньому лівому куті), якщо не вказано інше.
  • Канали кольору — числа з рухомою комою в діапазоні 0.01.0 (DeviceRGB).
  • Коди формату зображення/рендерингу format: 0 = PNG, 1 = JPEG.

Структури

Ці структури обгортають дескриптори нативних ресурсів або декодовані дані, які повертають наведені нижче функції.

Структура Призначення
PdfOxide.Document Відкритий дескриптор PDF для читання/витягання
PdfOxide.Pdf Побудований дескриптор PDF (зі створення/конвертації)
PdfOxide.DocumentEditor Змінюваний дескриптор редагування PDF
PdfOxide.Page Легке представлення однієї сторінки з індексом від 0
PdfOxide.DocumentBuilder Білдер для створення PDF
PdfOxide.PageBuilder Білдер сторінки, запущений від DocumentBuilder
PdfOxide.EmbeddedFont Завантажений TTF/OTF-шрифт для вбудовування
PdfOxide.Certificate Сертифікат X.509 + приватний ключ для підписання
PdfOxide.SignatureInfo Розібраний підпис PDF
PdfOxide.Timestamp Розібраний токен мітки часу RFC 3161
PdfOxide.TsaClient Клієнт служби довіреної мітки часу (TSA) за RFC 3161
PdfOxide.Dss Дескриптор сховища безпеки документа (Document Security Store)
PdfOxide.PdfAResult / PdfUaResult / PdfXResult Результати валідації
PdfOxide.UaStats Кількість елементів доступності
PdfOxide.Barcode Згенерований/розпізнаний штрих-код або QR-код
PdfOxide.OcrEngine Дескриптор движка OCR
PdfOxide.Renderer Багаторазовий рендерер сторінок
PdfOxide.ElementList Непрозорий список елементів сторінки
PdfOxide.Error Виняток з полями code та op

Структури даних

Структура Поля
PdfOxide.Bbox x, y, width, height
PdfOxide.Char character (кодова точка), 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 — Відкриття

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 — Інформація

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 — Витягання тексту

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 — Витягання за регіоном

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 — Шрифти, зображення, анотації, контури

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 — Класифікація сторінок і очищення

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 — Пошук

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 — Допоміжні функції для перегляду сторінки

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 — Структура та метадані

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 — Вивід в офісні формати

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 — Форми

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 — Доступ до анотацій

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 — Список елементів

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 — Рендеринг

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)

Іменовані опції 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 — Підписи (читання та підписання)

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 — Валідація

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 — Відкриття та інформація

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 — Сторінки та геометрія

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 — Видалення та редагування (redaction)

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 — Сплощення анотацій

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 — Форми

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 — Об’єднання, вкладення та штрих-коди

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 — Збереження

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

Створення Pdf (одним викликом)

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 — Текст і компонування

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

PageBuilder — Посилання та JavaScript

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 — Анотації

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 — Віджети форм

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 — Графіка

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 — Зображення та штрих-коди

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 — Таблиці

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 — Фіксація

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

Підписання (сирі байти)

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

sign_bytes_pades/5 level: 0 = B-B, 1 = B-T, 2 = B-LT. Ключі 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

Ключі opts для tsa_client/2: :username, :password, :timeout, :hash_algo, :use_nonce, :cert_req.

Dss (сховище безпеки документа)

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

Штрих-коди (окремо)

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

Логування, конфігурація та криптографія

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

Повний приклад

# --- 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

PDF Oxide надає нативні прив’язки для всіх основних екосистем: Rust, Python, Node.js, WASM, C#, Golang, Java, PHP, Ruby, C++, Swift, Kotlin, Dart, R, Julia, Zig, Scala, Clojure та Objective-C.

Наступні кроки