Thu, 13 Mar 2003 07:57:21 +0000
added pdf_write_text(), just a placeholder/debugging tool at the moment.
Makefile | file | annotate | diff | revisions | |
pdf.h | file | annotate | diff | revisions | |
pdf_text.c | file | annotate | diff | revisions |
1.1 diff -r c22e1c0a64fd -r cbc382d73a86 Makefile 1.2 --- a/Makefile Thu Mar 13 06:56:57 2003 +0000 1.3 +++ b/Makefile Thu Mar 13 07:57:21 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.27 2003/03/12 19:39:38 eric Exp $ 1.8 +# $Id: Makefile,v 1.28 2003/03/12 23:57:21 eric Exp $ 1.9 # Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 1.10 # 1.11 # This program is free software; you can redistribute it and/or modify 1.12 @@ -55,7 +55,7 @@ 1.13 # let me know why so I can improve this Makefile. 1.14 # ----------------------------------------------------------------------------- 1.15 1.16 -VERSION = 0.22 1.17 +VERSION = 0.23 1.18 1.19 PACKAGE = t2p 1.20 1.21 @@ -64,7 +64,7 @@ 1.22 CSRCS = t2p.c semantics.c \ 1.23 bitblt.c bitblt_table_gen.c bitblt_g4.c g4_table_gen.c \ 1.24 pdf.c pdf_util.c pdf_prim.c pdf_bookmark.c pdf_name_tree.c \ 1.25 - pdf_g4.c pdf_jpeg.c 1.26 + pdf_text.c pdf_g4.c pdf_jpeg.c 1.27 OSRCS = scanner.l parser.y 1.28 HDRS = t2p.h semantics.h bitblt.h bitblt_tables.h \ 1.29 pdf.h pdf_private.h pdf_util.h pdf_prim.h pdf_name_tree.h 1.30 @@ -88,7 +88,7 @@ 1.31 t2p: t2p.o scanner.o semantics.o parser.tab.o \ 1.32 bitblt.o bitblt_g4.o bitblt_tables.o g4_tables.o \ 1.33 pdf.o pdf_util.o pdf_prim.o pdf_bookmark.o pdf_name_tree.o \ 1.34 - pdf_g4.o pdf_jpeg.o 1.35 + pdf_text.o pdf_g4.o pdf_jpeg.o 1.36 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ 1.37 ifndef DEBUG 1.38 strip $@
2.1 diff -r c22e1c0a64fd -r cbc382d73a86 pdf.h 2.2 --- a/pdf.h Thu Mar 13 06:56:57 2003 +0000 2.3 +++ b/pdf.h Thu Mar 13 07:57:21 2003 +0000 2.4 @@ -4,7 +4,7 @@ 2.5 * will be compressed using ITU-T T.6 (G4) fax encoding. 2.6 * 2.7 * PDF routines 2.8 - * $Id: pdf.h,v 1.7 2003/03/12 02:57:55 eric Exp $ 2.9 + * $Id: pdf.h,v 1.8 2003/03/12 23:57:21 eric Exp $ 2.10 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 2.11 * 2.12 * This program is free software; you can redistribute it and/or modify 2.13 @@ -57,6 +57,9 @@ 2.14 void pdf_close_page (pdf_page_handle pdf_page); 2.15 2.16 2.17 +void pdf_write_text (pdf_page_handle pdf_page); 2.18 + 2.19 + 2.20 /* The length of the data must be Rows * rowbytes. 2.21 Note that rowbytes must be at least (Columns+7)/8, but may be arbitrarily 2.22 large. */
3.1 diff -r c22e1c0a64fd -r cbc382d73a86 pdf_text.c 3.2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 +++ b/pdf_text.c Thu Mar 13 07:57:21 2003 +0000 3.4 @@ -0,0 +1,91 @@ 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_text.c,v 1.1 2003/03/12 23:57:21 eric Exp $ 3.12 + * Copyright 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 +#include <string.h> 3.36 + 3.37 + 3.38 +#include "bitblt.h" 3.39 +#include "pdf.h" 3.40 +#include "pdf_util.h" 3.41 +#include "pdf_prim.h" 3.42 +#include "pdf_private.h" 3.43 + 3.44 + 3.45 + 3.46 +static void pdf_write_text_content_callback (pdf_file_handle pdf_file, 3.47 + struct pdf_obj *stream, 3.48 + void *app_data) 3.49 +{ 3.50 + pdf_stream_printf (pdf_file, stream, 3.51 + "BT /F1 24 Tf 100 100 Td (Hello World) Tj ET\r\n"); 3.52 +} 3.53 + 3.54 + 3.55 +static struct pdf_obj *pdf_create_font (pdf_page_handle pdf_page) 3.56 +{ 3.57 + struct pdf_obj *font = pdf_new_ind_ref (pdf_page->pdf_file, 3.58 + pdf_new_obj (PT_DICTIONARY)); 3.59 + pdf_set_dict_entry (font, "Type", pdf_new_name ("Font")); 3.60 + pdf_set_dict_entry (font, "Subtype", pdf_new_name ("Type1")); 3.61 + pdf_set_dict_entry (font, "Name", pdf_new_name ("F1")); 3.62 + pdf_set_dict_entry (font, "BaseFont", pdf_new_name ("Helvetica")); 3.63 + pdf_set_dict_entry (font, "Encoding", pdf_new_name ("MacRomanEncoding")); 3.64 + 3.65 + return (font); 3.66 +} 3.67 + 3.68 +void pdf_write_text (pdf_page_handle pdf_page) 3.69 +{ 3.70 + struct pdf_obj *font; 3.71 + struct pdf_obj *font_dict; 3.72 + struct pdf_obj *content_stream; 3.73 + 3.74 + font = pdf_create_font (pdf_page); 3.75 + 3.76 + font_dict = pdf_new_ind_ref (pdf_page->pdf_file, 3.77 + pdf_new_obj (PT_DICTIONARY)); 3.78 + 3.79 + pdf_set_dict_entry (font_dict, "F1", font); 3.80 + 3.81 + pdf_set_dict_entry (pdf_page->resources, "Font", font_dict); 3.82 + 3.83 + pdf_add_array_elem_unique (pdf_page->procset, pdf_new_name ("Text")); 3.84 + 3.85 + content_stream = pdf_new_ind_ref (pdf_page->pdf_file, 3.86 + pdf_new_stream (pdf_page->pdf_file, 3.87 + pdf_new_obj (PT_DICTIONARY), 3.88 + & pdf_write_text_content_callback, 3.89 + NULL)); 3.90 + 3.91 + pdf_set_dict_entry (pdf_page->page_dict, "Contents", content_stream); 3.92 + 3.93 + pdf_write_ind_obj (pdf_page->pdf_file, content_stream); 3.94 +} 3.95 +