This demo shows usage of PDF dictionaries and arrays. PDF tiling pattern is created by feeding corresponding dictionaries. Dictionary can have stream within, in this case it is created using HPDF_DictStream_New() function, otherwise HPDF_Dict_New() should be called.
Library automatically calculates cross-references when array inserted to dictionary or dictionary inserted to dictionary etc.
Also, some items are inserted to page's "Resources" dictionary. It is done using HPDF_Page_GetInheritableItem() function.
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include "handler.h"
int
main (int argc, char **argv)
{
char fname[256];
strcpy (fname, argv[0]);
strcat (fname, ".pdf");
pdf =
HPDF_New (demo_error_handler, NULL);
if (!pdf) {
printf ("error: cannot create PdfDoc object\n");
return 1;
}
if (setjmp(env)) {
return 1;
}
"q 0.49814 w -0.09962 -0.09962 m 10.0624 10.0624 l -0.09962 10.0624 m 10.0624 -0.09962 l S Q");
return 0;
}
HPDF_STATUS HPDF_SaveToFile(HPDF_Doc pdf, const char *filename)
Saves the current document to file.
void HPDF_Free(HPDF_Doc pdf)
Revoke a document object and all resources.
HPDF_Doc HPDF_New(HPDF_Error_Handler user_error_fn, void *user_data)
Create an instance of a document object and initialize it.
HPDF_STATUS HPDF_Page_Rectangle(HPDF_Page page, HPDF_REAL x, HPDF_REAL y, HPDF_REAL width, HPDF_REAL height)
Append rectangle to the current path.
HPDF_STATUS HPDF_Page_Fill(HPDF_Page page)
Fill current path using non-zero winding number rule.
HPDF_REAL HPDF_Page_GetHeight(HPDF_Page page)
Get page height.
HPDF_Page HPDF_AddPage(HPDF_Doc pdf)
Create new page and add it after the last page of document.
HPDF_STATUS HPDF_Page_SetSize(HPDF_Page page, HPDF_PageSizes size, HPDF_PageDirection direction)
Change page size and direction to a predefined ones.
HPDF_REAL HPDF_Page_GetWidth(HPDF_Page page)
Get page width.
#define HPDF_MM
Predefined value for calculations with millimeters. Equals to 72.0/25.4 (72 points pre inch per mm).
Definition: hpdf_consts.h:178
HPDF_Dict HPDF_DictStream_New(HPDF_MMgr mmgr, HPDF_Xref xref)
HPDF_Array HPDF_Array_New(HPDF_MMgr mmgr)
HPDF_STATUS HPDF_Array_AddReal(HPDF_Array array, HPDF_REAL value)
HPDF_STATUS HPDF_Dict_AddReal(HPDF_Dict dict, const char *key, HPDF_REAL value)
HPDF_Dict HPDF_Dict_New(HPDF_MMgr mmgr)
HPDF_STATUS HPDF_Array_AddName(HPDF_Array array, const char *value)
HPDF_STATUS HPDF_Dict_AddName(HPDF_Dict dict, const char *key, const char *value)
HPDF_STATUS HPDF_Xref_Add(HPDF_Xref xref, void *obj)
HPDF_STATUS HPDF_Dict_Add(HPDF_Dict dict, const char *key, void *obj)
#define HPDF_OCLASS_DICT
Definition: hpdf_objects.h:47
HPDF_STATUS HPDF_Dict_AddNumber(HPDF_Dict dict, const char *key, HPDF_INT32 value)
@ HPDF_PAGE_SIZE_A4
ISO 216 "A4" page size (210.0mm x 297.0mm)
Definition: hpdf_page_sizes.h:137
struct _HPDF_PageAttr_Rec * HPDF_PageAttr
Definition: hpdf_pages.h:51
void * HPDF_Page_GetInheritableItem(HPDF_Page page, const char *key, HPDF_UINT16 obj_class)
HPDF_STATUS HPDF_Stream_WriteStr(HPDF_Stream stream, const char *value)
float HPDF_REAL
Definition: hpdf_types.h:79
@ HPDF_PAGE_LANDSCAPE
Landscape orientation (longest size horizontal)
Definition: hpdf_types.h:577
Definition: hpdf_objects.h:333
Definition: hpdf_objects.h:421
void * attr
Definition: hpdf_objects.h:433
HPDF_MMgr mmgr
Definition: hpdf_objects.h:423
HPDF_Stream stream
Definition: hpdf_objects.h:430
Definition: hpdf_doc.h:36
HPDF_MMgr mmgr
Definition: hpdf_doc.h:40
HPDF_Xref xref
Definition: hpdf_doc.h:43
Definition: hpdf_pages.h:53
HPDF_Stream stream
Definition: hpdf_pages.h:66