libspectre 0.2.11
Data Structures | Functions
spectre-document.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "spectre-document.h"
#include "spectre-private.h"
#include "spectre-exporter.h"
#include "spectre-utils.h"

Data Structures

struct  SpectreDocument
 

Functions

SpectreDocumentspectre_document_new (void)
 
static void document_load (SpectreDocument *document, const char *filename, FILE *file)
 
void spectre_document_load (SpectreDocument *document, const char *filename)
 
void spectre_document_load_from_stream (SpectreDocument *document, FILE *file)
 
void spectre_document_free (SpectreDocument *document)
 
SpectreStatus spectre_document_status (SpectreDocument *document)
 
unsigned int spectre_document_get_n_pages (SpectreDocument *document)
 
SpectreOrientation spectre_document_get_orientation (SpectreDocument *document)
 
const char * spectre_document_get_title (SpectreDocument *document)
 
const char * spectre_document_get_creator (SpectreDocument *document)
 
const char * spectre_document_get_for (SpectreDocument *document)
 
const char * spectre_document_get_creation_date (SpectreDocument *document)
 
const char * spectre_document_get_format (SpectreDocument *document)
 
int spectre_document_is_eps (SpectreDocument *document)
 
unsigned int spectre_document_get_language_level (SpectreDocument *document)
 
SpectrePagespectre_document_get_page (SpectreDocument *document, unsigned int page_index)
 
SpectrePagespectre_document_get_page_by_label (SpectreDocument *document, const char *label)
 
void spectre_document_render_full (SpectreDocument *document, SpectreRenderContext *rc, unsigned char **page_data, int *row_length)
 
void spectre_document_render (SpectreDocument *document, unsigned char **page_data, int *row_length)
 
void spectre_document_get_page_size (SpectreDocument *document, int *width, int *height)
 
void spectre_document_save (SpectreDocument *document, const char *filename)
 
void spectre_document_save_to_pdf (SpectreDocument *document, const char *filename)
 
struct document * _spectre_document_get_doc (SpectreDocument *document)
 

Function Documentation

◆ _spectre_document_get_doc()

struct document * _spectre_document_get_doc ( SpectreDocument document)

◆ document_load()

static void document_load ( SpectreDocument document,
const char *  filename,
FILE *  file 
)
static

◆ spectre_document_free()

void spectre_document_free ( SpectreDocument document)

Frees the document

Parameters
documentthe document that will be freed

◆ spectre_document_get_creation_date()

const char * spectre_document_get_creation_date ( SpectreDocument document)

Returns the creation date of the document. The date is copied verbatim from the document, so no format can be assumed on it. It returns a null const char * if the document specifies no creation date. This function can fail

Parameters
documentthe document whose creation date will be returned
See also
spectre_document_status

◆ spectre_document_get_creator()

const char * spectre_document_get_creator ( SpectreDocument document)

Returns the creator of the document. It returns a null const char * if the document specifies no creator. This function can fail

Parameters
documentthe document whose creator will be returned
See also
spectre_document_status

◆ spectre_document_get_for()

const char * spectre_document_get_for ( SpectreDocument document)

Returns the for of the document. It returns a null const char * if the document specifies no for. This function can fail

Parameters
documentthe document whose for will be returned
See also
spectre_document_status

◆ spectre_document_get_format()

const char * spectre_document_get_format ( SpectreDocument document)

Returns the format of the document. This function can fail

Parameters
documentthe document whose format will be returned
See also
spectre_document_status

◆ spectre_document_get_language_level()

unsigned int spectre_document_get_language_level ( SpectreDocument document)

Returns the PostScript language level of the document. It returns 0 if no language level was defined on the file. This function can fail

Parameters
documentthe document whose language level will be returned
See also
spectre_document_status

◆ spectre_document_get_n_pages()

unsigned int spectre_document_get_n_pages ( SpectreDocument document)

Returns the number of pages of the document. This function can fail

Parameters
documentthe document whose pages number will be returned
See also
spectre_document_status

◆ spectre_document_get_orientation()

SpectreOrientation spectre_document_get_orientation ( SpectreDocument document)

Returns the orientation of the document. This function can fail

Parameters
documentthe document whose orientation will be returned
See also
spectre_document_status

◆ spectre_document_get_page()

SpectrePage * spectre_document_get_page ( SpectreDocument document,
unsigned int  page_index 
)

Returns a page of the document. This function can fail

Parameters
documentthe document whose page will be returned
page_indexthe page index to get. First page has index 0.
See also
spectre_document_status

◆ spectre_document_get_page_by_label()

SpectrePage * spectre_document_get_page_by_label ( SpectreDocument document,
const char *  label 
)

Returns a page of the document referenced by label. This function can fail

Parameters
documentthe document whose page will be returned
labelthe label of the page to get.
See also
spectre_document_status

◆ spectre_document_get_page_size()

void spectre_document_get_page_size ( SpectreDocument document,
int *  width,
int *  height 
)

◆ spectre_document_get_title()

const char * spectre_document_get_title ( SpectreDocument document)

Returns the title of the document. It returns a null const char * if the document specifies no title. This function can fail

Parameters
documentthe document whose title will be returned
See also
spectre_document_status

◆ spectre_document_is_eps()

int spectre_document_is_eps ( SpectreDocument document)

Returns if the document is a Encapsulated PostScript file. This function can fail

Parameters
documentthe document to query
See also
spectre_document_status

◆ spectre_document_load()

void spectre_document_load ( SpectreDocument document,
const char *  filename 
)

Loads a the given file into the document. This function can fail

Parameters
documentthe document where the file will be loaded
filenamethe file to loa
See also
spectre_document_status

◆ spectre_document_load_from_stream()

void spectre_document_load_from_stream ( SpectreDocument document,
FILE *  file 
)

◆ spectre_document_new()

SpectreDocument * spectre_document_new ( void  )

Creates a document

◆ spectre_document_render()

void spectre_document_render ( SpectreDocument document,
unsigned char **  page_data,
int *  row_length 
)

Convenient function for rendering documents with no pages, tipically eps. Document will be rendered with the default options, use spectre_document_render_full if you want to change any of them. When used with multi-page documents the first page will be rendered.

Parameters
documentthe document to render @width the page width will be returned here, or NULL @height the page height will be returned here, or NULL @page_data a pointer that will point to the image data @row_length the length of an image row will be returned here
See also
spectre_document_render_full

◆ spectre_document_render_full()

void spectre_document_render_full ( SpectreDocument document,
SpectreRenderContext rc,
unsigned char **  page_data,
int *  row_length 
)

Convenient function for rendering documents with no pages, tipically eps. When used with multi-page documents the first page will be rendered.

Parameters
documentthe document to render @rc the rendering context specifying how the document has to be rendered @width the page width will be returned here, or NULL @height the page height will be returned here, or NULL @page_data a pointer that will point to the image data @row_length the length of an image row will be returned here
See also
spectre_document_render_full

◆ spectre_document_save()

void spectre_document_save ( SpectreDocument document,
const char *  filename 
)

Save document as filename. This function can fail

Parameters
documentthe document that will be saved
filenamethe path where document will be saved
See also
spectre_document_status

◆ spectre_document_save_to_pdf()

void spectre_document_save_to_pdf ( SpectreDocument document,
const char *  filename 
)

◆ spectre_document_status()

SpectreStatus spectre_document_status ( SpectreDocument document)

Returns the document status

Parameters
documentthe document whose status will be returned