This program shows usage of matrix multiplication. It allows to produce some delayed and combined calculations on matrices.
Please pay attention, matrix combination operations and page operations are in reverse order to each other.
#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;
}
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_Stroke(HPDF_Page page)
Paint current path.
HPDF_STATUS HPDF_Page_MoveTo(HPDF_Page page, HPDF_REAL x, HPDF_REAL y)
Start new subpath and move current point for drawing path.
HPDF_STATUS HPDF_Page_Scale(HPDF_Page page, HPDF_REAL sx, HPDF_REAL sy)
Concatenate the page's transformation matrix with scale matrix.
HPDF_STATUS HPDF_Page_GSave(HPDF_Page page)
Save the page's current graphics state to the stack.
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_Concat(HPDF_Page page, HPDF_REAL a, HPDF_REAL b, HPDF_REAL c, HPDF_REAL d, HPDF_REAL x, HPDF_REAL y)
Concatenate the page's transformation matrix and specified matrix.
HPDF_STATUS HPDF_Page_Translate(HPDF_Page page, HPDF_REAL dx, HPDF_REAL dy)
Concatenate the page's transformation matrix with translation matrix.
HPDF_STATUS HPDF_Page_LineTo(HPDF_Page page, HPDF_REAL x, HPDF_REAL y)
Append path from current point to specified point.
HPDF_STATUS HPDF_Page_GRestore(HPDF_Page page)
Restore graphics state which is saved by HPDF_Page_GSave().
HPDF_STATUS HPDF_Page_Rotate(HPDF_Page page, HPDF_REAL a)
Concatenate the page's transformation matrix with rotate matrix.
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.
#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
#define HPDF_PI
Definition: hpdf_consts.h:32
@ HPDF_PAGE_SIZE_A4
ISO 216 "A4" page size (210.0mm x 297.0mm)
Definition: hpdf_page_sizes.h:137
@ HPDF_PAGE_LANDSCAPE
Landscape orientation (longest size horizontal)
Definition: hpdf_types.h:577
HPDF_TransMatrix HPDF_Matrix_Translate(HPDF_TransMatrix m, HPDF_REAL dx, HPDF_REAL dy)
HPDF_TransMatrix HPDF_Matrix_RotateDeg(HPDF_TransMatrix m, HPDF_REAL degrees)
HPDF_TransMatrix HPDF_Matrix_Scale(HPDF_TransMatrix m, HPDF_REAL sx, HPDF_REAL sy)
Definition: hpdf_objects.h:421
Definition: hpdf_doc.h:36
Definition: hpdf_types.h:240
HPDF_REAL b
Definition: hpdf_types.h:242
HPDF_REAL y
Definition: hpdf_types.h:246
HPDF_REAL a
Definition: hpdf_types.h:241
HPDF_REAL d
Definition: hpdf_types.h:244
HPDF_REAL c
Definition: hpdf_types.h:243
HPDF_REAL x
Definition: hpdf_types.h:245