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