This version of the module is deprecated: Use moonbitlang/pdflite instead
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! pdf_bytes_of_int_array([37, 80, 68, 70])
if pdf_int_array_of_bytes(bytes) != [37, 80, 68, 70] {
fail("expected raw PDF header bytes to be preserved")
}
inspect(pdf_is_whitespace_byte(32), content="true")
inspect(pdf_is_delimiter_byte(47), content="true")
}///|
test "byte validation raises PdfError" {
let result : Result[Byte, Error] = try? pdf_byte_of_int(300)
guard result is Err(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
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)fn 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_is_delimiter_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) -> Bool