123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800 |
- extern "C" {
- struct pdf_doc;
- struct pdf_object;
- struct pdf_info {
- char creator[64];
- char producer[64];
- char title[64];
-
- char author[64];
- char subject[64];
- char date[64];
- };
- enum {
- IMAGE_PNG,
- IMAGE_JPG,
- IMAGE_PPM,
- IMAGE_BMP,
- IMAGE_UNKNOWN
- };
- enum {
-
- PNG_COLOR_GREYSCALE = 0,
-
- PNG_COLOR_RGB = 2,
-
- PNG_COLOR_INDEXED = 3,
-
- PNG_COLOR_GREYSCALE_A = 4,
-
- PNG_COLOR_RGBA = 6,
- PNG_COLOR_INVALID = 255
- };
- struct png_header {
- uint32_t width;
- uint32_t height;
- uint8_t bitDepth;
- uint8_t colorType;
- uint8_t deflate;
- uint8_t filtering;
- uint8_t interlace;
- };
- struct bmp_header {
- uint32_t bfSize;
- uint16_t bfReserved1;
- uint16_t bfReserved2;
- uint32_t bfOffBits;
- uint32_t biSize;
- int32_t biWidth;
- int32_t biHeight;
- uint16_t biPlanes;
- uint16_t biBitCount;
- uint32_t biCompression;
- };
- struct jpeg_header {
- int ncolours;
- };
- enum {
- PPM_BINARY_COLOR_RGB,
- PPM_BINARY_COLOR_GRAY,
-
- };
- struct ppm_header {
- size_t size;
- size_t data_begin_pos;
- int color_space;
- };
- struct pdf_img_info {
- int image_format;
- uint32_t width;
- uint32_t height;
-
-
- union {
- struct bmp_header bmp;
- struct jpeg_header jpeg;
- struct png_header png;
- struct ppm_header ppm;
- };
- };
- struct pdf_path_operation {
- char op;
- float x1;
- float y1;
- float x2;
- float y2;
- float x3;
- float y3;
- };
- (uint32_t)((((r)&0xff) << 16) | (((g)&0xff) << 8) | (((b)&0xff)))
- (uint32_t)(((uint32_t)((a)&0xff) << 24) | (((r)&0xff) << 16) | \
- (((g)&0xff) << 8) | (((b)&0xff)))
- enum {
- PDF_ALIGN_LEFT,
- PDF_ALIGN_RIGHT,
- PDF_ALIGN_CENTER,
- PDF_ALIGN_JUSTIFY,
-
- PDF_ALIGN_JUSTIFY_ALL,
-
- PDF_ALIGN_NO_WRITE,
-
- };
- struct pdf_doc *pdf_create(float width, float height,
- const struct pdf_info *info);
- void pdf_destroy(struct pdf_doc *pdf);
- const char *pdf_get_err(const struct pdf_doc *pdf, int *errval);
- void pdf_clear_err(struct pdf_doc *pdf);
- int pdf_set_font(struct pdf_doc *pdf, const char *font);
- int pdf_get_font_text_width(struct pdf_doc *pdf, const char *font_name,
- const char *text, float size, float *text_width);
- float pdf_height(const struct pdf_doc *pdf);
- float pdf_width(const struct pdf_doc *pdf);
- float pdf_page_height(const struct pdf_object *page);
- float pdf_page_width(const struct pdf_object *page);
- struct pdf_object *pdf_append_page(struct pdf_doc *pdf);
- struct pdf_object *pdf_get_page(struct pdf_doc *pdf, int page_number);
- int pdf_page_set_size(struct pdf_doc *pdf, struct pdf_object *page,
- float width, float height);
- int pdf_save(struct pdf_doc *pdf, const char *filename);
- int pdf_save_file(struct pdf_doc *pdf, FILE *fp);
- int pdf_add_text(struct pdf_doc *pdf, struct pdf_object *page,
- const char *text, float size, float xoff, float yoff,
- uint32_t colour);
- int pdf_add_text_rotate(struct pdf_doc *pdf, struct pdf_object *page,
- const char *text, float size, float xoff, float yoff,
- float angle, uint32_t colour);
- int pdf_add_text_wrap(struct pdf_doc *pdf, struct pdf_object *page,
- const char *text, float size, float xoff, float yoff,
- float angle, uint32_t colour, float wrap_width,
- int align, float *height);
- int pdf_add_line(struct pdf_doc *pdf, struct pdf_object *page, float x1,
- float y1, float x2, float y2, float width, uint32_t colour);
- int pdf_add_cubic_bezier(struct pdf_doc *pdf, struct pdf_object *page,
- float x1, float y1, float x2, float y2, float xq1,
- float yq1, float xq2, float yq2, float width,
- uint32_t colour);
- int pdf_add_quadratic_bezier(struct pdf_doc *pdf, struct pdf_object *page,
- float x1, float y1, float x2, float y2,
- float xq1, float yq1, float width,
- uint32_t colour);
- int pdf_add_custom_path(struct pdf_doc *pdf, struct pdf_object *page,
- const struct pdf_path_operation *operations,
- int operation_count, float stroke_width,
- uint32_t stroke_colour, uint32_t fill_colour);
- int pdf_add_ellipse(struct pdf_doc *pdf, struct pdf_object *page, float x,
- float y, float xradius, float yradius, float width,
- uint32_t colour, uint32_t fill_colour);
- int pdf_add_circle(struct pdf_doc *pdf, struct pdf_object *page, float x,
- float y, float radius, float width, uint32_t colour,
- uint32_t fill_colour);
- int pdf_add_rectangle(struct pdf_doc *pdf, struct pdf_object *page, float x,
- float y, float width, float height, float border_width,
- uint32_t colour);
- int pdf_add_filled_rectangle(struct pdf_doc *pdf, struct pdf_object *page,
- float x, float y, float width, float height,
- float border_width, uint32_t colour_fill,
- uint32_t colour_border);
- int pdf_add_polygon(struct pdf_doc *pdf, struct pdf_object *page, float x[],
- float y[], int count, float border_width,
- uint32_t colour);
- int pdf_add_filled_polygon(struct pdf_doc *pdf, struct pdf_object *page,
- float x[], float y[], int count,
- float border_width, uint32_t colour);
- int pdf_add_bookmark(struct pdf_doc *pdf, struct pdf_object *page, int parent,
- const char *name);
- int pdf_add_link(struct pdf_doc *pdf, struct pdf_object *page, float x,
- float y, float width, float height,
- struct pdf_object *target_page, float target_x,
- float target_y);
- enum {
- PDF_BARCODE_128A,
- PDF_BARCODE_39,
- PDF_BARCODE_EAN13,
- PDF_BARCODE_UPCA,
- PDF_BARCODE_EAN8,
- PDF_BARCODE_UPCE,
- };
- int pdf_add_barcode(struct pdf_doc *pdf, struct pdf_object *page, int code,
- float x, float y, float width, float height,
- const char *string, uint32_t colour);
- int pdf_add_image_data(struct pdf_doc *pdf, struct pdf_object *page, float x,
- float y, float display_width, float display_height,
- const uint8_t *data, size_t len);
- int pdf_add_rgb24(struct pdf_doc *pdf, struct pdf_object *page, float x,
- float y, float display_width, float display_height,
- const uint8_t *data, uint32_t width, uint32_t height);
- int pdf_add_grayscale8(struct pdf_doc *pdf, struct pdf_object *page, float x,
- float y, float display_width, float display_height,
- const uint8_t *data, uint32_t width, uint32_t height);
- int pdf_add_image_file(struct pdf_doc *pdf, struct pdf_object *page, float x,
- float y, float display_width, float display_height,
- const char *image_filename);
- int pdf_parse_image_header(struct pdf_img_info *info, const uint8_t *data,
- size_t length, char *err_msg,
- size_t err_msg_length);
- }
|