Skip to content

Elixir API 레퍼런스

PDF Oxide는 pdf_oxide C ABI 위에 NIF로 구현된 이디오매틱한 Elixir 바인딩을 제공합니다. CPU 집약적인 추출 작업은 dirty CPU 스케줄러에서 실행되므로 BEAM을 절대 막지 않으며, 네이티브 핸들은 가비지 컬렉터가 회수하거나(또는 대응하는 *_close/1 함수로 즉시) 해제됩니다.

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

Rust API는 Rust API 레퍼런스를, Python은 Python API 레퍼런스를 참고하세요. 타입에 대한 자세한 내용은 타입 & 열거형을 확인하세요.

규칙

  • 모든 공개 함수는 단일 PdfOxide 모듈에 있습니다.
  • 함수는 {:ok, value} 또는 {:error, code}(정수 오류 코드)를 반환합니다. Error 예외는 codeop를 담고 있습니다.
  • 페이지 인덱스는 0부터 시작합니다.
  • 별도 표기가 없으면 좌표와 사각형은 PDF 사용자 공간 포인트 단위입니다(원점은 왼쪽 아래).
  • 색상 채널은 0.0~1.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 RFC 3161 타임스탬프 기관(TSA) 클라이언트
PdfOxide.Dss 문서 보안 저장소(Document Security Store) 핸들
PdfOxide.PdfAResult / PdfUaResult / PdfXResult 검증 결과
PdfOxide.UaStats 접근성 요소 개수
PdfOxide.Barcode 생성/디코딩된 바코드 또는 QR 코드
PdfOxide.OcrEngine OCR 엔진 핸들
PdfOxide.Renderer 재사용 가능한 페이지 렌더러
PdfOxide.ElementList 페이지 요소의 불투명 목록
PdfOxide.Error codeop를 가진 예외

데이터 구조체

구조체 필드
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 — 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 — 양식

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 — 주석 평탄화(Flattening)

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/5level: 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

tsa_client/2opts 키: :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

다음 단계