Thu, 20 Feb 2003 12:44:17 +0000
my own PDF routines to replace Panda.
Makefile | file | annotate | diff | revisions | |
bitblt_g4.c | file | annotate | diff | revisions | |
pdf.c | file | annotate | diff | revisions | |
pdf.h | file | annotate | diff | revisions | |
pdf_g4.c | file | annotate | diff | revisions | |
pdf_prim.c | file | annotate | diff | revisions | |
pdf_prim.h | file | annotate | diff | revisions | |
pdf_private.h | file | annotate | diff | revisions | |
pdf_util.c | file | annotate | diff | revisions | |
pdf_util.h | file | annotate | diff | revisions | |
t2p.c | file | annotate | diff | revisions | |
tumble.c | file | annotate | diff | revisions |
1.1 --- a/Makefile Thu Feb 20 12:21:10 2003 +0000 1.2 +++ b/Makefile Thu Feb 20 12:44:17 2003 +0000 1.3 @@ -1,6 +1,6 @@ 1.4 # t2p: build a PDF file out of one or more TIFF Class F Group 4 files 1.5 # Makefile 1.6 -# $Id: Makefile,v 1.13 2003/02/20 04:21:10 eric Exp $ 1.7 +# $Id: Makefile,v 1.14 2003/02/20 04:44:17 eric Exp $ 1.8 # Copyright 2001 Eric Smith <eric@brouhaha.com> 1.9 # 1.10 # This program is free software; you can redistribute it and/or modify 1.11 @@ -19,13 +19,13 @@ 1.12 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 1.13 1.14 1.15 -CFLAGS = -Wall -g -I/usr/local/include/panda 1.16 +CFLAGS = -Wall -g 1.17 1.18 # Panda is not all that common, so we'll statically link it in order to 1.19 # make the t2p binary more portable. 1.20 1.21 LDFLAGS = -g 1.22 -LDLIBS = -Wl,-static -lpanda -Wl,-dy -lpng -ltiff -ljpeg -lz -lm -L/usr/local/lib/panda 1.23 +LDLIBS = -ltiff -lm 1.24 1.25 YACC = bison 1.26 YFLAGS = -d -v 1.27 @@ -61,7 +61,7 @@ 1.28 1.29 1.30 t2p: t2p.o scanner.o semantics.o parser.tab.o bitblt.o \ 1.31 - pdf_util.o pdf_prim.o pdf_g4.o 1.32 + pdf.o pdf_util.o pdf_prim.o pdf_g4.o 1.33 1.34 bitblt_tables.h: bitblt_table_gen 1.35 ./bitblt_table_gen >bitblt_tables.h
2.1 --- a/bitblt_g4.c Thu Feb 20 12:21:10 2003 +0000 2.2 +++ b/bitblt_g4.c Thu Feb 20 12:44:17 2003 +0000 2.3 @@ -1,7 +1,36 @@ 2.4 +/* 2.5 + * t2p: Create a PDF file from the contents of one or more TIFF 2.6 + * bilevel image files. The images in the resulting PDF file 2.7 + * will be compressed using ITU-T T.6 (G4) fax encoding. 2.8 + * 2.9 + * PDF routines 2.10 + * $Id: bitblt_g4.c,v 1.3 2003/02/20 04:44:17 eric Exp $ 2.11 + * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 2.12 + * 2.13 + * This program is free software; you can redistribute it and/or modify 2.14 + * it under the terms of the GNU General Public License version 2 as 2.15 + * published by the Free Software Foundation. Note that permission is 2.16 + * not granted to redistribute this program under the terms of any 2.17 + * other version of the General Public License. 2.18 + * 2.19 + * This program is distributed in the hope that it will be useful, 2.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 2.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2.22 + * GNU General Public License for more details. 2.23 + * 2.24 + * You should have received a copy of the GNU General Public License 2.25 + * along with this program; if not, write to the Free Software 2.26 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 2.27 + */ 2.28 + 2.29 + 2.30 +#include <stdbool.h> 2.31 +#include <stdint.h> 2.32 #include <stdio.h> 2.33 #include <string.h> 2.34 2.35 2.36 +#include "bitblt.h" 2.37 #include "pdf.h" 2.38 #include "pdf_util.h" 2.39 #include "pdf_prim.h" 2.40 @@ -12,10 +41,8 @@ 2.41 { 2.42 unsigned long Columns; 2.43 unsigned long Rows; 2.44 - unsigned long rowbytes; 2.45 int BlackIs1; 2.46 - unsigned char *data; 2.47 - unsigned long len; 2.48 + Bitmap *bitmap; 2.49 char XObject_name [4]; 2.50 }; 2.51 2.52 @@ -69,23 +96,24 @@ 2.53 { 2.54 struct pdf_g4_image *image = app_data; 2.55 2.56 -#if 1 2.57 +#if 0 2.58 pdf_stream_write_data (pdf_file, stream, image->data, image->len); 2.59 #else 2.60 unsigned long row = 0; 2.61 - unsigned char *ref; 2.62 - unsigned char *raw; 2.63 + word_type *ref; 2.64 + word_type *raw; 2.65 2.66 ref = NULL; 2.67 - raw = image->data; 2.68 + raw = image->bitmap->bits; 2.69 2.70 while (row < image->Rows) 2.71 { 2.72 - pdf_stream_write_data (pdf_file, stream, raw, image->rowbytes); 2.73 + pdf_stream_write_data (pdf_file, stream, raw, 2.74 + image->bitmap->row_words * sizeof (word_type)); 2.75 2.76 row++; 2.77 ref = raw; 2.78 - raw += image->rowbytes; 2.79 + raw += image->bitmap->row_words; 2.80 } 2.81 /* $$$ generate and write EOFB code */ 2.82 /* $$$ flush any remaining buffered bits */ 2.83 @@ -94,13 +122,9 @@ 2.84 2.85 2.86 void pdf_write_g4_fax_image (pdf_page_handle pdf_page, 2.87 - unsigned long Columns, 2.88 - unsigned long Rows, 2.89 - unsigned long rowbytes, 2.90 + Bitmap *bitmap, 2.91 int ImageMask, 2.92 - int BlackIs1, /* boolean, typ. false */ 2.93 - unsigned char *data, 2.94 - unsigned long len) 2.95 + int BlackIs1) /* boolean, typ. false */ 2.96 { 2.97 struct pdf_g4_image *image; 2.98 2.99 @@ -112,12 +136,10 @@ 2.100 2.101 image = pdf_calloc (sizeof (struct pdf_g4_image)); 2.102 2.103 - image->Columns = Columns; 2.104 - image->Rows = Rows; 2.105 - image->rowbytes = rowbytes; 2.106 + image->bitmap = bitmap; 2.107 + image->Columns = bitmap->rect.max.x - bitmap->rect.min.x; 2.108 + image->Rows = bitmap->rect.max.y - bitmap->rect.min.y; 2.109 image->BlackIs1 = BlackIs1; 2.110 - image->data = data; 2.111 - image->len = len; 2.112 2.113 stream_dict = pdf_new_obj (PT_DICTIONARY); 2.114 2.115 @@ -133,8 +155,8 @@ 2.116 pdf_set_dict_entry (stream_dict, "Type", pdf_new_name ("XObject")); 2.117 pdf_set_dict_entry (stream_dict, "Subtype", pdf_new_name ("Image")); 2.118 pdf_set_dict_entry (stream_dict, "Name", pdf_new_name (& image->XObject_name [0])); 2.119 - pdf_set_dict_entry (stream_dict, "Width", pdf_new_integer (Columns)); 2.120 - pdf_set_dict_entry (stream_dict, "Height", pdf_new_integer (Rows)); 2.121 + pdf_set_dict_entry (stream_dict, "Width", pdf_new_integer (image->Columns)); 2.122 + pdf_set_dict_entry (stream_dict, "Height", pdf_new_integer (image->Rows)); 2.123 pdf_set_dict_entry (stream_dict, "BitsPerComponent", pdf_new_integer (1)); 2.124 if (ImageMask) 2.125 pdf_set_dict_entry (stream_dict, "ImageMask", pdf_new_bool (ImageMask)); 2.126 @@ -149,11 +171,11 @@ 2.127 2.128 pdf_set_dict_entry (decode_parms, 2.129 "Columns", 2.130 - pdf_new_integer (Columns)); 2.131 + pdf_new_integer (image->Columns)); 2.132 2.133 pdf_set_dict_entry (decode_parms, 2.134 "Rows", 2.135 - pdf_new_integer (Rows)); 2.136 + pdf_new_integer (image->Rows)); 2.137 2.138 if (BlackIs1) 2.139 pdf_set_dict_entry (decode_parms,
3.1 --- a/pdf.c Thu Feb 20 12:21:10 2003 +0000 3.2 +++ b/pdf.c Thu Feb 20 12:44:17 2003 +0000 3.3 @@ -1,7 +1,36 @@ 3.4 +/* 3.5 + * t2p: Create a PDF file from the contents of one or more TIFF 3.6 + * bilevel image files. The images in the resulting PDF file 3.7 + * will be compressed using ITU-T T.6 (G4) fax encoding. 3.8 + * 3.9 + * PDF routines 3.10 + * $Id: pdf.c,v 1.3 2003/02/20 04:44:17 eric Exp $ 3.11 + * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 3.12 + * 3.13 + * This program is free software; you can redistribute it and/or modify 3.14 + * it under the terms of the GNU General Public License version 2 as 3.15 + * published by the Free Software Foundation. Note that permission is 3.16 + * not granted to redistribute this program under the terms of any 3.17 + * other version of the General Public License. 3.18 + * 3.19 + * This program is distributed in the hope that it will be useful, 3.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 3.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 3.22 + * GNU General Public License for more details. 3.23 + * 3.24 + * You should have received a copy of the GNU General Public License 3.25 + * along with this program; if not, write to the Free Software 3.26 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 3.27 + */ 3.28 + 3.29 + 3.30 +#include <stdbool.h> 3.31 +#include <stdint.h> 3.32 #include <stdio.h> 3.33 #include <stdlib.h> 3.34 3.35 3.36 +#include "bitblt.h" 3.37 #include "pdf.h" 3.38 #include "pdf_util.h" 3.39 #include "pdf_prim.h"
4.1 --- a/pdf.h Thu Feb 20 12:21:10 2003 +0000 4.2 +++ b/pdf.h Thu Feb 20 12:44:17 2003 +0000 4.3 @@ -1,3 +1,29 @@ 4.4 +/* 4.5 + * t2p: Create a PDF file from the contents of one or more TIFF 4.6 + * bilevel image files. The images in the resulting PDF file 4.7 + * will be compressed using ITU-T T.6 (G4) fax encoding. 4.8 + * 4.9 + * PDF routines 4.10 + * $Id: pdf.h,v 1.2 2003/02/20 04:44:17 eric Exp $ 4.11 + * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 4.12 + * 4.13 + * This program is free software; you can redistribute it and/or modify 4.14 + * it under the terms of the GNU General Public License version 2 as 4.15 + * published by the Free Software Foundation. Note that permission is 4.16 + * not granted to redistribute this program under the terms of any 4.17 + * other version of the General Public License. 4.18 + * 4.19 + * This program is distributed in the hope that it will be useful, 4.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 4.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 4.22 + * GNU General Public License for more details. 4.23 + * 4.24 + * You should have received a copy of the GNU General Public License 4.25 + * along with this program; if not, write to the Free Software 4.26 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 4.27 + */ 4.28 + 4.29 + 4.30 typedef struct pdf_file *pdf_file_handle; 4.31 4.32 typedef struct pdf_page *pdf_page_handle; 4.33 @@ -28,13 +54,9 @@ 4.34 Note that rowbytes must be at least (Columns+7)/8, but may be arbitrarily 4.35 large. */ 4.36 void pdf_write_g4_fax_image (pdf_page_handle pdf_page, 4.37 - unsigned long Columns, 4.38 - unsigned long Rows, 4.39 - unsigned long rowbytes, 4.40 + Bitmap *bitmap, 4.41 int ImageMask, 4.42 - int BlackIs1, /* boolean, typ. false */ 4.43 - unsigned char *data, 4.44 - unsigned long len); 4.45 + int BlackIs1); /* boolean, typ. false */ 4.46 4.47 4.48 void pdf_set_page_number (pdf_page_handle pdf_page, char *page_number);
5.1 --- a/pdf_g4.c Thu Feb 20 12:21:10 2003 +0000 5.2 +++ b/pdf_g4.c Thu Feb 20 12:44:17 2003 +0000 5.3 @@ -1,7 +1,36 @@ 5.4 +/* 5.5 + * t2p: Create a PDF file from the contents of one or more TIFF 5.6 + * bilevel image files. The images in the resulting PDF file 5.7 + * will be compressed using ITU-T T.6 (G4) fax encoding. 5.8 + * 5.9 + * PDF routines 5.10 + * $Id: pdf_g4.c,v 1.3 2003/02/20 04:44:17 eric Exp $ 5.11 + * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 5.12 + * 5.13 + * This program is free software; you can redistribute it and/or modify 5.14 + * it under the terms of the GNU General Public License version 2 as 5.15 + * published by the Free Software Foundation. Note that permission is 5.16 + * not granted to redistribute this program under the terms of any 5.17 + * other version of the General Public License. 5.18 + * 5.19 + * This program is distributed in the hope that it will be useful, 5.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 5.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 5.22 + * GNU General Public License for more details. 5.23 + * 5.24 + * You should have received a copy of the GNU General Public License 5.25 + * along with this program; if not, write to the Free Software 5.26 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 5.27 + */ 5.28 + 5.29 + 5.30 +#include <stdbool.h> 5.31 +#include <stdint.h> 5.32 #include <stdio.h> 5.33 #include <string.h> 5.34 5.35 5.36 +#include "bitblt.h" 5.37 #include "pdf.h" 5.38 #include "pdf_util.h" 5.39 #include "pdf_prim.h" 5.40 @@ -12,10 +41,8 @@ 5.41 { 5.42 unsigned long Columns; 5.43 unsigned long Rows; 5.44 - unsigned long rowbytes; 5.45 int BlackIs1; 5.46 - unsigned char *data; 5.47 - unsigned long len; 5.48 + Bitmap *bitmap; 5.49 char XObject_name [4]; 5.50 }; 5.51 5.52 @@ -69,23 +96,24 @@ 5.53 { 5.54 struct pdf_g4_image *image = app_data; 5.55 5.56 -#if 1 5.57 +#if 0 5.58 pdf_stream_write_data (pdf_file, stream, image->data, image->len); 5.59 #else 5.60 unsigned long row = 0; 5.61 - unsigned char *ref; 5.62 - unsigned char *raw; 5.63 + word_type *ref; 5.64 + word_type *raw; 5.65 5.66 ref = NULL; 5.67 - raw = image->data; 5.68 + raw = image->bitmap->bits; 5.69 5.70 while (row < image->Rows) 5.71 { 5.72 - pdf_stream_write_data (pdf_file, stream, raw, image->rowbytes); 5.73 + pdf_stream_write_data (pdf_file, stream, raw, 5.74 + image->bitmap->row_words * sizeof (word_type)); 5.75 5.76 row++; 5.77 ref = raw; 5.78 - raw += image->rowbytes; 5.79 + raw += image->bitmap->row_words; 5.80 } 5.81 /* $$$ generate and write EOFB code */ 5.82 /* $$$ flush any remaining buffered bits */ 5.83 @@ -94,13 +122,9 @@ 5.84 5.85 5.86 void pdf_write_g4_fax_image (pdf_page_handle pdf_page, 5.87 - unsigned long Columns, 5.88 - unsigned long Rows, 5.89 - unsigned long rowbytes, 5.90 + Bitmap *bitmap, 5.91 int ImageMask, 5.92 - int BlackIs1, /* boolean, typ. false */ 5.93 - unsigned char *data, 5.94 - unsigned long len) 5.95 + int BlackIs1) /* boolean, typ. false */ 5.96 { 5.97 struct pdf_g4_image *image; 5.98 5.99 @@ -112,12 +136,10 @@ 5.100 5.101 image = pdf_calloc (sizeof (struct pdf_g4_image)); 5.102 5.103 - image->Columns = Columns; 5.104 - image->Rows = Rows; 5.105 - image->rowbytes = rowbytes; 5.106 + image->bitmap = bitmap; 5.107 + image->Columns = bitmap->rect.max.x - bitmap->rect.min.x; 5.108 + image->Rows = bitmap->rect.max.y - bitmap->rect.min.y; 5.109 image->BlackIs1 = BlackIs1; 5.110 - image->data = data; 5.111 - image->len = len; 5.112 5.113 stream_dict = pdf_new_obj (PT_DICTIONARY); 5.114 5.115 @@ -133,8 +155,8 @@ 5.116 pdf_set_dict_entry (stream_dict, "Type", pdf_new_name ("XObject")); 5.117 pdf_set_dict_entry (stream_dict, "Subtype", pdf_new_name ("Image")); 5.118 pdf_set_dict_entry (stream_dict, "Name", pdf_new_name (& image->XObject_name [0])); 5.119 - pdf_set_dict_entry (stream_dict, "Width", pdf_new_integer (Columns)); 5.120 - pdf_set_dict_entry (stream_dict, "Height", pdf_new_integer (Rows)); 5.121 + pdf_set_dict_entry (stream_dict, "Width", pdf_new_integer (image->Columns)); 5.122 + pdf_set_dict_entry (stream_dict, "Height", pdf_new_integer (image->Rows)); 5.123 pdf_set_dict_entry (stream_dict, "BitsPerComponent", pdf_new_integer (1)); 5.124 if (ImageMask) 5.125 pdf_set_dict_entry (stream_dict, "ImageMask", pdf_new_bool (ImageMask)); 5.126 @@ -149,11 +171,11 @@ 5.127 5.128 pdf_set_dict_entry (decode_parms, 5.129 "Columns", 5.130 - pdf_new_integer (Columns)); 5.131 + pdf_new_integer (image->Columns)); 5.132 5.133 pdf_set_dict_entry (decode_parms, 5.134 "Rows", 5.135 - pdf_new_integer (Rows)); 5.136 + pdf_new_integer (image->Rows)); 5.137 5.138 if (BlackIs1) 5.139 pdf_set_dict_entry (decode_parms,
6.1 --- a/pdf_prim.c Thu Feb 20 12:21:10 2003 +0000 6.2 +++ b/pdf_prim.c Thu Feb 20 12:44:17 2003 +0000 6.3 @@ -1,7 +1,36 @@ 6.4 +/* 6.5 + * t2p: Create a PDF file from the contents of one or more TIFF 6.6 + * bilevel image files. The images in the resulting PDF file 6.7 + * will be compressed using ITU-T T.6 (G4) fax encoding. 6.8 + * 6.9 + * PDF routines 6.10 + * $Id: pdf_prim.c,v 1.3 2003/02/20 04:44:17 eric Exp $ 6.11 + * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 6.12 + * 6.13 + * This program is free software; you can redistribute it and/or modify 6.14 + * it under the terms of the GNU General Public License version 2 as 6.15 + * published by the Free Software Foundation. Note that permission is 6.16 + * not granted to redistribute this program under the terms of any 6.17 + * other version of the General Public License. 6.18 + * 6.19 + * This program is distributed in the hope that it will be useful, 6.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 6.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 6.22 + * GNU General Public License for more details. 6.23 + * 6.24 + * You should have received a copy of the GNU General Public License 6.25 + * along with this program; if not, write to the Free Software 6.26 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 6.27 + */ 6.28 + 6.29 + 6.30 +#include <stdbool.h> 6.31 +#include <stdint.h> 6.32 #include <stdio.h> 6.33 #include <stdlib.h> 6.34 #include <string.h> 6.35 6.36 +#include "bitblt.h" 6.37 #include "pdf.h" 6.38 #include "pdf_util.h" 6.39 #include "pdf_prim.h" 6.40 @@ -60,7 +89,7 @@ 6.41 unsigned long ref_count; 6.42 pdf_obj_type type; 6.43 union { 6.44 - int bool; 6.45 + bool boolean; 6.46 char *name; 6.47 char *string; 6.48 unsigned long integer; 6.49 @@ -170,10 +199,10 @@ 6.50 } 6.51 6.52 6.53 -struct pdf_obj *pdf_new_bool (int bool) 6.54 +struct pdf_obj *pdf_new_bool (bool val) 6.55 { 6.56 struct pdf_obj *obj = pdf_new_obj (PT_BOOL); 6.57 - obj->val.bool = bool; 6.58 + obj->val.boolean = val; 6.59 return (obj); 6.60 } 6.61 6.62 @@ -450,7 +479,7 @@ 6.63 fprintf (pdf_file->f, "null "); 6.64 break; 6.65 case PT_BOOL: 6.66 - if (obj->val.bool) 6.67 + if (obj->val.boolean) 6.68 fprintf (pdf_file->f, "true "); 6.69 else 6.70 fprintf (pdf_file->f, "false ");
7.1 --- a/pdf_prim.h Thu Feb 20 12:21:10 2003 +0000 7.2 +++ b/pdf_prim.h Thu Feb 20 12:44:17 2003 +0000 7.3 @@ -1,3 +1,29 @@ 7.4 +/* 7.5 + * t2p: Create a PDF file from the contents of one or more TIFF 7.6 + * bilevel image files. The images in the resulting PDF file 7.7 + * will be compressed using ITU-T T.6 (G4) fax encoding. 7.8 + * 7.9 + * PDF routines 7.10 + * $Id: pdf_prim.h,v 1.2 2003/02/20 04:44:17 eric Exp $ 7.11 + * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 7.12 + * 7.13 + * This program is free software; you can redistribute it and/or modify 7.14 + * it under the terms of the GNU General Public License version 2 as 7.15 + * published by the Free Software Foundation. Note that permission is 7.16 + * not granted to redistribute this program under the terms of any 7.17 + * other version of the General Public License. 7.18 + * 7.19 + * This program is distributed in the hope that it will be useful, 7.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 7.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 7.22 + * GNU General Public License for more details. 7.23 + * 7.24 + * You should have received a copy of the GNU General Public License 7.25 + * along with this program; if not, write to the Free Software 7.26 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 7.27 + */ 7.28 + 7.29 + 7.30 typedef enum 7.31 { 7.32 PT_BAD, 7.33 @@ -36,7 +62,7 @@ 7.34 /* Create a new object that will NOT be used indirectly */ 7.35 struct pdf_obj *pdf_new_obj (pdf_obj_type type); 7.36 7.37 -struct pdf_obj *pdf_new_bool (int bool); 7.38 +struct pdf_obj *pdf_new_bool (bool val); 7.39 7.40 struct pdf_obj *pdf_new_name (char *name); 7.41
8.1 --- a/pdf_private.h Thu Feb 20 12:21:10 2003 +0000 8.2 +++ b/pdf_private.h Thu Feb 20 12:44:17 2003 +0000 8.3 @@ -1,3 +1,29 @@ 8.4 +/* 8.5 + * t2p: Create a PDF file from the contents of one or more TIFF 8.6 + * bilevel image files. The images in the resulting PDF file 8.7 + * will be compressed using ITU-T T.6 (G4) fax encoding. 8.8 + * 8.9 + * PDF routines 8.10 + * $Id: pdf_private.h,v 1.2 2003/02/20 04:44:17 eric Exp $ 8.11 + * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 8.12 + * 8.13 + * This program is free software; you can redistribute it and/or modify 8.14 + * it under the terms of the GNU General Public License version 2 as 8.15 + * published by the Free Software Foundation. Note that permission is 8.16 + * not granted to redistribute this program under the terms of any 8.17 + * other version of the General Public License. 8.18 + * 8.19 + * This program is distributed in the hope that it will be useful, 8.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 8.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 8.22 + * GNU General Public License for more details. 8.23 + * 8.24 + * You should have received a copy of the GNU General Public License 8.25 + * along with this program; if not, write to the Free Software 8.26 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 8.27 + */ 8.28 + 8.29 + 8.30 struct pdf_page 8.31 { 8.32 pdf_file_handle pdf_file;
9.1 --- a/pdf_util.c Thu Feb 20 12:21:10 2003 +0000 9.2 +++ b/pdf_util.c Thu Feb 20 12:44:17 2003 +0000 9.3 @@ -1,8 +1,37 @@ 9.4 +/* 9.5 + * t2p: Create a PDF file from the contents of one or more TIFF 9.6 + * bilevel image files. The images in the resulting PDF file 9.7 + * will be compressed using ITU-T T.6 (G4) fax encoding. 9.8 + * 9.9 + * PDF routines 9.10 + * $Id: pdf_util.c,v 1.3 2003/02/20 04:44:17 eric Exp $ 9.11 + * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 9.12 + * 9.13 + * This program is free software; you can redistribute it and/or modify 9.14 + * it under the terms of the GNU General Public License version 2 as 9.15 + * published by the Free Software Foundation. Note that permission is 9.16 + * not granted to redistribute this program under the terms of any 9.17 + * other version of the General Public License. 9.18 + * 9.19 + * This program is distributed in the hope that it will be useful, 9.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 9.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9.22 + * GNU General Public License for more details. 9.23 + * 9.24 + * You should have received a copy of the GNU General Public License 9.25 + * along with this program; if not, write to the Free Software 9.26 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 9.27 + */ 9.28 + 9.29 + 9.30 #include <stdarg.h> 9.31 +#include <stdbool.h> 9.32 +#include <stdint.h> 9.33 #include <stdio.h> 9.34 #include <stdlib.h> 9.35 #include <string.h> 9.36 9.37 +#include "bitblt.h" 9.38 #include "pdf.h" 9.39 #include "pdf_util.h" 9.40
10.1 --- a/pdf_util.h Thu Feb 20 12:21:10 2003 +0000 10.2 +++ b/pdf_util.h Thu Feb 20 12:44:17 2003 +0000 10.3 @@ -1,3 +1,29 @@ 10.4 +/* 10.5 + * t2p: Create a PDF file from the contents of one or more TIFF 10.6 + * bilevel image files. The images in the resulting PDF file 10.7 + * will be compressed using ITU-T T.6 (G4) fax encoding. 10.8 + * 10.9 + * PDF routines 10.10 + * $Id: pdf_util.h,v 1.2 2003/02/20 04:44:17 eric Exp $ 10.11 + * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 10.12 + * 10.13 + * This program is free software; you can redistribute it and/or modify 10.14 + * it under the terms of the GNU General Public License version 2 as 10.15 + * published by the Free Software Foundation. Note that permission is 10.16 + * not granted to redistribute this program under the terms of any 10.17 + * other version of the General Public License. 10.18 + * 10.19 + * This program is distributed in the hope that it will be useful, 10.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 10.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10.22 + * GNU General Public License for more details. 10.23 + * 10.24 + * You should have received a copy of the GNU General Public License 10.25 + * along with this program; if not, write to the Free Software 10.26 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 10.27 + */ 10.28 + 10.29 + 10.30 void pdf_fatal (char *fmt, ...); 10.31 10.32 void *pdf_calloc (long int size);
11.1 --- a/t2p.c Thu Feb 20 12:21:10 2003 +0000 11.2 +++ b/t2p.c Thu Feb 20 12:44:17 2003 +0000 11.3 @@ -4,7 +4,7 @@ 11.4 * will be compressed using ITU-T T.6 (G4) fax encoding. 11.5 * 11.6 * Main program 11.7 - * $Id: t2p.c,v 1.21 2003/01/21 10:39:55 eric Exp $ 11.8 + * $Id: t2p.c,v 1.22 2003/02/20 04:44:17 eric Exp $ 11.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 11.10 * 11.11 * This program is free software; you can redistribute it and/or modify 11.12 @@ -20,7 +20,8 @@ 11.13 * 11.14 * You should have received a copy of the GNU General Public License 11.15 * along with this program; if not, write to the Free Software 11.16 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA */ 11.17 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 11.18 + */ 11.19 11.20 11.21 #include <stdarg.h> 11.22 @@ -28,18 +29,17 @@ 11.23 #include <stdint.h> 11.24 #include <stdio.h> 11.25 #include <stdlib.h> 11.26 +#include <string.h> 11.27 #include <unistd.h> 11.28 11.29 #include <tiffio.h> 11.30 #define TIFF_REVERSE_BITS 11.31 11.32 -#include <panda/functions.h> 11.33 -#include <panda/constants.h> 11.34 - 11.35 #include "bitblt.h" 11.36 #include "semantics.h" 11.37 #include "parser.tab.h" 11.38 #include "t2p.h" 11.39 +#include "pdf.h" 11.40 11.41 11.42 #define MAX_INPUT_FILES 5000 11.43 @@ -55,7 +55,7 @@ 11.44 { 11.45 struct output_file_t *next; 11.46 char *name; 11.47 - panda_pdf *pdf; 11.48 + pdf_file_handle pdf; 11.49 } output_file_t; 11.50 11.51 11.52 @@ -66,7 +66,6 @@ 11.53 TIFF *in; 11.54 output_file_t *output_files; 11.55 output_file_t *out; 11.56 -/* panda_pdf *out; */ 11.57 11.58 11.59 char *progname; 11.60 @@ -87,6 +86,10 @@ 11.61 fprintf (stderr, " %s [options] <input.tif>... -o <output.pdf>\n", progname); 11.62 fprintf (stderr, "options:\n"); 11.63 fprintf (stderr, " -v verbose\n"); 11.64 + fprintf (stderr, " -b fmt create bookmarks\n"); 11.65 + fprintf (stderr, "bookmark format:\n"); 11.66 + fprintf (stderr, " %%F file name\n"); 11.67 + fprintf (stderr, " %%p page number\n"); 11.68 } 11.69 11.70 11.71 @@ -158,7 +161,7 @@ 11.72 for (o = output_files; o; o = n) 11.73 { 11.74 n = o->next; 11.75 - panda_close (o->pdf); 11.76 + pdf_close (o->pdf); 11.77 free (o->name); 11.78 free (o); 11.79 } 11.80 @@ -195,7 +198,7 @@ 11.81 return (0); 11.82 } 11.83 11.84 - o->pdf = panda_open (name, "w"); 11.85 + o->pdf = pdf_create (name); 11.86 if (! o->pdf) 11.87 { 11.88 fprintf (stderr, "can't open output file '%s'\n", name); 11.89 @@ -205,15 +208,15 @@ 11.90 } 11.91 11.92 if (attributes->author) 11.93 - panda_setauthor (o->pdf, attributes->author); 11.94 + pdf_set_author (o->pdf, attributes->author); 11.95 if (attributes->creator) 11.96 - panda_setcreator (o->pdf, attributes->creator); 11.97 + pdf_set_creator (o->pdf, attributes->creator); 11.98 if (attributes->title) 11.99 - panda_settitle (o->pdf, attributes->title); 11.100 + pdf_set_title (o->pdf, attributes->title); 11.101 if (attributes->subject) 11.102 - panda_setsubject (o->pdf, attributes->subject); 11.103 + pdf_set_subject (o->pdf, attributes->subject); 11.104 if (attributes->keywords) 11.105 - panda_setkeywords (o->pdf, attributes->keywords); 11.106 + pdf_set_keywords (o->pdf, attributes->keywords); 11.107 11.108 /* prepend new output file onto list */ 11.109 o->next = output_files; 11.110 @@ -304,23 +307,15 @@ 11.111 float x_resolution, y_resolution; 11.112 float dest_x_resolution, dest_y_resolution; 11.113 11.114 - int width_points, height_points; /* really 1/72 inch units rather than 11.115 - points */ 11.116 + double width_points, height_points; /* really 1/72 inch units rather than 11.117 + points */ 11.118 11.119 Rect rect; 11.120 Bitmap *bitmap; 11.121 11.122 int row; 11.123 11.124 - panda_page *page; 11.125 - 11.126 - int tiff_temp_fd; 11.127 - char tiff_temp_fn [] = "/var/tmp/t2p-XXXXXX\0"; 11.128 - TIFF *tiff_temp; 11.129 - 11.130 - char pagesize [26]; /* Needs to hold two ints of four characters (0..3420), 11.131 - two zeros, three spaces, two brackets, and a NULL. 11.132 - Added an extra ten characters just in case. */ 11.133 + pdf_page_handle page; 11.134 11.135 if (! TIFFSetDirectory (in, image - 1)) 11.136 { 11.137 @@ -406,7 +401,7 @@ 11.138 dest_image_length = image_width; 11.139 dest_x_resolution = y_resolution; 11.140 dest_y_resolution = x_resolution; 11.141 - SWAP (int, width_points, height_points); 11.142 + SWAP (double, width_points, height_points); /* $$$ not yet set!!! */ 11.143 } 11.144 else 11.145 { 11.146 @@ -453,80 +448,32 @@ 11.147 rotate_bitmap (bitmap, 11.148 input_attributes); 11.149 11.150 - tiff_temp_fd = mkstemp (tiff_temp_fn); 11.151 - if (tiff_temp_fd < 0) 11.152 - { 11.153 - fprintf (stderr, "can't create temporary TIFF file\n"); 11.154 - goto fail; 11.155 - } 11.156 - 11.157 - tiff_temp = TIFFFdOpen (tiff_temp_fd, tiff_temp_fn, "w"); 11.158 - if (! out) 11.159 - { 11.160 - fprintf (stderr, "can't open temporary TIFF file '%s'\n", tiff_temp_fn); 11.161 - goto fail; 11.162 - } 11.163 - 11.164 - TIFFSetField (tiff_temp, TIFFTAG_IMAGELENGTH, rect_height (& bitmap->rect)); 11.165 - TIFFSetField (tiff_temp, TIFFTAG_IMAGEWIDTH, rect_width (& bitmap->rect)); 11.166 - TIFFSetField (tiff_temp, TIFFTAG_PLANARCONFIG, planar_config); 11.167 - 11.168 - TIFFSetField (tiff_temp, TIFFTAG_ROWSPERSTRIP, rect_height (& bitmap->rect)); 11.169 - 11.170 - TIFFSetField (tiff_temp, TIFFTAG_RESOLUTIONUNIT, resolution_unit); 11.171 - TIFFSetField (tiff_temp, TIFFTAG_XRESOLUTION, dest_x_resolution); 11.172 - TIFFSetField (tiff_temp, TIFFTAG_YRESOLUTION, dest_y_resolution); 11.173 - 11.174 - TIFFSetField (tiff_temp, TIFFTAG_SAMPLESPERPIXEL, samples_per_pixel); 11.175 - TIFFSetField (tiff_temp, TIFFTAG_BITSPERSAMPLE, bits_per_sample); 11.176 - TIFFSetField (tiff_temp, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4); 11.177 - TIFFSetField (tiff_temp, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); 11.178 - 11.179 #ifdef TIFF_REVERSE_BITS 11.180 reverse_bits ((uint8_t *) bitmap->bits, 11.181 image_length * bitmap->row_words * sizeof (word_type)); 11.182 #endif /* TIFF_REVERSE_BITS */ 11.183 11.184 - for (row = 0; row < rect_height (& bitmap->rect); row++) 11.185 - if (1 != TIFFWriteScanline (tiff_temp, 11.186 - bitmap->bits + row * bitmap->row_words, 11.187 - row, 11.188 - 0)) 11.189 - { 11.190 - fprintf (stderr, "can't write TIFF scanline\n"); 11.191 - goto fail; 11.192 - } 11.193 - 11.194 - TIFFClose (tiff_temp); 11.195 - 11.196 width_points = (rect_width (& bitmap->rect) / dest_x_resolution) * POINTS_PER_INCH; 11.197 height_points = (rect_height (& bitmap->rect) / dest_y_resolution) * POINTS_PER_INCH; 11.198 11.199 - free_bitmap (bitmap); 11.200 - 11.201 if ((height_points > PAGE_MAX_POINTS) || (width_points > PAGE_MAX_POINTS)) 11.202 { 11.203 fprintf (stdout, "image too large (max %d inches on a side\n", PAGE_MAX_INCHES); 11.204 goto fail; 11.205 } 11.206 11.207 - sprintf (pagesize, "[0 0 %d %d]", width_points, height_points); 11.208 + page = pdf_new_page (out->pdf, width_points, height_points); 11.209 11.210 - page = panda_newpage (out->pdf, pagesize); 11.211 - panda_imagebox (out->pdf, 11.212 - page, 11.213 - 0, /* top */ 11.214 - 0, /* left */ 11.215 - height_points, /* bottom */ 11.216 - width_points, /* right */ 11.217 - tiff_temp_fn, 11.218 - panda_image_tiff); 11.219 + pdf_write_g4_fax_image (page, 11.220 + bitmap, 11.221 + 0, /* ImageMask */ 11.222 + 0); /* BlackIs1 */ 11.223 + 11.224 + free_bitmap (bitmap); 11.225 11.226 result = 1; 11.227 11.228 fail: 11.229 - if (tiff_temp_fd) 11.230 - unlink (tiff_temp_fn); 11.231 return (result); 11.232 } 11.233 11.234 @@ -548,6 +495,7 @@ 11.235 fatal (3, "error opening input file \"%s\"\n", in_fn [i]); 11.236 for (ip = 1;; ip++) 11.237 { 11.238 + fprintf (stderr, "processing page %d of file \"%s\"\r", ip, in_fn [i]); 11.239 if (! process_page (ip, input_attributes, NULL)) 11.240 fatal (3, "error processing page %d of input file \"%s\"\n", ip, in_fn [i]); 11.241 if (last_tiff_page ()) 11.242 @@ -576,12 +524,13 @@ 11.243 { 11.244 char *spec_fn = NULL; 11.245 char *out_fn = NULL; 11.246 + char *bookmark_fmt = NULL; 11.247 int inf_count = 0; 11.248 char *in_fn [MAX_INPUT_FILES]; 11.249 11.250 progname = argv [0]; 11.251 11.252 - panda_init (); 11.253 + pdf_init (); 11.254 11.255 while (--argc) 11.256 { 11.257 @@ -611,6 +560,17 @@ 11.258 else 11.259 fatal (1, "missing filename after \"-s\" option\n"); 11.260 } 11.261 + else if (strcmp (argv [1], "-b") == 0) 11.262 + { 11.263 + if (argc) 11.264 + { 11.265 + argc--; 11.266 + argv++; 11.267 + bookmark_fmt = argv [1]; 11.268 + } 11.269 + else 11.270 + fatal (1, "missing format string after \"-b\" option\n"); 11.271 + } 11.272 else 11.273 fatal (1, "unrecognized option \"%s\"\n", argv [1]); 11.274 }
12.1 --- a/tumble.c Thu Feb 20 12:21:10 2003 +0000 12.2 +++ b/tumble.c Thu Feb 20 12:44:17 2003 +0000 12.3 @@ -4,7 +4,7 @@ 12.4 * will be compressed using ITU-T T.6 (G4) fax encoding. 12.5 * 12.6 * Main program 12.7 - * $Id: tumble.c,v 1.21 2003/01/21 10:39:55 eric Exp $ 12.8 + * $Id: tumble.c,v 1.22 2003/02/20 04:44:17 eric Exp $ 12.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 12.10 * 12.11 * This program is free software; you can redistribute it and/or modify 12.12 @@ -20,7 +20,8 @@ 12.13 * 12.14 * You should have received a copy of the GNU General Public License 12.15 * along with this program; if not, write to the Free Software 12.16 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA */ 12.17 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 12.18 + */ 12.19 12.20 12.21 #include <stdarg.h> 12.22 @@ -28,18 +29,17 @@ 12.23 #include <stdint.h> 12.24 #include <stdio.h> 12.25 #include <stdlib.h> 12.26 +#include <string.h> 12.27 #include <unistd.h> 12.28 12.29 #include <tiffio.h> 12.30 #define TIFF_REVERSE_BITS 12.31 12.32 -#include <panda/functions.h> 12.33 -#include <panda/constants.h> 12.34 - 12.35 #include "bitblt.h" 12.36 #include "semantics.h" 12.37 #include "parser.tab.h" 12.38 #include "t2p.h" 12.39 +#include "pdf.h" 12.40 12.41 12.42 #define MAX_INPUT_FILES 5000 12.43 @@ -55,7 +55,7 @@ 12.44 { 12.45 struct output_file_t *next; 12.46 char *name; 12.47 - panda_pdf *pdf; 12.48 + pdf_file_handle pdf; 12.49 } output_file_t; 12.50 12.51 12.52 @@ -66,7 +66,6 @@ 12.53 TIFF *in; 12.54 output_file_t *output_files; 12.55 output_file_t *out; 12.56 -/* panda_pdf *out; */ 12.57 12.58 12.59 char *progname; 12.60 @@ -87,6 +86,10 @@ 12.61 fprintf (stderr, " %s [options] <input.tif>... -o <output.pdf>\n", progname); 12.62 fprintf (stderr, "options:\n"); 12.63 fprintf (stderr, " -v verbose\n"); 12.64 + fprintf (stderr, " -b fmt create bookmarks\n"); 12.65 + fprintf (stderr, "bookmark format:\n"); 12.66 + fprintf (stderr, " %%F file name\n"); 12.67 + fprintf (stderr, " %%p page number\n"); 12.68 } 12.69 12.70 12.71 @@ -158,7 +161,7 @@ 12.72 for (o = output_files; o; o = n) 12.73 { 12.74 n = o->next; 12.75 - panda_close (o->pdf); 12.76 + pdf_close (o->pdf); 12.77 free (o->name); 12.78 free (o); 12.79 } 12.80 @@ -195,7 +198,7 @@ 12.81 return (0); 12.82 } 12.83 12.84 - o->pdf = panda_open (name, "w"); 12.85 + o->pdf = pdf_create (name); 12.86 if (! o->pdf) 12.87 { 12.88 fprintf (stderr, "can't open output file '%s'\n", name); 12.89 @@ -205,15 +208,15 @@ 12.90 } 12.91 12.92 if (attributes->author) 12.93 - panda_setauthor (o->pdf, attributes->author); 12.94 + pdf_set_author (o->pdf, attributes->author); 12.95 if (attributes->creator) 12.96 - panda_setcreator (o->pdf, attributes->creator); 12.97 + pdf_set_creator (o->pdf, attributes->creator); 12.98 if (attributes->title) 12.99 - panda_settitle (o->pdf, attributes->title); 12.100 + pdf_set_title (o->pdf, attributes->title); 12.101 if (attributes->subject) 12.102 - panda_setsubject (o->pdf, attributes->subject); 12.103 + pdf_set_subject (o->pdf, attributes->subject); 12.104 if (attributes->keywords) 12.105 - panda_setkeywords (o->pdf, attributes->keywords); 12.106 + pdf_set_keywords (o->pdf, attributes->keywords); 12.107 12.108 /* prepend new output file onto list */ 12.109 o->next = output_files; 12.110 @@ -304,23 +307,15 @@ 12.111 float x_resolution, y_resolution; 12.112 float dest_x_resolution, dest_y_resolution; 12.113 12.114 - int width_points, height_points; /* really 1/72 inch units rather than 12.115 - points */ 12.116 + double width_points, height_points; /* really 1/72 inch units rather than 12.117 + points */ 12.118 12.119 Rect rect; 12.120 Bitmap *bitmap; 12.121 12.122 int row; 12.123 12.124 - panda_page *page; 12.125 - 12.126 - int tiff_temp_fd; 12.127 - char tiff_temp_fn [] = "/var/tmp/t2p-XXXXXX\0"; 12.128 - TIFF *tiff_temp; 12.129 - 12.130 - char pagesize [26]; /* Needs to hold two ints of four characters (0..3420), 12.131 - two zeros, three spaces, two brackets, and a NULL. 12.132 - Added an extra ten characters just in case. */ 12.133 + pdf_page_handle page; 12.134 12.135 if (! TIFFSetDirectory (in, image - 1)) 12.136 { 12.137 @@ -406,7 +401,7 @@ 12.138 dest_image_length = image_width; 12.139 dest_x_resolution = y_resolution; 12.140 dest_y_resolution = x_resolution; 12.141 - SWAP (int, width_points, height_points); 12.142 + SWAP (double, width_points, height_points); /* $$$ not yet set!!! */ 12.143 } 12.144 else 12.145 { 12.146 @@ -453,80 +448,32 @@ 12.147 rotate_bitmap (bitmap, 12.148 input_attributes); 12.149 12.150 - tiff_temp_fd = mkstemp (tiff_temp_fn); 12.151 - if (tiff_temp_fd < 0) 12.152 - { 12.153 - fprintf (stderr, "can't create temporary TIFF file\n"); 12.154 - goto fail; 12.155 - } 12.156 - 12.157 - tiff_temp = TIFFFdOpen (tiff_temp_fd, tiff_temp_fn, "w"); 12.158 - if (! out) 12.159 - { 12.160 - fprintf (stderr, "can't open temporary TIFF file '%s'\n", tiff_temp_fn); 12.161 - goto fail; 12.162 - } 12.163 - 12.164 - TIFFSetField (tiff_temp, TIFFTAG_IMAGELENGTH, rect_height (& bitmap->rect)); 12.165 - TIFFSetField (tiff_temp, TIFFTAG_IMAGEWIDTH, rect_width (& bitmap->rect)); 12.166 - TIFFSetField (tiff_temp, TIFFTAG_PLANARCONFIG, planar_config); 12.167 - 12.168 - TIFFSetField (tiff_temp, TIFFTAG_ROWSPERSTRIP, rect_height (& bitmap->rect)); 12.169 - 12.170 - TIFFSetField (tiff_temp, TIFFTAG_RESOLUTIONUNIT, resolution_unit); 12.171 - TIFFSetField (tiff_temp, TIFFTAG_XRESOLUTION, dest_x_resolution); 12.172 - TIFFSetField (tiff_temp, TIFFTAG_YRESOLUTION, dest_y_resolution); 12.173 - 12.174 - TIFFSetField (tiff_temp, TIFFTAG_SAMPLESPERPIXEL, samples_per_pixel); 12.175 - TIFFSetField (tiff_temp, TIFFTAG_BITSPERSAMPLE, bits_per_sample); 12.176 - TIFFSetField (tiff_temp, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4); 12.177 - TIFFSetField (tiff_temp, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); 12.178 - 12.179 #ifdef TIFF_REVERSE_BITS 12.180 reverse_bits ((uint8_t *) bitmap->bits, 12.181 image_length * bitmap->row_words * sizeof (word_type)); 12.182 #endif /* TIFF_REVERSE_BITS */ 12.183 12.184 - for (row = 0; row < rect_height (& bitmap->rect); row++) 12.185 - if (1 != TIFFWriteScanline (tiff_temp, 12.186 - bitmap->bits + row * bitmap->row_words, 12.187 - row, 12.188 - 0)) 12.189 - { 12.190 - fprintf (stderr, "can't write TIFF scanline\n"); 12.191 - goto fail; 12.192 - } 12.193 - 12.194 - TIFFClose (tiff_temp); 12.195 - 12.196 width_points = (rect_width (& bitmap->rect) / dest_x_resolution) * POINTS_PER_INCH; 12.197 height_points = (rect_height (& bitmap->rect) / dest_y_resolution) * POINTS_PER_INCH; 12.198 12.199 - free_bitmap (bitmap); 12.200 - 12.201 if ((height_points > PAGE_MAX_POINTS) || (width_points > PAGE_MAX_POINTS)) 12.202 { 12.203 fprintf (stdout, "image too large (max %d inches on a side\n", PAGE_MAX_INCHES); 12.204 goto fail; 12.205 } 12.206 12.207 - sprintf (pagesize, "[0 0 %d %d]", width_points, height_points); 12.208 + page = pdf_new_page (out->pdf, width_points, height_points); 12.209 12.210 - page = panda_newpage (out->pdf, pagesize); 12.211 - panda_imagebox (out->pdf, 12.212 - page, 12.213 - 0, /* top */ 12.214 - 0, /* left */ 12.215 - height_points, /* bottom */ 12.216 - width_points, /* right */ 12.217 - tiff_temp_fn, 12.218 - panda_image_tiff); 12.219 + pdf_write_g4_fax_image (page, 12.220 + bitmap, 12.221 + 0, /* ImageMask */ 12.222 + 0); /* BlackIs1 */ 12.223 + 12.224 + free_bitmap (bitmap); 12.225 12.226 result = 1; 12.227 12.228 fail: 12.229 - if (tiff_temp_fd) 12.230 - unlink (tiff_temp_fn); 12.231 return (result); 12.232 } 12.233 12.234 @@ -548,6 +495,7 @@ 12.235 fatal (3, "error opening input file \"%s\"\n", in_fn [i]); 12.236 for (ip = 1;; ip++) 12.237 { 12.238 + fprintf (stderr, "processing page %d of file \"%s\"\r", ip, in_fn [i]); 12.239 if (! process_page (ip, input_attributes, NULL)) 12.240 fatal (3, "error processing page %d of input file \"%s\"\n", ip, in_fn [i]); 12.241 if (last_tiff_page ()) 12.242 @@ -576,12 +524,13 @@ 12.243 { 12.244 char *spec_fn = NULL; 12.245 char *out_fn = NULL; 12.246 + char *bookmark_fmt = NULL; 12.247 int inf_count = 0; 12.248 char *in_fn [MAX_INPUT_FILES]; 12.249 12.250 progname = argv [0]; 12.251 12.252 - panda_init (); 12.253 + pdf_init (); 12.254 12.255 while (--argc) 12.256 { 12.257 @@ -611,6 +560,17 @@ 12.258 else 12.259 fatal (1, "missing filename after \"-s\" option\n"); 12.260 } 12.261 + else if (strcmp (argv [1], "-b") == 0) 12.262 + { 12.263 + if (argc) 12.264 + { 12.265 + argc--; 12.266 + argv++; 12.267 + bookmark_fmt = argv [1]; 12.268 + } 12.269 + else 12.270 + fatal (1, "missing format string after \"-b\" option\n"); 12.271 + } 12.272 else 12.273 fatal (1, "unrecognized option \"%s\"\n", argv [1]); 12.274 }