pdf_page_label.c

Fri, 14 Mar 2003 08:24:37 +0000

author
eric
date
Fri, 14 Mar 2003 08:24:37 +0000
changeset 131
4b8c80d77f76
child 132
ccf1c28a2940
permissions
-rw-r--r--

finished implementing page labels.

     1 /*
     2  * tumble: build a PDF file from image files
     3  *
     4  * PDF routines
     5  * $Id: pdf_page_label.c,v 1.1 2003/03/14 00:24:37 eric Exp $
     6  * Copyright 2003 Eric Smith <eric@brouhaha.com>
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License version 2 as
    10  * published by the Free Software Foundation.  Note that permission is
    11  * not granted to redistribute this program under the terms of any
    12  * other version of the General Public License.
    13  *
    14  * This program is distributed in the hope that it will be useful,
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
    18  *
    19  * You should have received a copy of the GNU General Public License
    20  * along with this program; if not, write to the Free Software
    21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
    22  */
    25 #include <stdbool.h>
    26 #include <stdint.h>
    27 #include <stdio.h>
    28 #include <stdlib.h>
    29 #include <string.h>
    32 #include "bitblt.h"
    33 #include "pdf.h"
    34 #include "pdf_util.h"
    35 #include "pdf_prim.h"
    36 #include "pdf_private.h"
    37 #include "pdf_name_tree.h"
    40 void pdf_new_page_label (pdf_file_handle pdf_file,
    41 			 int page_index,
    42 			 int base,
    43 			 int count,
    44 			 char style,
    45 			 char *prefix)
    46 {
    47   struct pdf_obj *label_dict;
    48   char style_str [2] = { style, '\0' };
    50   fprintf (stderr,
    51 	   "page index %d, count %d, base %d, prefix '%s', style %c\n",
    52 	   page_index, count, base,
    53 	   prefix ? prefix : "NULL",
    54 	   style);
    56   if (! pdf_file->page_label_tree)
    57     {
    58       pdf_file->page_label_tree = pdf_new_name_tree (pdf_file, 1);
    59     }
    61   label_dict = pdf_new_obj (PT_DICTIONARY);
    62   pdf_set_dict_entry (label_dict, "S", pdf_new_name (style_str));
    63   if (prefix)
    64     pdf_set_dict_entry (label_dict, "P", pdf_new_string (prefix));
    65   if (base != 1)
    66     pdf_set_dict_entry (label_dict, "St", pdf_new_integer (base));
    68   pdf_add_number_tree_element (pdf_file->page_label_tree,
    69 			       page_index,
    70 			       label_dict);
    71 }