Mon, 18 Aug 2003 09:59:41 +0000
added big-endian support
eric@62 | 1 | /* |
eric@125 | 2 | * tumble: build a PDF file from image files |
eric@62 | 3 | * |
eric@62 | 4 | * PDF routines |
eric@147 | 5 | * $Id: pdf.h,v 1.13 2003/03/19 23:53:09 eric Exp $ |
eric@62 | 6 | * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> |
eric@62 | 7 | * |
eric@62 | 8 | * This program is free software; you can redistribute it and/or modify |
eric@62 | 9 | * it under the terms of the GNU General Public License version 2 as |
eric@62 | 10 | * published by the Free Software Foundation. Note that permission is |
eric@62 | 11 | * not granted to redistribute this program under the terms of any |
eric@62 | 12 | * other version of the General Public License. |
eric@62 | 13 | * |
eric@62 | 14 | * This program is distributed in the hope that it will be useful, |
eric@62 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
eric@62 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
eric@62 | 17 | * GNU General Public License for more details. |
eric@62 | 18 | * |
eric@62 | 19 | * You should have received a copy of the GNU General Public License |
eric@62 | 20 | * along with this program; if not, write to the Free Software |
eric@62 | 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA |
eric@62 | 22 | */ |
eric@62 | 23 | |
eric@62 | 24 | |
eric@147 | 25 | /* Acrobat default units aren't really points, but they're close. */ |
eric@147 | 26 | #define POINTS_PER_INCH 72.0 |
eric@141 | 27 | |
eric@141 | 28 | /* page size limited by Acrobat Reader to 45 inches on a side */ |
eric@141 | 29 | #define PAGE_MAX_INCHES 45 |
eric@141 | 30 | #define PAGE_MAX_POINTS (PAGE_MAX_INCHES * POINTS_PER_INCH) |
eric@141 | 31 | |
eric@141 | 32 | |
eric@59 | 33 | typedef struct pdf_file *pdf_file_handle; |
eric@59 | 34 | |
eric@59 | 35 | typedef struct pdf_page *pdf_page_handle; |
eric@59 | 36 | |
eric@74 | 37 | typedef struct pdf_bookmark *pdf_bookmark_handle; |
eric@74 | 38 | |
eric@59 | 39 | |
eric@75 | 40 | #define PDF_PAGE_MODE_USE_NONE 0 |
eric@133 | 41 | #define PDF_PAGE_MODE_USE_OUTLINES 1 /* if no outlines, will use NONE */ |
eric@75 | 42 | #define PDF_PAGE_MODE_USE_THUMBS 2 /* not yet implemented */ |
eric@75 | 43 | |
eric@75 | 44 | |
eric@59 | 45 | void pdf_init (void); |
eric@59 | 46 | |
eric@133 | 47 | pdf_file_handle pdf_create (char *filename); |
eric@59 | 48 | |
eric@133 | 49 | void pdf_close (pdf_file_handle pdf_file, int page_mode); |
eric@59 | 50 | |
eric@59 | 51 | void pdf_set_author (pdf_file_handle pdf_file, char *author); |
eric@59 | 52 | void pdf_set_creator (pdf_file_handle pdf_file, char *author); |
eric@59 | 53 | void pdf_set_title (pdf_file_handle pdf_file, char *author); |
eric@59 | 54 | void pdf_set_subject (pdf_file_handle pdf_file, char *author); |
eric@59 | 55 | void pdf_set_keywords (pdf_file_handle pdf_file, char *author); |
eric@59 | 56 | |
eric@59 | 57 | |
eric@59 | 58 | /* width and height in units of 1/72 inch */ |
eric@59 | 59 | pdf_page_handle pdf_new_page (pdf_file_handle pdf_file, |
eric@59 | 60 | double width, |
eric@59 | 61 | double height); |
eric@59 | 62 | |
eric@59 | 63 | void pdf_close_page (pdf_page_handle pdf_page); |
eric@59 | 64 | |
eric@59 | 65 | |
eric@119 | 66 | void pdf_write_text (pdf_page_handle pdf_page); |
eric@119 | 67 | |
eric@119 | 68 | |
eric@59 | 69 | /* The length of the data must be Rows * rowbytes. |
eric@59 | 70 | Note that rowbytes must be at least (Columns+7)/8, but may be arbitrarily |
eric@59 | 71 | large. */ |
eric@59 | 72 | void pdf_write_g4_fax_image (pdf_page_handle pdf_page, |
eric@64 | 73 | double x, |
eric@64 | 74 | double y, |
eric@64 | 75 | double width, |
eric@64 | 76 | double height, |
eric@62 | 77 | Bitmap *bitmap, |
eric@66 | 78 | bool ImageMask, |
eric@66 | 79 | double r, /* RGB fill color, only for ImageMask */ |
eric@66 | 80 | double g, |
eric@66 | 81 | double b, |
eric@66 | 82 | bool BlackIs1); /* boolean, typ. false */ |
eric@59 | 83 | |
eric@59 | 84 | |
eric@107 | 85 | void pdf_write_jpeg_image (pdf_page_handle pdf_page, |
eric@107 | 86 | double x, |
eric@107 | 87 | double y, |
eric@107 | 88 | double width, |
eric@107 | 89 | double height, |
eric@147 | 90 | bool color, |
eric@147 | 91 | uint32_t width_samples, |
eric@147 | 92 | uint32_t height_samples, |
eric@107 | 93 | FILE *f); |
eric@107 | 94 | |
eric@107 | 95 | |
eric@59 | 96 | void pdf_set_page_number (pdf_page_handle pdf_page, char *page_number); |
eric@59 | 97 | |
eric@74 | 98 | /* Create a new bookmark, under the specified parent, or at the top |
eric@74 | 99 | level if parent is NULL. */ |
eric@74 | 100 | pdf_bookmark_handle pdf_new_bookmark (pdf_bookmark_handle parent, |
eric@74 | 101 | char *title, |
eric@74 | 102 | bool open, |
eric@74 | 103 | pdf_page_handle pdf_page); |
eric@131 | 104 | |
eric@131 | 105 | |
eric@131 | 106 | void pdf_new_page_label (pdf_file_handle pdf_file, |
eric@131 | 107 | int page_index, |
eric@131 | 108 | int base, |
eric@131 | 109 | int count, |
eric@131 | 110 | char style, |
eric@131 | 111 | char *prefix); |