Vanilla.PDF  1.6.0
Cross-platform toolkit for creating and modifying PDF documents
extract.c

File image extaction full example.

#include "tools.h"
void print_extract_help() {
printf("Usage: extract -s [source file]");
}
error_type process_stream(StreamObjectHandle* stream, biguint_type object_number, ushort_type generation_number) {
DictionaryObjectHandle* stream_dictionary = NULL;
ObjectType type_object_type;
ObjectType subtype_object_type;
ObjectHandle* type_object = NULL;
ObjectHandle* subtype_object = NULL;
NameObjectHandle* type_name = NULL;
NameObjectHandle* subtype_name = NULL;
boolean_type contains_subtype = VANILLAPDF_RV_FALSE;
boolean_type contains_height = VANILLAPDF_RV_FALSE;
boolean_type contains_colorspace = VANILLAPDF_RV_FALSE;
boolean_type is_type_xobject = VANILLAPDF_RV_FALSE;
boolean_type is_subtype_image = VANILLAPDF_RV_FALSE;
boolean_type processed_with_params = VANILLAPDF_RV_FALSE;
unsigned long long object_number_converted = 0;
unsigned int generation_number_converted = 0;
int return_value = 0;
char output_filename[256] = { 0 };
RETURN_ERROR_IF_NOT_SUCCESS(StreamObject_GetHeader(stream, &stream_dictionary));
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Contains(stream_dictionary, NameConstant_Type, &contains_type));
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Contains(stream_dictionary, NameConstant_Subtype, &contains_subtype));
if (!contains_type || !contains_subtype) {
goto err;
}
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Find(stream_dictionary, NameConstant_Type, &type_object));
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Find(stream_dictionary, NameConstant_Subtype, &subtype_object));
RETURN_ERROR_IF_NOT_SUCCESS(Object_GetObjectType(type_object, &type_object_type));
RETURN_ERROR_IF_NOT_SUCCESS(Object_GetObjectType(subtype_object, &subtype_object_type));
if (type_object_type != ObjectType_Name || subtype_object_type != ObjectType_Name) {
goto err;
}
RETURN_ERROR_IF_NOT_SUCCESS(NameObject_FromObject(type_object, &type_name));
RETURN_ERROR_IF_NOT_SUCCESS(NameObject_FromObject(subtype_object, &subtype_name));
RETURN_ERROR_IF_NOT_SUCCESS(NameObject_Equals(type_name, NameConstant_XObject, &is_type_xobject));
RETURN_ERROR_IF_NOT_SUCCESS(NameObject_Equals(subtype_name, NameConstant_Image, &is_subtype_image));
if (!is_type_xobject || !is_subtype_image) {
goto err;
}
object_number_converted = object_number;
generation_number_converted = generation_number;
return_value = snprintf(output_filename, sizeof(output_filename), "%llu.%u.jpeg", object_number_converted, generation_number_converted);
if (return_value < 0) {
printf("Could not create destination filename");
return VANILLAPDF_TOOLS_ERROR_FAILURE;
}
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Contains(stream_dictionary, NameConstant_Width, &contains_width));
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Contains(stream_dictionary, NameConstant_Height, &contains_height));
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Contains(stream_dictionary, NameConstant_ColorSpace, &contains_colorspace));
if (contains_width && contains_height && contains_colorspace) {
ObjectType width_object_type;
ObjectType height_object_type;
ObjectType colorspace_object_type;
ObjectHandle* width_object = NULL;
ObjectHandle* height_object = NULL;
ObjectHandle* colorspace_object = NULL;
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Find(stream_dictionary, NameConstant_Width, &width_object));
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Find(stream_dictionary, NameConstant_Height, &height_object));
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Find(stream_dictionary, NameConstant_ColorSpace, &colorspace_object));
RETURN_ERROR_IF_NOT_SUCCESS(Object_GetObjectType(width_object, &width_object_type));
RETURN_ERROR_IF_NOT_SUCCESS(Object_GetObjectType(height_object, &height_object_type));
RETURN_ERROR_IF_NOT_SUCCESS(Object_GetObjectType(colorspace_object, &colorspace_object_type));
if (width_object_type == ObjectType_Integer && height_object_type == ObjectType_Integer && colorspace_object_type == ObjectType_Name) {
OutputStreamHandle* output_stream = NULL;
DCTDecodeFilterHandle* encoding_filter = NULL;
DictionaryObjectHandle* encoding_dictionary = NULL;
BufferHandle* decoded_body = NULL;
BufferHandle* encoded_body = NULL;
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Create(&encoding_dictionary));
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_InsertConst(encoding_dictionary, NameConstant_Width, width_object, VANILLAPDF_RV_FALSE));
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_InsertConst(encoding_dictionary, NameConstant_Height, height_object, VANILLAPDF_RV_FALSE));
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_InsertConst(encoding_dictionary, NameConstant_ColorSpace, colorspace_object, VANILLAPDF_RV_FALSE));
RETURN_ERROR_IF_NOT_SUCCESS(StreamObject_GetBody(stream, &decoded_body));
RETURN_ERROR_IF_NOT_SUCCESS(DCTDecodeFilter_Create(&encoding_filter));
RETURN_ERROR_IF_NOT_SUCCESS(DCTDecodeFilter_EncodeParams(encoding_filter, decoded_body, encoding_dictionary, &encoded_body));
RETURN_ERROR_IF_NOT_SUCCESS(DCTDecodeFilter_Release(encoding_filter));
RETURN_ERROR_IF_NOT_SUCCESS(OutputStream_CreateFromFile(output_filename, &output_stream));
RETURN_ERROR_IF_NOT_SUCCESS(OutputStream_WriteBuffer(output_stream, encoded_body));
RETURN_ERROR_IF_NOT_SUCCESS(OutputStream_Flush(output_stream));
RETURN_ERROR_IF_NOT_SUCCESS(OutputStream_Release(output_stream));
RETURN_ERROR_IF_NOT_SUCCESS(Buffer_Release(encoded_body));
RETURN_ERROR_IF_NOT_SUCCESS(Buffer_Release(decoded_body));
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Release(encoding_dictionary));
processed_with_params = VANILLAPDF_RV_TRUE;
}
RETURN_ERROR_IF_NOT_SUCCESS(Object_Release(width_object));
RETURN_ERROR_IF_NOT_SUCCESS(Object_Release(height_object));
RETURN_ERROR_IF_NOT_SUCCESS(Object_Release(colorspace_object));
}
if (processed_with_params != VANILLAPDF_RV_TRUE) {
OutputStreamHandle* output_stream = NULL;
BufferHandle* encoded_body = NULL;
RETURN_ERROR_IF_NOT_SUCCESS(StreamObject_GetBodyRaw(stream, &encoded_body));
RETURN_ERROR_IF_NOT_SUCCESS(OutputStream_CreateFromFile(output_filename, &output_stream));
RETURN_ERROR_IF_NOT_SUCCESS(OutputStream_WriteBuffer(output_stream, encoded_body));
RETURN_ERROR_IF_NOT_SUCCESS(OutputStream_Flush(output_stream));
RETURN_ERROR_IF_NOT_SUCCESS(OutputStream_Release(output_stream));
RETURN_ERROR_IF_NOT_SUCCESS(Buffer_Release(encoded_body));
}
err:
if (type_object != NULL) {
RETURN_ERROR_IF_NOT_SUCCESS(Object_Release(type_object));
type_object = NULL;
}
if (subtype_object != NULL) {
RETURN_ERROR_IF_NOT_SUCCESS(Object_Release(subtype_object));
subtype_object = NULL;
}
if (type_name != NULL) {
RETURN_ERROR_IF_NOT_SUCCESS(NameObject_Release(type_name));
type_name = NULL;
}
if (subtype_name != NULL) {
RETURN_ERROR_IF_NOT_SUCCESS(NameObject_Release(subtype_name));
subtype_name = NULL;
}
if (stream_dictionary != NULL) {
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Release(stream_dictionary));
stream_dictionary = NULL;
}
return VANILLAPDF_TOOLS_ERROR_SUCCESS;
}
error_type process_object(ObjectHandle* obj, biguint_type object_number, ushort_type generation_number) {
ObjectType type;
RETURN_ERROR_IF_NOT_SUCCESS(Object_GetObjectType(obj, &type));
if (type == ObjectType_Stream) {
StreamObjectHandle* stream = NULL;
RETURN_ERROR_IF_NOT_SUCCESS(StreamObject_FromObject(obj, &stream));
RETURN_ERROR_IF_NOT_SUCCESS(process_stream(stream, object_number, generation_number));
RETURN_ERROR_IF_NOT_SUCCESS(StreamObject_Release(stream));
}
return VANILLAPDF_TOOLS_ERROR_SUCCESS;
}
error_type process_xref(XrefHandle* xref) {
XrefIteratorHandle* xref_iterator = NULL;
RETURN_ERROR_IF_NOT_SUCCESS(Xref_GetIterator(xref, &xref_iterator));
while (VANILLAPDF_ERROR_SUCCESS == XrefIterator_IsValid(xref_iterator, &valid)
&& VANILLAPDF_RV_TRUE == valid) {
XrefEntryHandle* entry = NULL;
XrefCompressedEntryHandle* compressed_entry = NULL;
XrefUsedEntryHandle* used_entry = NULL;
biguint_type object_number = 0;
ushort_type generation_number = 0;
RETURN_ERROR_IF_NOT_SUCCESS(XrefIterator_GetValue(xref_iterator, &entry));
RETURN_ERROR_IF_NOT_SUCCESS(XrefEntry_GetType(entry, &type));
RETURN_ERROR_IF_NOT_SUCCESS(XrefEntry_GetObjectNumber(entry, &object_number));
RETURN_ERROR_IF_NOT_SUCCESS(XrefEntry_GetGenerationNumber(entry, &generation_number));
if (type == XrefEntryType_Used) {
ObjectHandle* obj = NULL;
RETURN_ERROR_IF_NOT_SUCCESS(XrefUsedEntry_FromEntry(entry, &used_entry));
RETURN_ERROR_IF_NOT_SUCCESS(XrefUsedEntry_GetReference(used_entry, &obj));
RETURN_ERROR_IF_NOT_SUCCESS(process_object(obj, object_number, generation_number));
RETURN_ERROR_IF_NOT_SUCCESS(Object_Release(obj));
RETURN_ERROR_IF_NOT_SUCCESS(XrefUsedEntry_Release(used_entry));
}
if (type == XrefEntryType_Compressed) {
ObjectHandle* obj = NULL;
RETURN_ERROR_IF_NOT_SUCCESS(XrefCompressedEntry_FromEntry(entry, &compressed_entry));
RETURN_ERROR_IF_NOT_SUCCESS(XrefCompressedEntry_GetReference(compressed_entry, &obj));
RETURN_ERROR_IF_NOT_SUCCESS(process_object(obj, object_number, generation_number));
RETURN_ERROR_IF_NOT_SUCCESS(Object_Release(obj));
RETURN_ERROR_IF_NOT_SUCCESS(XrefCompressedEntry_Release(compressed_entry));
}
RETURN_ERROR_IF_NOT_SUCCESS(XrefEntry_Release(entry));
RETURN_ERROR_IF_NOT_SUCCESS(XrefIterator_Next(xref_iterator));
}
RETURN_ERROR_IF_NOT_SUCCESS(XrefIterator_Release(xref_iterator));
return VANILLAPDF_TOOLS_ERROR_SUCCESS;
}
error_type process_file(FileHandle* file) {
XrefChainHandle* chain = NULL;
XrefChainIteratorHandle* chain_iterator = NULL;
RETURN_ERROR_IF_NOT_SUCCESS(File_XrefChain(file, &chain));
RETURN_ERROR_IF_NOT_SUCCESS(XrefChain_GetIterator(chain, &chain_iterator));
while (VANILLAPDF_ERROR_SUCCESS == XrefChainIterator_IsValid(chain_iterator, &valid)
&& VANILLAPDF_RV_TRUE == valid) {
XrefHandle* xref = NULL;
RETURN_ERROR_IF_NOT_SUCCESS(XrefChainIterator_GetValue(chain_iterator, &xref));
RETURN_ERROR_IF_NOT_SUCCESS(process_xref(xref));
RETURN_ERROR_IF_NOT_SUCCESS(Xref_Release(xref));
RETURN_ERROR_IF_NOT_SUCCESS(XrefChainIterator_Next(chain_iterator));
}
RETURN_ERROR_IF_NOT_SUCCESS(XrefChainIterator_Release(chain_iterator));
RETURN_ERROR_IF_NOT_SUCCESS(XrefChain_Release(chain));
return VANILLAPDF_TOOLS_ERROR_SUCCESS;
}
error_type process_page_contents(PageContentsHandle* page_contents, size_type page_number) {
size_type i = 0;
size_type contents_size = 0;
unsigned long long page_number_converted = page_number;
RETURN_ERROR_IF_NOT_SUCCESS(PageContents_GetInstructionsSize(page_contents, &contents_size));
for (i = 0; i < contents_size; ++i) {
ContentInstructionType instruction_type;
ContentObjectType object_type;
ContentInstructionHandle* content_instruction = NULL;
ContentObjectHandle* content_object = NULL;
ContentObjectInlineImageHandle* content_image = NULL;
DictionaryObjectHandle* content_image_dictionary = NULL;
BufferHandle* content_image_data = NULL;
int return_value = 0;
unsigned long long i_converted = i;
char output_filename[256] = {0};
OutputStreamHandle* output_stream = NULL;
RETURN_ERROR_IF_NOT_SUCCESS(PageContents_GetInstructionAt(page_contents, i, &content_instruction));
RETURN_ERROR_IF_NOT_SUCCESS(ContentInstruction_GetInstructionType(content_instruction, &instruction_type));
if (instruction_type != ContentInstructionType_Object) {
RETURN_ERROR_IF_NOT_SUCCESS(ContentInstruction_Release(content_instruction));
continue;
}
RETURN_ERROR_IF_NOT_SUCCESS(ContentObject_FromInstruction(content_instruction, &content_object));
RETURN_ERROR_IF_NOT_SUCCESS(ContentObject_GetObjectType(content_object, &object_type));
if (object_type != ContentObjectType_InlineImage) {
RETURN_ERROR_IF_NOT_SUCCESS(ContentObject_Release(content_object));
RETURN_ERROR_IF_NOT_SUCCESS(ContentInstruction_Release(content_instruction));
continue;
}
RETURN_ERROR_IF_NOT_SUCCESS(ContentObject_ToInlineImage(content_object, &content_image));
RETURN_ERROR_IF_NOT_SUCCESS(ContentObjectInlineImage_GetDictionary(content_image, &content_image_dictionary));
RETURN_ERROR_IF_NOT_SUCCESS(ContentObjectInlineImage_GetData(content_image, &content_image_data));
return_value = snprintf(output_filename, sizeof(output_filename), "%llu.%llu", page_number_converted, i_converted);
if (return_value < 0) {
printf("Could not create destination filename");
return VANILLAPDF_TOOLS_ERROR_FAILURE;
}
RETURN_ERROR_IF_NOT_SUCCESS(OutputStream_CreateFromFile(output_filename, &output_stream));
RETURN_ERROR_IF_NOT_SUCCESS(OutputStream_WriteBuffer(output_stream, content_image_data));
RETURN_ERROR_IF_NOT_SUCCESS(OutputStream_Flush(output_stream));
RETURN_ERROR_IF_NOT_SUCCESS(OutputStream_Release(output_stream));
RETURN_ERROR_IF_NOT_SUCCESS(Buffer_Release(content_image_data));
RETURN_ERROR_IF_NOT_SUCCESS(DictionaryObject_Release(content_image_dictionary));
RETURN_ERROR_IF_NOT_SUCCESS(ContentObjectInlineImage_Release(content_image));
RETURN_ERROR_IF_NOT_SUCCESS(ContentObject_Release(content_object));
RETURN_ERROR_IF_NOT_SUCCESS(ContentInstruction_Release(content_instruction));
}
return VANILLAPDF_TOOLS_ERROR_SUCCESS;
}
int process_extract(int argc, char *argv[]) {
const char *filename = NULL;
int arg_counter = 0;
size_type i = 0;
size_type page_count = 0;
FileHandle* file = NULL;
DocumentHandle* document = NULL;
CatalogHandle* catalog = NULL;
PageTreeHandle* tree = NULL;
for (arg_counter = 0; arg_counter < argc; ++arg_counter) {
// source file
if (strcmp(argv[arg_counter], "-s") == 0 && (arg_counter + 1 < argc)) {
filename = argv[arg_counter + 1];
arg_counter++;
} else {
print_extract_help();
return VANILLAPDF_TOOLS_ERROR_INVALID_PARAMETERS;
}
}
if (filename == NULL) {
print_extract_help();
return VANILLAPDF_TOOLS_ERROR_INVALID_PARAMETERS;
}
RETURN_ERROR_IF_NOT_SUCCESS(File_Open(filename, &file));
RETURN_ERROR_IF_NOT_SUCCESS(File_Initialize(file));
RETURN_ERROR_IF_NOT_SUCCESS(process_file(file));
RETURN_ERROR_IF_NOT_SUCCESS(Document_OpenFile(file, &document));
RETURN_ERROR_IF_NOT_SUCCESS(Document_GetCatalog(document, &catalog));
RETURN_ERROR_IF_NOT_SUCCESS(Catalog_GetPages(catalog, &tree));
RETURN_ERROR_IF_NOT_SUCCESS(PageTree_GetPageCount(tree, &page_count));
for (i = 0; i < page_count; ++i) {
PageContentsHandle* page_contents = NULL;
PageObjectHandle* page_object = NULL;
RETURN_ERROR_IF_NOT_SUCCESS(PageTree_GetPage(tree, i + 1, &page_object));
RETURN_ERROR_IF_NOT_SUCCESS(PageObject_GetContents(page_object, &page_contents));
RETURN_ERROR_IF_NOT_SUCCESS(process_page_contents(page_contents, i + 1));
RETURN_ERROR_IF_NOT_SUCCESS(PageContents_Release(page_contents));
RETURN_ERROR_IF_NOT_SUCCESS(PageObject_Release(page_object));
}
RETURN_ERROR_IF_NOT_SUCCESS(PageTree_Release(tree));
RETURN_ERROR_IF_NOT_SUCCESS(Catalog_Release(catalog));
RETURN_ERROR_IF_NOT_SUCCESS(Document_Release(document));
RETURN_ERROR_IF_NOT_SUCCESS(File_Release(file));
return VANILLAPDF_TOOLS_ERROR_SUCCESS;
}
XrefEntryType
Required for conversion to derived types.
Definition: c_xref.h:94
@ XrefEntryType_Compressed
Represents compressed entry within cross-reference section.
Definition: c_xref.h:125
@ XrefEntryType_Used
Represents used entry within cross-reference section.
Definition: c_xref.h:119
Represents memory stored data.
error_type CALLING_CONVENTION Buffer_Release(BufferHandle *handle)
Decrement the internal reference counter.
The root of a document's object hierarchy.
error_type CALLING_CONVENTION Catalog_Release(CatalogHandle *handle)
Decrement the internal reference counter.
error_type CALLING_CONVENTION Catalog_GetPages(CatalogHandle *handle, PageTreeHandle **result)
The root of the document's page tree (see 7.7.3, "Page Tree").
Base class for all content objects and operations.
error_type CALLING_CONVENTION ContentInstruction_Release(ContentInstructionHandle *handle)
Decrement the internal reference counter.
error_type CALLING_CONVENTION ContentInstruction_GetInstructionType(ContentInstructionHandle *handle, ContentInstructionType *result)
Get derived type of current object.
A sequence of content instructions grouped within a single object.
error_type CALLING_CONVENTION ContentObject_ToInlineImage(ContentObjectHandle *handle, ContentObjectInlineImageHandle **result)
Reinterpret current object as ContentObjectInlineImageHandle.
error_type CALLING_CONVENTION ContentObject_GetObjectType(ContentObjectHandle *handle, ContentObjectType *result)
Get derived type of current object.
error_type CALLING_CONVENTION ContentObject_FromInstruction(ContentInstructionHandle *handle, ContentObjectHandle **result)
Convert ContentInstructionHandle to ContentObjectHandle.
error_type CALLING_CONVENTION ContentObject_Release(ContentObjectHandle *handle)
Decrement the internal reference counter.
As an alternative to the image XObjects described in section 8.9.5 - Image Dictionaries,...
error_type CALLING_CONVENTION ContentObjectInlineImage_Release(ContentObjectInlineImageHandle *handle)
Decrement the internal reference counter.
error_type CALLING_CONVENTION ContentObjectInlineImage_GetDictionary(ContentObjectInlineImageHandle *handle, DictionaryObjectHandle **result)
Get meta-data dictionary for inline image.
error_type CALLING_CONVENTION ContentObjectInlineImage_GetData(ContentObjectInlineImageHandle *handle, BufferHandle **result)
Get raw image data.
The DCTDecode filter decodes grayscale or colour image data that has been encoded in the JPEG baselin...
error_type CALLING_CONVENTION DCTDecodeFilter_Create(DCTDecodeFilterHandle **result)
Creates a new filter instance.
error_type CALLING_CONVENTION DCTDecodeFilter_EncodeParams(DCTDecodeFilterHandle *handle, BufferHandle *data, DictionaryObjectHandle *parameters, BufferHandle **result)
Encodes source data and returns encoded result data.
error_type CALLING_CONVENTION DCTDecodeFilter_Release(DCTDecodeFilterHandle *handle)
Decrement the internal reference counter.
A dictionary object is an associative table containing pairs of objects.
error_type CALLING_CONVENTION DictionaryObject_Contains(DictionaryObjectHandle *handle, const NameObjectHandle *key, boolean_type *result)
Determine if collection contains key.
error_type CALLING_CONVENTION DictionaryObject_Find(DictionaryObjectHandle *handle, const NameObjectHandle *key, ObjectHandle **result)
Find mapped value for key key.
error_type CALLING_CONVENTION DictionaryObject_InsertConst(DictionaryObjectHandle *handle, const NameObjectHandle *key, ObjectHandle *value, boolean_type overwrite)
Insert new key-value pair into collection.
error_type CALLING_CONVENTION DictionaryObject_Release(DictionaryObjectHandle *handle)
Decrement the internal reference counter.
error_type CALLING_CONVENTION DictionaryObject_Create(DictionaryObjectHandle **result)
Creates a new dictionary instance.
Represents high-level file access handle.
error_type CALLING_CONVENTION Document_GetCatalog(DocumentHandle *handle, CatalogHandle **result)
Get document's catalog property.
error_type CALLING_CONVENTION Document_OpenFile(FileHandle *holder, DocumentHandle **result)
Opens a document using already existing file handle.
error_type CALLING_CONVENTION Document_Release(DocumentHandle *handle)
Decrement the internal reference counter.
Represents low-level file access handle.
error_type CALLING_CONVENTION File_XrefChain(FileHandle *handle, XrefChainHandle **result)
Get chain of xref tables for iteration.
error_type CALLING_CONVENTION File_Release(FileHandle *handle)
Decrement the internal reference counter.
error_type CALLING_CONVENTION File_Open(string_type filename, FileHandle **result)
Opens a file for reading.
error_type CALLING_CONVENTION File_Initialize(FileHandle *handle)
Perform basic intialization.
A name object is an atomic symbol uniquely defined by a sequence of characters.
error_type CALLING_CONVENTION NameObject_Equals(const NameObjectHandle *handle, const NameObjectHandle *other, boolean_type *result)
Compares two name objects.
error_type CALLING_CONVENTION NameObject_Release(NameObjectHandle *handle)
Decrement the internal reference counter.
error_type CALLING_CONVENTION NameObject_FromObject(ObjectHandle *handle, NameObjectHandle **result)
Convert ObjectHandle to NameObjectHandle.
Base class for syntactic tokens.
error_type CALLING_CONVENTION Object_GetObjectType(ObjectHandle *handle, ObjectType *result)
Get derived type of current object.
error_type CALLING_CONVENTION Object_Release(ObjectHandle *handle)
Decrement the internal reference counter.
Output stream can write sequences of characters and represent other kinds of data.
error_type CALLING_CONVENTION OutputStream_Release(OutputStreamHandle *handle)
Decrement the internal reference counter.
error_type CALLING_CONVENTION OutputStream_Flush(OutputStreamHandle *handle)
Flushes all pending data from the stream to it's destination.
error_type CALLING_CONVENTION OutputStream_WriteBuffer(OutputStreamHandle *handle, BufferHandle *data)
Appends buffer data to current output stream instance.
error_type CALLING_CONVENTION OutputStream_CreateFromFile(string_type filename, OutputStreamHandle **result)
Creates a new file at filename location and opens it for writing.
A content stream is a PDF stream object whose data consists of a sequence of instructions describing ...
error_type CALLING_CONVENTION PageContents_Release(PageContentsHandle *handle)
Decrement the internal reference counter.
error_type CALLING_CONVENTION PageContents_GetInstructionAt(PageContentsHandle *handle, size_type at, ContentInstructionHandle **result)
Get instruction at location at.
error_type CALLING_CONVENTION PageContents_GetInstructionsSize(PageContentsHandle *handle, size_type *result)
Return size of a collection.
The leaves of the page tree are page objects, each of which is a dictionary specifying the attributes...
error_type CALLING_CONVENTION PageObject_Release(PageObjectHandle *handle)
Decrement the internal reference counter.
error_type CALLING_CONVENTION PageObject_GetContents(PageObjectHandle *handle, PageContentsHandle **result)
A content stream (see 7.8.2, "Content Streams") that shall describe the contents of this page....
The pages of a document are accessed through a structure known as the page tree, which defines the or...
error_type CALLING_CONVENTION PageTree_Release(PageTreeHandle *handle)
Decrement the internal reference counter.
error_type CALLING_CONVENTION PageTree_GetPageCount(PageTreeHandle *handle, size_type *result)
Get total number of pages in current document.
error_type CALLING_CONVENTION PageTree_GetPage(PageTreeHandle *handle, size_type at, PageObjectHandle **result)
Get page at index at.
Stream object represents compressed data inside document.
error_type CALLING_CONVENTION StreamObject_GetBodyRaw(StreamObjectHandle *handle, BufferHandle **result)
Get uncompressed stream body.
error_type CALLING_CONVENTION StreamObject_GetBody(StreamObjectHandle *handle, BufferHandle **result)
Get decompressed stream content.
error_type CALLING_CONVENTION StreamObject_GetHeader(StreamObjectHandle *handle, DictionaryObjectHandle **result)
Return streams header dictionary.
error_type CALLING_CONVENTION StreamObject_FromObject(ObjectHandle *handle, StreamObjectHandle **result)
Convert ObjectHandle to StreamObjectHandle.
error_type CALLING_CONVENTION StreamObject_Release(StreamObjectHandle *handle)
Decrement the internal reference counter.
An ordered collection of all XrefHandle within the PDF file.
error_type CALLING_CONVENTION XrefChain_GetIterator(XrefChainHandle *handle, XrefChainIteratorHandle **result)
Get cross-reference section iterator.
error_type CALLING_CONVENTION XrefChain_Release(XrefChainHandle *handle)
Decrement the internal reference counter.
A pointer to XrefHandle within XrefChainHandle collection.
error_type CALLING_CONVENTION XrefChainIterator_IsValid(XrefChainIteratorHandle *handle, boolean_type *result)
Determine if the current iterator position is valid.
error_type CALLING_CONVENTION XrefChainIterator_Next(XrefChainIteratorHandle *handle)
Advance iterator to the next position.
error_type CALLING_CONVENTION XrefChainIterator_Release(XrefChainIteratorHandle *handle)
Decrement the internal reference counter.
error_type CALLING_CONVENTION XrefChainIterator_GetValue(XrefChainIteratorHandle *handle, XrefHandle **result)
Get cross-reference section from current iterator position.
Represents compressed entry within cross-reference section.
error_type CALLING_CONVENTION XrefCompressedEntry_FromEntry(XrefEntryHandle *handle, XrefCompressedEntryHandle **result)
Convert XrefEntryHandle to XrefUsedEntryHandle.
error_type CALLING_CONVENTION XrefCompressedEntry_Release(XrefCompressedEntryHandle *handle)
Decrement the internal reference counter.
error_type CALLING_CONVENTION XrefCompressedEntry_GetReference(XrefCompressedEntryHandle *handle, ObjectHandle **result)
Get reference to the object represented by this entry.
Cross-reference entry represents item within XrefHandle.
error_type CALLING_CONVENTION XrefEntry_GetObjectNumber(XrefEntryHandle *handle, biguint_type *result)
Get entry object number.
error_type CALLING_CONVENTION XrefEntry_GetType(XrefEntryHandle *handle, XrefEntryType *result)
Get entry type.
error_type CALLING_CONVENTION XrefEntry_GetGenerationNumber(XrefEntryHandle *handle, ushort_type *result)
Get entry generation number.
error_type CALLING_CONVENTION XrefEntry_Release(XrefEntryHandle *handle)
Decrement the internal reference counter.
The cross-reference table contains information that permits random access to indirect objects within ...
error_type CALLING_CONVENTION Xref_GetIterator(XrefHandle *handle, XrefIteratorHandle **result)
Get cross-reference entry iterator.
error_type CALLING_CONVENTION Xref_Release(XrefHandle *handle)
Decrement the internal reference counter.
A pointer to XrefEntryHandle within XrefHandle collection.
error_type CALLING_CONVENTION XrefIterator_GetValue(XrefIteratorHandle *handle, XrefEntryHandle **result)
Get cross-reference entry from current iterator position.
error_type CALLING_CONVENTION XrefIterator_IsValid(XrefIteratorHandle *handle, boolean_type *result)
Check if the current iterator position is valid.
error_type CALLING_CONVENTION XrefIterator_Next(XrefIteratorHandle *handle)
Advance iterator to the next position.
error_type CALLING_CONVENTION XrefIterator_Release(XrefIteratorHandle *handle)
Decrement the internal reference counter.
Represents used entry within cross-reference section.
error_type CALLING_CONVENTION XrefUsedEntry_Release(XrefUsedEntryHandle *handle)
Decrement the internal reference counter.
error_type CALLING_CONVENTION XrefUsedEntry_FromEntry(XrefEntryHandle *handle, XrefUsedEntryHandle **result)
Convert XrefEntryHandle to XrefUsedEntryHandle.
error_type CALLING_CONVENTION XrefUsedEntry_GetReference(XrefUsedEntryHandle *handle, ObjectHandle **result)
Get reference to the object represented by this entry.
const boolean_type VANILLAPDF_RV_TRUE
Represents the boolean true value.
const boolean_type VANILLAPDF_RV_FALSE
Represents the boolean false value.
ContentObjectType
Derived types of ContentObjectHandle.
Definition: c_content_object.h:49
ContentInstructionType
Available content instruction types.
Definition: c_content_instruction.h:43
@ ContentObjectType_InlineImage
As an alternative to the image XObjects described in section 8.9.5 - Image Dictionaries,...
Definition: c_content_object.h:61
@ ContentInstructionType_Object
A sequence of content instructions grouped within a single object.
Definition: c_content_instruction.h:56
const error_type VANILLAPDF_ERROR_SUCCESS
Indicates that the operation completed successfully.
const NameObjectHandle * NameConstant_Type
Usually represents a dictionary type entry.
ObjectType
Derived types of ObjectHandle.
Definition: c_object.h:29
@ ObjectType_Stream
Stream object represents compressed data inside document.
Definition: c_object.h:82
@ ObjectType_Integer
Integer objects represent mathematical integers.
Definition: c_object.h:64
@ ObjectType_Name
A name object is an atomic symbol uniquely defined by a sequence of characters.
Definition: c_object.h:70
uint32_t error_type
This is return value type of all API functions.
Definition: c_types.h:25
uint64_t biguint_type
64-bit unsigned integer type
Definition: c_types.h:77
uint16_t ushort_type
16-bit unsigned integer
Definition: c_types.h:46
int8_t boolean_type
Boolean type supported in C.
Definition: c_types.h:31
uint32_t size_type
Size type defined in standard library.
Definition: c_types.h:62