flowchart LR
Ints[integer byte values] --> Guard[pdf_byte_of_int]
Guard --> Bytes[pdf_bytes_of_int_array]
Bytes --> Views[BytesView APIs]
Views --> Names[PdfName]
Guard --> Errors[PdfError]///|
test "byte helpers preserve raw PDF bytes" {
let bytes = try! @core.pdf_bytes_of_int_array([37, 80, 68, 70])
if @core.pdf_int_array_of_bytes(bytes) != [37, 80, 68, 70] {
fail("expected raw PDF header bytes to be preserved")
}
inspect(@core.pdf_is_whitespace_byte(32), content="true")
inspect(@core.pdf_is_delimiter_byte(47), content="true")
}///|
test "byte validation raises PdfError" {
let result : Result[Byte, Error] = try @core.pdf_byte_of_int(300) catch {
err => Err(err)
} noraise {
value => Ok(value)
}
guard result is Err(@core.PdfError::InvalidByte(300)) else {
fail("expected InvalidByte for values outside 0..=255")
}
}type PdfBytes = Bytespub(all) suberror PdfError {
InvalidByte(Int)
InvalidCursorPosition(Int)
InvalidReadLength(Int)
InvalidBit(Int)
InvalidBitCount(Int)
MatrixNotInvertable
DictionaryExpected
DictionaryKeyNotFound(PdfName)
NumberExpected
RectangleExpected
BadRectangle
MatrixMalformed
InvalidHexEscape
InvalidASCII85Data
FilterNotSupported(PdfName)
FilterExpected
CCITTDecodeParmsExpected
CCITTNotSupported(String)
InvalidCCITTData
PredictorExpected
PredictorNotSupported(Int)
InvalidLZWData
InvalidFlateData
FlateOutputLimitExceeded(Int)
BadJPEGHeader
BadJPEGString
InvalidJPEGBlock
JPEGDimensionsExpected
BadPNG(String)
BadJPEG2000Header
JPEG2000DimensionsExpected
ParseObjectExpected
ParseArrayMalformed
ParseSingleObjectExpected
ParseIndirectObjectExpected
ParseEndObjectExpected
ParseStreamExpected
ParseEndStreamExpected
StreamLengthExpected
StreamDataExpected
ParsedObjectExpected
PageTreeExpected
PageRotationExpected(Int)
BadPageSpecification(String)
BadCoordinateSpecification(String)
BadRectangleSpecification(String)
BadNumberArgument(String)
BadPresentationEffect(String)
SoftError(String)
HardError(String)
InsecurePathName(String)
ContentOperatorExpected
ContentOperandExpected
FunctionExpected
FunctionNotSupported(Int)
BadFunctionEvaluation(String)
StartXRefExpected
XRefExpected
XRefEntryExpected
TrailerExpected
RootExpected
BadRevision
InvalidObjectNumber(Int)
BadDate
InvalidUnicodeCodepoint(Int)
InvalidUTF16BE
InvalidUTF8
InvalidPDFDocEncoding(Int)
CryptoKeyExpected
InvalidCryptoDataLength(Int)
EncryptionExpected
EncryptionMethodExpected
EncryptionDictionaryEntryExpected(PdfName)
EncryptionDictionaryEntryTooShort(PdfName)
EncryptionIDExpected
EncryptionAuthenticationUnsupported(PdfCryptType)
EncryptionObjectCryptUnsupported(PdfCryptType)
EncryptionSavedStateExpected
EncryptionRecryptUnsupported(PdfCryptType)
EncryptionRecryptFailed
EncryptionPermissionsCorrupt
EncryptionPermissionsMismatch(Int, Int)
RandomBytesUnavailable
EncodingExpected
EncodingDifferencesMalformed
EncodingWriteUnsupported
FontSubtypeExpected
FontFlagsExpected
StandardFontExpected
BaseFontExpected
FontFirstCharExpected
FontLastCharExpected
FontWidthsExpected
FontWidthExpected
FontCharProcsExpected
FontTypeExpected
FontWriteUnsupported
AfmExpected
ColourSpaceExpected
BadText
TitleExpected
CIDSystemInfoExpected
CIDRegistryExpected
CIDOrderingExpected
CIDSupplementExpected
CIDBaseFontExpected
CIDFontDescriptorExpected
CIDWidthsExpected
CIDWidths2Expected
DescendantFontExpected
CMapEncodingExpected
PageLabelStyleExpected(String)
EndOfInput
} derive(Eq, ToJson, Debug)pub struct BitStream {
input : ByteCursor
current_byte : Int
bit_mask : Int
bits_read : Int
} derive(Eq, ToJson, Debug)#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn BitStreamPosition::equal(BitStreamPosition, BitStreamPosition) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn BitStreamPosition::not_equal(x : BitStreamPosition, y : BitStreamPosition) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn BitStreamPosition::to_json(BitStreamPosition) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn BitStreamPosition::to_repr(BitStreamPosition) -> Repr#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn ByteCursor::equal(ByteCursor, ByteCursor) -> Boolfn ByteCursor::ignore_until(self : ByteCursor, stop : (Int) -> Bool, eof_is_delimiter? : Bool) -> Unit raise PdfError#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn ByteCursor::not_equal(x : ByteCursor, y : ByteCursor) -> Boolfn ByteCursor::read_bytes_at(self : ByteCursor, position : Int, length : Int) -> Bytes raise PdfErrorfn ByteCursor::read_until_view(self : ByteCursor, stop : (Int) -> Bool, eof_is_delimiter? : Bool) -> BytesView raise PdfErrorfn ByteCursor::read_view_at(self : ByteCursor, position : Int, length : Int) -> BytesView raise PdfError#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn ByteCursor::to_json(ByteCursor) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn ByteCursor::to_repr(ByteCursor) -> Reprfn ByteCursor::view_at_absolute(self : ByteCursor, position : Int, length : Int) -> BytesView raise PdfError#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn ByteOutput::equal(ByteOutput, ByteOutput) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn ByteOutput::not_equal(x : ByteOutput, y : ByteOutput) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn ByteOutput::to_json(ByteOutput) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn ByteOutput::to_repr(ByteOutput) -> Reprfn ByteOutput::write_repeated_byte(self : ByteOutput, length : Int, value? : Int) -> Unit raise PdfErrorfn ByteOutput::write_view_at(self : ByteOutput, position : Int, bytes : BytesView) -> Unit raise PdfErrorfn ByteOutput::write_view_slice(self : ByteOutput, bytes : BytesView, offset : Int, length : Int) -> Unit raise PdfError#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfCryptType::equal(PdfCryptType, PdfCryptType) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfCryptType::not_equal(x : PdfCryptType, y : PdfCryptType) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfCryptType::to_json(PdfCryptType) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfCryptType::to_repr(PdfCryptType) -> Reprfn pdf_bytes_copy(values : BytesView) -> Bytesfn pdf_bytes_get(bytes : Bytes, index : Int) -> Byte?fn pdf_bytes_length(bytes : Bytes) -> Intfn pdf_bytes_of_view(values : BytesView) -> Bytesfn pdf_bytes_to_fixed_array(bytes : Bytes) -> FixedArray[Byte]fn pdf_count_whitespace_tokens(view : BytesView) -> Intfn pdf_is_delimiter_byte(value : Int) -> Boolfn pdf_is_digit_byte(value : Int) -> Boolfn pdf_is_newline_byte(value : Int) -> Boolfn pdf_is_not_whitespace_byte(value : Int) -> Boolfn pdf_is_whitespace_byte(value : Int) -> Boolfn pdf_is_whitespace_or_delimiter_byte(value : Int) -> Boollet pdf_no_more : Intfn pdf_startxref_search_view(data : BytesView) -> BytesViewInstall
Download zipByte-oriented PDF reading, writing, and manipulation toolkit for MoonBit.
Dependencies