About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pdfdoc.c File Reference
#include "system.h"
#include "mem.h"
#include "error.h"
#include "mfileio.h"
#include "dpxconf.h"
#include "numbers.h"
#include "pdfobj.h"
#include "pdfparse.h"
#include "pdfnames.h"
#include "pdfencrypt.h"
#include "dvipdfmx.h"
#include "pdfdev.h"
#include "pdfdraw.h"
#include "pdfcolor.h"
#include "pdfresource.h"
#include "pdffont.h"
#include "pdfximage.h"
#include "pdflimits.h"
#include "jpegimage.h"
#include "pdfdoc.h"
Include dependency graph for pdfdoc.c:

Go to the source code of this file.


struct  pdf_form
struct  form_list_node
struct  pdf_page
struct  pdf_olitem
struct  pdf_bead
struct  pdf_article
struct  name_dict
struct  pdf_doc


#define USE_MY_MEDIABOX   (1 << 0)
#define LASTPAGE(p)   (&(p->pages.entries[p->pages.num_entries]))
#define FIRSTPAGE(p)   (&(p->pages.entries[0]))
#define PAGECOUNT(p)   (p->pages.num_entries)
#define MAXPAGES(p)   (p->pages.max_entries)
#define PAGE_CLUSTER   4
#define VALIDATE_BOX(o)
#define MAX_OUTLINE_DEPTH   256u
#define TITLE_STRING   "<No Title>"
#define JS_CODE   "app.alert(\"The author of this document made this bookmark item empty!\", 3, 0)"
#define BMOPEN(b, p)   (((b) < 0) ? (((p)->outlines.current_depth > (p)->options.outline_open_depth) ? 0 : 1) : (b))
#define NUM_NAME_CATEGORY   (sizeof(name_dict_categories)/sizeof(name_dict_categories[0]))


typedef struct pdf_form pdf_form
typedef struct pdf_page pdf_page
typedef struct pdf_olitem pdf_olitem
typedef struct pdf_bead pdf_bead
typedef struct pdf_article pdf_article
typedef struct pdf_doc pdf_doc


static pdf_objread_thumbnail (const char *thumb_filename)
static void pdf_doc_init_catalog (pdf_doc *p)
static void pdf_doc_close_catalog (pdf_doc *p)
static void doc_resize_page_entries (pdf_doc *p, int size)
static pdf_pagedoc_get_page_entry (pdf_doc *p, unsigned int page_no)
static void pdf_doc_init_page_tree (pdf_doc *p, double media_width, double media_height)
static void pdf_doc_close_page_tree (pdf_doc *p)
static void pdf_doc_init_names (pdf_doc *p, int check_gotos)
static void pdf_doc_close_names (pdf_doc *p)
static void pdf_doc_add_goto (pdf_obj *annot_dict)
static void pdf_doc_init_docinfo (pdf_doc *p)
static void pdf_doc_close_docinfo (pdf_doc *p)
static void pdf_doc_init_articles (pdf_doc *p)
static void pdf_doc_close_articles (pdf_doc *p)
static void pdf_doc_init_bookmarks (pdf_doc *p, int bm_open_depth)
static void pdf_doc_close_bookmarks (pdf_doc *p)
void pdf_doc_set_bop_content (const char *content, unsigned length)
void pdf_doc_set_eop_content (const char *content, unsigned length)
static pdf_objpdf_doc_get_page_resources (pdf_doc *p, const char *category)
void pdf_doc_add_page_resource (const char *category, const char *resource_name, pdf_obj *resource_ref)
static void doc_flush_page (pdf_doc *p, pdf_page *page, pdf_obj *parent_ref)
static pdf_objbuild_page_tree (pdf_doc *p, pdf_page *firstpage, int num_pages, pdf_obj *parent_ref)
int pdf_doc_get_page_count (pdf_file *pf)
static int set_bounding_box (pdf_rect *bbox, enum pdf_page_boundary opt_bbox, pdf_obj *media_box, pdf_obj *crop_box, pdf_obj *art_box, pdf_obj *trim_box, pdf_obj *bleed_box)
static int set_transform_matrix (pdf_tmatrix *matrix, pdf_rect *bbox, pdf_obj *rotate)
pdf_objpdf_doc_get_page (pdf_file *pf, int page_no, enum pdf_page_boundary opt_bbox, pdf_rect *bbox, pdf_tmatrix *matrix, pdf_obj **resources_p)
static int clean_bookmarks (pdf_olitem *item)
static int flush_bookmarks (pdf_olitem *item, pdf_obj *parent_ref, pdf_obj *parent_dict)
int pdf_doc_bookmarks_up (void)
int pdf_doc_bookmarks_down (void)
int pdf_doc_bookmarks_depth (void)
void pdf_doc_bookmarks_add (pdf_obj *dict, int is_open)
int pdf_doc_add_names (const char *category, const void *key, int keylen, pdf_obj *value)
static void warn_undef_dests (struct ht_table *dests, struct ht_table *gotos)
static void pdf_doc_get_mediabox (unsigned page_no, pdf_rect *mediabox)
void pdf_doc_add_annot (unsigned page_no, const pdf_rect *rect, pdf_obj *annot_dict, int new_annot)
void pdf_doc_begin_article (const char *article_id, pdf_obj *article_info)
static pdf_beadfind_bead (pdf_article *article, const char *bead_id)
void pdf_doc_add_bead (const char *article_id, const char *bead_id, int page_no, const pdf_rect *rect)
static pdf_objmake_article (pdf_doc *p, pdf_article *article, const char **bead_ids, int num_beads, pdf_obj *article_info)
static void clean_article (pdf_article *article)
void pdf_doc_set_mediabox (unsigned page_no, const pdf_rect *mediabox)
pdf_objpdf_doc_current_page_resources (void)
pdf_objpdf_doc_get_dictionary (const char *category)
int pdf_doc_current_page_number (void)
pdf_objpdf_doc_ref_page (unsigned page_no)
pdf_objpdf_doc_get_reference (const char *category)
static void pdf_doc_new_page (pdf_doc *p)
static void pdf_doc_finish_page (pdf_doc *p)
void pdf_doc_set_bgcolor (const pdf_color *color)
static void doc_fill_page_background (pdf_doc *p)
void pdf_doc_begin_page (double scale, double x_origin, double y_origin)
void pdf_doc_end_page (void)
void pdf_doc_add_page_content (const char *buffer, unsigned length)
void pdf_open_document (const char *filename, const char *creator, const unsigned char *id1, const unsigned char *id2, struct pdf_setting settings)
void pdf_close_document (void)
static void pdf_doc_make_xform (pdf_obj *xform, pdf_rect *bbox, pdf_tmatrix *matrix, pdf_obj *resources, pdf_obj *attrib)
int pdf_doc_begin_grabbing (const char *ident, double ref_x, double ref_y, const pdf_rect *cropbox)
void pdf_doc_end_grabbing (pdf_obj *attrib)
static void reset_box (void)
void pdf_doc_begin_annot (pdf_obj *dict)
void pdf_doc_end_annot (void)
void pdf_doc_break_annot (void)
void pdf_doc_expand_box (const pdf_rect *rect)


struct ht_tableglobal_names = NULL
static pdf_doc pdoc
static const char * name_dict_categories []
static pdf_color bgcolor = { -1, -1 , 1, NULL, { 1.0 }, -1}
struct {
   int   dirty
   int   broken
   pdf_obj *   annot_dict
   pdf_rect   rect
breaking_state = {0, 0, NULL, {0.0, 0.0, 0.0, 0.0}}

Macro Definition Documentation


#define BMOPEN (   b,
)    (((b) < 0) ? (((p)->outlines.current_depth > (p)->options.outline_open_depth) ? 0 : 1) : (b))



Definition at line 1245 of file pdfdoc.c.


#define FIRSTPAGE (   p)    (&(p->pages.entries[0]))

Definition at line 303 of file pdfdoc.c.


#define JS_CODE   "app.alert(\"The author of this document made this bookmark item empty!\", 3, 0)"


#define LASTPAGE (   p)    (&(p->pages.entries[p->pages.num_entries]))

Definition at line 302 of file pdfdoc.c.


#define MAX_OUTLINE_DEPTH   256u


#define MAXPAGES (   p)    (p->pages.max_entries)

Definition at line 305 of file pdfdoc.c.


Definition at line 1531 of file pdfdoc.c.


#define PAGE_CLUSTER   4

Definition at line 649 of file pdfdoc.c.


#define PAGECOUNT (   p)    (p->pages.num_entries)

Definition at line 304 of file pdfdoc.c.



Definition at line 66 of file pdfdoc.c.



Definition at line 67 of file pdfdoc.c.



Definition at line 65 of file pdfdoc.c.


#define TITLE_STRING   "<No Title>"


#define USE_MY_MEDIABOX   (1 << 0)

Definition at line 122 of file pdfdoc.c.


#define VALIDATE_BOX (   o)
if ((o)) {\
if (!PDF_OBJ_ARRAYTYPE((o)) || pdf_array_length((o)) != 4) \
return -1;\
unsigned pdf_array_length(pdf_obj *array)
Definition: pdfobj.c:1479
Definition: pdfobj.h:81

Typedef Documentation

◆ pdf_article

typedef struct pdf_article pdf_article

◆ pdf_bead

typedef struct pdf_bead pdf_bead

◆ pdf_doc

typedef struct pdf_doc pdf_doc

◆ pdf_form

typedef struct pdf_form pdf_form

◆ pdf_olitem

typedef struct pdf_olitem pdf_olitem

◆ pdf_page

typedef struct pdf_page pdf_page

Function Documentation

◆ build_page_tree()

static pdf_obj* build_page_tree ( pdf_doc p,
pdf_page firstpage,
int  num_pages,
pdf_obj parent_ref 

◆ clean_article()

static void clean_article ( pdf_article article)

◆ clean_bookmarks()

static int clean_bookmarks ( pdf_olitem item)

Definition at line 1279 of file pdfdoc.c.

References item, next, pdf_release_obj(), and RELEASE.

Referenced by pdf_doc_close_bookmarks().

◆ doc_fill_page_background()

◆ doc_flush_page()

static void doc_flush_page ( pdf_doc p,
pdf_page page,
pdf_obj parent_ref 

◆ doc_get_page_entry()

static pdf_page* doc_get_page_entry ( pdf_doc p,
unsigned int  page_no 

◆ doc_resize_page_entries()

static void doc_resize_page_entries ( pdf_doc p,
int  size 

Definition at line 308 of file pdfdoc.c.

References i, MAXPAGES, NULL, p, RENEW, and size.

Referenced by doc_get_page_entry(), and pdf_doc_new_page().

◆ find_bead()

static pdf_bead* find_bead ( pdf_article article,
const char *  bead_id 

Definition at line 1869 of file pdfdoc.c.

References pdf_article::beads, i, pdf_bead::id, NULL, pdf_article::num_beads, and strcmp().

Referenced by make_article(), and pdf_doc_add_bead().

◆ flush_bookmarks()

static int flush_bookmarks ( pdf_olitem item,
pdf_obj parent_ref,
pdf_obj parent_dict 

◆ make_article()

◆ pdf_close_document()

◆ pdf_doc_add_annot()

◆ pdf_doc_add_bead()

◆ pdf_doc_add_goto()

◆ pdf_doc_add_names()

int pdf_doc_add_names ( const char *  category,
const void key,
int  keylen,
pdf_obj value 

Definition at line 1560 of file pdfdoc.c.

References i, key, NULL, p, pdf_names_add_object(), pdf_new_name_tree(), pdoc, strcmp(), and WARN().

Referenced by spc_handler_pdfm_dest(), and spc_handler_pdfm_names().

◆ pdf_doc_add_page_content()

◆ pdf_doc_add_page_resource()

◆ pdf_doc_begin_annot()

void pdf_doc_begin_annot ( pdf_obj dict)

Definition at line 2789 of file pdfdoc.c.

References breaking_state, and reset_box().

Referenced by do_bann(), html_make_link_dict(), and spc_begin_annot().

◆ pdf_doc_begin_article()

void pdf_doc_begin_article ( const char *  article_id,
pdf_obj article_info 

◆ pdf_doc_begin_grabbing()

◆ pdf_doc_begin_page()

void pdf_doc_begin_page ( double  scale,
double  x_origin,
double  y_origin 

Definition at line 2442 of file pdfdoc.c.

References M, p, pdf_dev_bop(), pdf_doc_new_page(), pdoc, scale, x_origin, and y_origin.

Referenced by do_bop(), and mps_do_page().

◆ pdf_doc_bookmarks_add()

void pdf_doc_bookmarks_add ( pdf_obj dict,
int  is_open 

Definition at line 1455 of file pdfdoc.c.

References ASSERT, BMOPEN, is_open(), item, NEW, next, NULL, p, pdf_doc_add_goto(), pdf_link_obj(), and pdoc.

Referenced by spc_handler_pdfm_outline().

◆ pdf_doc_bookmarks_depth()

int pdf_doc_bookmarks_depth ( void  )

Definition at line 1447 of file pdfdoc.c.

References p, and pdoc.

Referenced by spc_handler_pdfm_outline().

◆ pdf_doc_bookmarks_down()

◆ pdf_doc_bookmarks_up()

int pdf_doc_bookmarks_up ( void  )

Definition at line 1365 of file pdfdoc.c.

References item, NEW, NULL, p, parent, pdoc, and WARN().

Referenced by spc_handler_pdfm_outline().

◆ pdf_doc_break_annot()

◆ pdf_doc_close_articles()

◆ pdf_doc_close_bookmarks()

static void pdf_doc_close_bookmarks ( pdf_doc p)

◆ pdf_doc_close_catalog()

◆ pdf_doc_close_docinfo()

◆ pdf_doc_close_names()

◆ pdf_doc_close_page_tree()

◆ pdf_doc_current_page_number()

◆ pdf_doc_current_page_resources()

pdf_obj* pdf_doc_current_page_resources ( void  )

◆ pdf_doc_end_annot()

void pdf_doc_end_annot ( void  )

Definition at line 2797 of file pdfdoc.c.

References breaking_state, NULL, pdf_doc_break_annot(), and pdf_release_obj().

Referenced by do_eann(), html_end_anchor(), and spc_end_annot().

◆ pdf_doc_end_grabbing()

◆ pdf_doc_end_page()

void pdf_doc_end_page ( void  )

Definition at line 2460 of file pdfdoc.c.

References doc_fill_page_background(), p, pdf_dev_eop(), pdf_doc_finish_page(), and pdoc.

Referenced by do_eop(), and mps_do_page().

◆ pdf_doc_expand_box()

void pdf_doc_expand_box ( const pdf_rect rect)

◆ pdf_doc_finish_page()

◆ pdf_doc_get_dictionary()

pdf_obj* pdf_doc_get_dictionary ( const char *  category)

Definition at line 2175 of file pdfdoc.c.

References ASSERT, currentpage, ERROR, LASTPAGE, NULL, p, pdf_new_dict(), pdoc, and strcmp().

◆ pdf_doc_get_mediabox()

static void pdf_doc_get_mediabox ( unsigned  page_no,
pdf_rect mediabox 

◆ pdf_doc_get_page()

◆ pdf_doc_get_page_count()

◆ pdf_doc_get_page_resources()

static pdf_obj* pdf_doc_get_page_resources ( pdf_doc p,
const char *  category 

◆ pdf_doc_get_reference()

pdf_obj* pdf_doc_get_reference ( const char *  category)

◆ pdf_doc_init_articles()

static void pdf_doc_init_articles ( pdf_doc p)

Definition at line 1829 of file pdfdoc.c.

References NULL, and p.

Referenced by pdf_open_document().

◆ pdf_doc_init_bookmarks()

static void pdf_doc_init_bookmarks ( pdf_doc p,
int  bm_open_depth 

Definition at line 1254 of file pdfdoc.c.

References item, MAX_OUTLINE_DEPTH, NEW, NULL, and p.

Referenced by pdf_open_document().

◆ pdf_doc_init_catalog()

static void pdf_doc_init_catalog ( pdf_doc p)

Definition at line 236 of file pdfdoc.c.

References NULL, p, pdf_new_dict(), and pdf_set_root().

Referenced by pdf_open_document().

◆ pdf_doc_init_docinfo()

static void pdf_doc_init_docinfo ( pdf_doc p)

Definition at line 413 of file pdfdoc.c.

References p, pdf_new_dict(), and pdf_set_info().

Referenced by pdf_open_document().

◆ pdf_doc_init_names()

static void pdf_doc_init_names ( pdf_doc p,
int  check_gotos 

◆ pdf_doc_init_page_tree()

static void pdf_doc_init_page_tree ( pdf_doc p,
double  media_width,
double  media_height 

Definition at line 715 of file pdfdoc.c.

References media_height, media_width, NULL, p, and pdf_new_dict().

Referenced by pdf_open_document().

◆ pdf_doc_make_xform()

static void pdf_doc_make_xform ( pdf_obj xform,
pdf_rect bbox,
pdf_tmatrix matrix,
pdf_obj resources,
pdf_obj attrib 

◆ pdf_doc_new_page()

◆ pdf_doc_ref_page()

◆ pdf_doc_set_bgcolor()

◆ pdf_doc_set_bop_content()

void pdf_doc_set_bop_content ( const char *  content,
unsigned  length 

◆ pdf_doc_set_eop_content()

void pdf_doc_set_eop_content ( const char *  content,
unsigned  length 

◆ pdf_doc_set_mediabox()

void pdf_doc_set_mediabox ( unsigned  page_no,
const pdf_rect mediabox 

◆ pdf_open_document()

◆ read_thumbnail()

static pdf_obj* read_thumbnail ( const char *  thumb_filename)

◆ reset_box()

static void reset_box ( void  )

Definition at line 2781 of file pdfdoc.c.

References breaking_state.

Referenced by pdf_doc_begin_annot(), and pdf_doc_break_annot().

◆ set_bounding_box()

◆ set_transform_matrix()

static int set_transform_matrix ( pdf_tmatrix matrix,
pdf_rect bbox,
pdf_obj rotate 

◆ warn_undef_dests()

static void warn_undef_dests ( struct ht_table dests,
struct ht_table gotos 

Variable Documentation

◆ annot_dict

pdf_obj* annot_dict

◆ bgcolor


◆ broken

int broken

Definition at line 2775 of file pdfdoc.c.

◆ dirty

◆ global_names

◆ name_dict_categories

const char* name_dict_categories[]
Initial value:
= {
"Dests", "AP", "JavaScript", "Pages",
"Templates", "IDS", "URLS", "EmbeddedFiles",
"AlternatePresentations", "Renditions"

Definition at line 1526 of file pdfdoc.c.

Referenced by pdf_doc_init_names().

◆ pdoc

◆ rect

Definition at line 2777 of file pdfdoc.c.

Referenced by make_article(), and pdf_doc_break_annot().