This version of the module is deprecated: Use moonbitlang/pdflite instead
Byte-oriented PDF reading, writing, and manipulation toolkit for MoonBit.
flowchart LR
Bytes[PDF bytes] --> Reader[pdf_read_document_from_bytes]
Reader --> Document[PdfDocument]
Document --> Pages[page tree and resources]
Document --> Objects[object table]
Pages --> Content[content operators]
Objects --> Writer[pdf_write_document]
Content --> Writer
Writer --> BytesOut[PDF bytes]moon run --target native --release --build-only cmd/main_build/native/release/build/cmd/main/main.exe info fixtures/camlpdf/logo.pdf
_build/native/release/build/cmd/main/main.exe info --json fixtures/camlpdf/logo.pdf
_build/native/release/build/cmd/main/main.exe validate fixtures/camlpdf/logo.pdf
_build/native/release/build/cmd/main/main.exe rewrite fixtures/camlpdf/logo.pdf _build/logo-roundtrip.pdfmoon run --target native --release --build-only cmd/main
PDFLITE_CLI="$PWD/_build/native/release/build/cmd/main/main.exe" \
PDFLITE_LOGO_PDF="$PWD/fixtures/camlpdf/logo.pdf" \
moon cram test tests/crammoon run --target native scripts/release_check.mbtxmoon run --target native scripts/release_check.mbtx -- --full-native-tests --publish-dry-run///|
test "minimum document round trip" {
let document = try! @pdflite.pdf_minimum_valid_pdf()
let bytes = try! @pdflite.pdf_write_document(document)
let version = try! @pdflite.pdf_read_header_from_bytes(bytes)
if version.major != 1 || version.minor != 0 {
fail("expected a PDF 1.0 header")
}
let parsed = try! @pdflite.pdf_read_document_from_bytes(bytes)
inspect(try! parsed.endpage(), content="1")
}///|
test "name writer escapes delimiter bytes" {
let name = @pdflite.pdf_name_of_bytes(
try! @pdflite.pdf_bytes_of_int_array([47, 65, 32, 66]),
)
@test.assert_eq(
@pdflite.pdf_int_array_of_bytes(@pdflite.pdf_write_name(name)),
[47, 65, 35, 50, 48, 66],
)
}This package contains over 1298 items.
Install
Download zipByte-oriented PDF reading, writing, and manipulation toolkit for MoonBit.