2010.05.20 08:23 "[Tiff] [PATCH] tiff2ps: Ability to specify document title", by Thomas Jarosch

2010.05.20 08:23 "[Tiff] [PATCH] tiff2ps: Ability to specify document title", by Thomas Jarosch

Hello,

attached is a small patch that adds the ability to specify

the postscript document title generated by tiff2ps.

If no title is specified, the filename is used like before.

Cheers,

Thomas

diff -u -r -p tiff-3.9.2/man/tiff2ps.1 tiff.title/man/tiff2ps.1

--- tiff-3.9.2/man/tiff2ps.1    2009-08-20 20:40:33.000000000 +0200
+++ tiff.title/man/tiff2ps.1    2010-05-20 10:08:26.925282892 +0200

@@ -192,6 +192,9 @@ Rotate image by 180 degrees.
 .B \-s
 Generate output for a single IFD (page) in the input file.
 .TP
+.B \-t

+Set title field of the postscript document. Otherwise the filename is used.

+.TP
 .B \-w
 Specify the horizontal size of the printed area (in inches).
 .TP
diff -u -r -p tiff-3.9.2/tools/tiff2ps.c tiff.title/tools/tiff2ps.c

--- tiff-3.9.2/tools/tiff2ps.c  2010-05-20 09:58:40.509258780 +0200
+++ tiff.title/tools/tiff2ps.c  2010-05-20 10:06:17.192047405 +0200

@@ -140,7 +140,8 @@ double      maxPageWidth  = 0;              /* maximum wi

 double splitOverlap = 0;               /* amount for split pages to overlag */
 int    rotate = FALSE;                 /* rotate image by angle 90, 180, 270 degrees */
 int    rotation = 0;                   /* optional value for rotation angle */
-char   *filename;                      /* input filename */
+char   *filename = NULL;               /* input filename */
+char   *title = NULL;                  /* document title. set to input filename if unspecified */
 int    useImagemask = FALSE;           /* Use imagemask instead of image operator */
 uint16 res_unit = 0;                   /* Resolution units: 2 - inches, 3 - cm */

@@ -186,7 +187,7 @@ main(int argc, char* argv[])
        extern int optind;
        FILE* output = stdout;

-       while ((c = getopt(argc, argv, "b:d:h:H:W:L:i:w:l:o:O:r:acelmxyzps1238DT")) != -1)
+       while ((c = getopt(argc, argv, "b:d:h:H:W:L:i:w:l:o:O:r:t:acelmxyzps1238DT")) != -1)

               switch (c) {

                case 'b':
                        bottommargin = atof(optarg);
@@ -269,6 +270,9 @@ main(int argc, char* argv[])
                case 's':
                        printAll = FALSE;
                        break;
+               case 't':
+                       title = optarg;
+                       break;
                case 'w':
                        pageWidth = atof(optarg);
                        break;

@@ -955,7 +959,7 @@ PSHead(FILE *fd, TIFF *tif, uint32 w, ui

       t = time(0);

        fprintf(fd, "%%!PS-Adobe-3.0%s\n", generateEPSF ? " EPSF-3.0" : "");
        fprintf(fd, "%%%%Creator: tiff2ps\n");
-       fprintf(fd, "%%%%Title: %s\n", filename);
+       fprintf(fd, "%%%%Title: %s\n", title ? title : filename);
        fprintf(fd, "%%%%CreationDate: %s", ctime(&t));
        fprintf(fd, "%%%%DocumentData: Clean7Bit\n");
        fprintf(fd, "%%%%Origin: %ld %ld\n", (long) ox, (long) oy);

@@ -2354,6 +2358,7 @@ char* stuff[] = {

 " -p            generate regular PostScript",
 " -r # or auto  rotate by 90, 180, 270 degrees or auto",
 " -s            generate PostScript for a single image",
+" -t name       set postscript document title. Otherwise the filename is used",
 " -T            print pages for top edge binding",
 " -x            override resolution units as centimeters",
 " -y            override resolution units as inches",