--- poster-20050907.orig/.pc/.quilt_patches +++ poster-20050907/.pc/.quilt_patches @@ -0,0 +1 @@ +debian/patches --- poster-20050907.orig/.pc/.quilt_series +++ poster-20050907/.pc/.quilt_series @@ -0,0 +1 @@ +series --- poster-20050907.orig/.pc/.version +++ poster-20050907/.pc/.version @@ -0,0 +1 @@ +2 --- poster-20050907.orig/.pc/Bug485924.patch/poster.1 +++ poster-20050907/.pc/Bug485924.patch/poster.1 @@ -0,0 +1,328 @@ +.TH POSTER 1 +.fi +.SH NAME +poster \- Scale and tile a postscript image to print on multiple pages +.SH SYNOPSIS +.in +7n +.ti -7n +poster infile +.in -7n +.SH DESCRIPTION +\fIPoster\fP can be used to create a large poster by building it +from multiple pages and/or printing it on large media. +It expects as input a generic (encapsulated) postscript +file, normally printing on a single page. +The output is again a postscript file, maybe containing multiple pages +together building the poster. +The output pages bear cutmarks and have slightly overlapping images +for easier assembling. +The input picture will be scaled to obtain the desired size. +.P +The program uses a brute-force method: it copies the entire input +file for each output page, hence the output file can be very large. +Since the program does not really bother about the input file contents, +it clearly works for both black-and-white and color postscript. +.P +To control its operation, you need to specify either the size +of the desired poster or a scale factor for the image: +.TP 2n +- +Given the poster size, it calculates the required number of sheets +to print on, and from that a scale factor to fill these sheets optimally with the +input image. +.TP +- +Given a scale factor, it derives the required number of pages from the input +image size, and positions the scaled image centered on this area. +.P +Its input file should best be a real `Encapsulated Postscript' file +(often denoted with the extension .eps or .epsf). +Such files can be generated from about all current drawing applications, +and text processors like Word, Interleaf and Framemaker. +.br +However \fIposter\fP tries to behave properly also on more relaxed, +general postscript files containing a single page definition. +Proper operation is obtained for instance on pages generated +by (La)TeX and (g)troff. +.P +The media to print on can be selected independently from the input image size +and/or the poster size. \fIPoster\fP will determine by itself whether it +is beneficial to rotate the output image on the media. +.P +To preview the output results of \fIposter\fP and/or to (re-)print individual +output pages, you should use a postscript previewer like ghostview(1). + +.ne 5 +.SH OPTIONS +.TP 3n +-v +Be verbose. Tell about scaling, rotation and number of pages. +.br +Default is silent operation. +.TP +-f +Ask manual media feed on the plotting/printing device, +instead of using its standard paper tray. +.br +Default is adhering to the device settings. +.TP +-i +Specify the size of the input image. +.br +Default is reading the image size from the `%%BoundingBox' specification +in the input file header. +.TP +-m +Specify the desired media size to print on. See below for . +.br +The default is obtained from the PAPERCONF environment variable. If +it is not set, it is read from the file whose name is in the PAPERSIZE +environment variable. If that too is not set, the default is read +from the file /etc/papersize. See +.BR papersize (5) +for a full description of the format of the config file. +.TP +-p +Specify the poster size. See below for . +Since \fIposter\fP will autonomously choose for rotation, +always specify a `portrait' poster size (i.e. higher then wide). +.br +If you don't give the -s option, the default poster size is identical to the +media size. +.TP +-s +Specify a linear scaling factor to produce the poster. +Together with the input image size and optional margins, this induces +an output poster size. So don't specify both -s and -p. +.br +Default is deriving the scale factor to fit a given poster size. +.TP +-c \fIor\fP -c % +.br +Specify the cut margin. This is the distance between the cutmarks and +the paper edge. If the output is really tiled on multiple sheets, +the cut marks indicate where to cut the paper for assembly. +This margin must be big enough to cover the non-printable margin which almost +all printers have. For see below. +.br +Default is 5%. Only when you specify identical poster and media sizes, +the default cut margin becomes 0, effectively removing the cutmarks. +.TP +-w \fIor\fP -w % +.br +Specify a white margin around the output image. +.br +In the `ideal' situation (when an input `eps' file specifies an exact +BoundingBox in its header), the output image will be scaled exactly to +the edges of the resulting poster (minus cut margin). If you desire +a certain margin to remain around the picture after poster assembly, +you can specify this with `-w'. +.br +(This option is actually redundant, since you can obtain the same result +using -s or -i. However some might find this more convenient.) +.br +Default is 0. +.TP +-P +.br +Specify which pages of the poster to print. It consists of a comma-separated +list of single pages or page ranges (using the dash). The order in which +page number appears determines the final page order in the result PostScript +file. Page numbering starts at 1, from left to right and bottom-up. +.br +Examples: 1-2 or 1,3-4,7 +.TP +-o +Specify the name of the file to write the output into. +.br +(Only added for those poor people who cannot specify output redirection +from their command line due to a silly OS.) +.br +Default is writing to standard output. +.P +The mentioned above is a specification of horizontal and vertical size. +Only in combination with the `-i' option, the program also understands the +offset specification in the . +.br +In general: + = [][] +.br +with multiplier and offset being specified optionally. + = * +.br + = +, +.br + = or +.P +Many international media names are recognised by the program, in upper and lower case, +and can be shortened to their first few characters, as long as unique. +For instance `A0', `Let'. +.br +Distance names are like `cm', `i', `ft'. + +.ne 5 +.SH EXAMPLES +The following command prints an A4 input file on 8 A3 pages, forming an A0 +poster: + poster -v -iA4 -mA3 -pA0 infile >outfile + +.ne 3 +The next command prints an eps input image on a poster of 3x3 Letter pages: + poster -v -mLet -p3x3Let image.eps > outfile + +.ne 3 +The next command enlarges an eps input image to print on a +large-media A0 capable device, maintaining 2 inch margins: + poster -v -mA0 -w2x2i image.eps > outfile + +.ne 3 +Enlarge a postscript image exactly 4 times, print on the default A4 media, +and let \fIposter\fP determine the number of pages required: + poster -v -s4 image.eps > outfile + +.ne 6 +Scale a postscript image to a poster of about 1 square meter, printing +on `Legal' media, maintaining a 10% of `Legal' size as white margin +around the poster. + poster -v -mLegal -p1x1m -w10% infile.ps >outfile + +.ne 5 +.SH "PROBLEMS & QUESTIONS" +.SS "I get a blurry image and/or interference patterns" +If your input file contains -or consists of- pixel images (as opposed +to just vector data which is essentially resolution independent), +you might have this problem. +Such pixel images are normally made to fit well to standard 300 (or 600) dpi devices. +Scaling such a picture with an carelessly chosen factor, +can easily lead to hazy edges and interference patterns on the output. +The solution is to provide \fIposter\fP with an exact scaling factor +(with the -s option), chosen as an integer. If integer scaling is +impractical for your purpose, +choose a fractional number made from a small integer denominator (2, 3, 4). +.SS "Can I select only a small part of a given input picture?" +Yes, for this purpose you can define both the size (width and height) +and offset (from left and bottom) of a window on the input image. +Specify these numbers as argument to a `-i' command line option. +.br +One way to obtain such numbers is previewing the original image with +ghostview, +and observing the coordinate numbers which it continually displays. +These numbers are in postscript units (points), +named by \fIposter\fP as just `p'. +.SS "Poster doesn't seem to work properly, output pages are empty" +The major cause for poster not to work correctly, is giving it +postscript files which don't conform to proper 'eps' behaviour. +Try whether your application (or printer driver) cannot generate +real 'encapsulated postscript'. +.SS "If I ask for a 50x50cm poster, it always generates something bigger" +Yes, probably. When specifying a desired output size with the `-p' option, +\fIposter\fP first determines an array of sheets to cover such an area. +Then it determines a scale factor for the picture to fill these sheets upto +their edge. As result your requested size is used as rough guess only. +If you want an exact output size, specify the scaling factor yourself +with the `-s' option (and omit the `-p'). +.SS "I want to keep the white space around the poster as in my original" +\fIPoster\fP will as default use the input image bounding box, and +scale/translate that to the edges of your poster. +If the program which generated your input file specifies an exact and tight +%%BoundingBox, you will indeed loose your white margin. +To keep the original margin, specify a `-i' option with as argument the papersize +on which the original document was formatted (such as `-iA4'). +Alternatively specify a smaller scale factor (with -s) or an explicit new +margin (with -w). + +.ne 4 +.SH "POSTER ASSEMBLY" +Our preferred method for the assembly of a poster from multiple sheets +is as follows: +.TP 2n +- +Arrange the sheets in the proper order on a large table or on the floor. +.TP +- +Remove from all sheets, except from those in the leftmost column or +bottom row, their left and bottom cutmargin. +.TP +- +In left-to-right and bottom-to-top order, glue the right (and top) cutmargin +and stick the right (and upper) neighbouring page on top of that. +.TP +- +Turn the glued-together poster face bottom, and put adhesive tape on the sheet +edges (on the backside of the poster) for more strength. +.TP +- +Remove the remaining cutmargin around the poster. + +.ne 4 +.SH "DEVICE SETTINGS" +For postscript level-2 capable printers/plotters, which is about all modern postscript +devices today, \fIposter\fP will send device settings in its output file. +This consists of a `setpagedevice' call, setting: +.TP 2n +- +the media size. +.br +This is required for all printers I know to get correct +behaviour on different media/picture sizes. +.TP +- +duplexing off. +.br +Some printers will otherwise perform double-side printing by default. +Clearly that is not what you want to print a poster. +.TP +- +manual media feed. +.br +This is given only when \fIposter\fP was executed with the `-f' +command line option. This is a convenient feature if you want to print +your job on different media than normally installed in the paper tray, +and you are submitting your job through a multi-user networking and +spooling environment. +.P +These settings cause proper device behaviour, without the need to +manually interact with the printer settings, and has been here locally +tested to work on devices like the HP300XL and HP650C. +.P +The settings thus passed in the postscript file, will affect the device +for this job only. + +.SH "DSC CONFORMANCE" +\fIPoster\fP will generate its own DSC header and other DSC lines +in the output file, according the `Document Structuring Conventions - version +3.0', +as written down in the `Postscript Language Reference Manual, 2nd ed.' from +Adobe Systems Inc, Addison Wesley Publ comp., 1990. +.P +It will copy any `%%Document...' line from the input file DSC header to its +own header output. This is used here in particular for required nonresident +fonts. +.P +However the copy(s) of the input file included in the output, +are stripped from all lines starting with a `%%', since they tend to +disturb our `ghostview' previewer and take useless space anyhow. + +.SH "SEE ALSO" +.BR ghostview "(1), " papersize (5) + +.SH "CONTRIBUTED BY" +.nf +.na +Jos van Eijndhoven (email: J.T.J.v.Eijndhoven@ele.tue.nl) +Design Automation Section (http://www.es.ele.tue.nl) +Dept. of Elec. Eng. +Eindhoven Univ of Technology +The Netherlands +24 August, 1995 + + + + + + + + + + + --- poster-20050907.orig/.pc/Bug884390.patch/Makefile +++ poster-20050907/.pc/Bug884390.patch/Makefile @@ -0,0 +1,30 @@ +# on Debian: +DEFINES = -DHAVE_LIBPAPER +CFLAGS = -O2 -g -Wall +LIBS = -lm -lpaper +# elsewhere +#DEFINES = # nothing +#CFLAGS = -g -Wall +#LIBS = -lm + +poster: poster.c + gcc $(CFLAGS) -o poster $(DEFINES) poster.c $(LIBS) + +# HPUX: cc -O -Aa -D_POSIX_SOURCE -o poster poster.c -lm +# Note that this program might trigger a stupid bug in the HPUX C library, +# causing the sscanf() call to produce a core dump. +# For proper operation, DON'T give the `+ESlit' option to the HP cc, +# or use gcc WITH the `-fwritable-strings' option. + +install: poster + strip poster + cp poster /usr/local/bin + cp poster.1 /usr/local/man/man1 + +clean: + rm -f poster core poster.o getopt.o + +tar: + tar -cvf poster.tar README Makefile poster.c poster.1 manual.ps + rm -f poster.tar.gz + gzip poster.tar --- poster-20050907.orig/.pc/all-changes-to-1.1.patch/Makefile +++ poster-20050907/.pc/all-changes-to-1.1.patch/Makefile @@ -0,0 +1,24 @@ +CFLAGS = -g -Wall +#CFLAGS = -O2 -Wall + +poster: poster.c + gcc $(CFLAGS) -o poster poster.c -lm + +# HPUX: cc -O -Aa -D_POSIX_SOURCE -o poster poster.c -lm +# Note that this program might trigger a stupid bug in the HPUX C library, +# causing the sscanf() call to produce a core dump. +# For proper operation, DON'T give the `+ESlit' option to the HP cc, +# or use gcc WITH the `-fwritable-strings' option. + +install: poster + strip poster + cp poster /usr/local/bin + cp poster.1 /usr/local/man/man1 + +clean: + rm -f poster core poster.o getopt.o + +tar: + tar -cvf poster.tar README Makefile poster.c poster.1 manual.ps + rm -f poster.tar.gz + gzip poster.tar --- poster-20050907.orig/.pc/all-changes-to-1.1.patch/poster.1 +++ poster-20050907/.pc/all-changes-to-1.1.patch/poster.1 @@ -0,0 +1,323 @@ +.TH POSTER 1 +.fi +.SH NAME +poster \- Scale and tile a postscript image to print on multiple pages +.SH SYNOPSIS +.in +7n +.ti -7n +poster infile +.in -7n +.SH DESCRIPTION +\fIPoster\fP can be used to create a large poster by building it +from multiple pages and/or printing it on large media. +It expects as input a generic (encapsulated) postscript +file, normally printing on a single page. +The output is again a postscript file, maybe containing multiple pages +together building the poster. +The output pages bear cutmarks and have slightly overlapping images +for easier assembling. +The input picture will be scaled to obtain the desired size. +.P +The program uses a brute-force method: it copies the entire input +file for each output page, hence the output file can be very large. +Since the program does not really bother about the input file contents, +it clearly works for both black-and-white and color postscript. +.P +To control its operation, you need to specify either the size +of the desired poster or a scale factor for the image: +.TP 2n +- +Given the poster size, it calculates the required number of sheets +to print on, and from that a scale factor to fill these sheets optimally with the +input image. +.TP +- +Given a scale factor, it derives the required number of pages from the input +image size, and positions the scaled image centered on this area. +.P +Its input file should best be a real `Encapsulated Postscript' file +(often denoted with the extension .eps or .epsf). +Such files can be generated from about all current drawing applications, +and text processors like Word, Interleaf and Framemaker. +.br +However \fIposter\fP tries to behave properly also on more relaxed, +general postscript files containing a single page definition. +Proper operation is obtained for instance on pages generated +by (La)TeX and (g)troff. +.P +The media to print on can be selected independently from the input image size +and/or the poster size. \fIPoster\fP will determine by itself whether it +is beneficial to rotate the output image on the media. +.P +To preview the output results of \fIposter\fP and/or to (re-)print individual +output pages, you should use a postscript previewer like ghostview(1). + +.ne 5 +.SH OPTIONS +.TP 3n +-v +Be verbose. Tell about scaling, rotation and number of pages. +.br +Default is silent operation. +.TP +-f +Ask manual media feed on the plotting/printing device, +instead of using its standard paper tray. +.br +Default is adhering to the device settings. +.TP +-i +Specify the size of the input image. +.br +Default is reading the image size from the `%%BoundingBox' specification +in the input file header. +.TP +-m +Specify the desired media size to print on. See below for . +.br +The default is set at compile time, being A4 in the standard package. +.TP +-p +Specify the poster size. See below for . +Since \fIposter\fP will autonomously choose for rotation, +always specify a `portrait' poster size (i.e. higher then wide). +.br +If you don't give the -s option, the default poster size is identical to the +media size. +.TP +-s +Specify a linear scaling factor to produce the poster. +Together with the input image size and optional margins, this induces +an output poster size. So don't specify both -s and -p. +.br +Default is deriving the scale factor to fit a given poster size. +.TP +-c \fIor\fP -c % +.br +Specify the cut margin. This is the distance between the cutmarks and +the paper edge. If the output is really tiled on multiple sheets, +the cut marks indicate where to cut the paper for assembly. +This margin must be big enough to cover the non-printable margin which almost +all printers have. For see below. +.br +Default is 5%. Only when you specify identical poster and media sizes, +the default cut margin becomes 0, effectively removing the cutmarks. +.TP +-w \fIor\fP -w % +.br +Specify a white margin around the output image. +.br +In the `ideal' situation (when an input `eps' file specifies an exact +BoundingBox in its header), the output image will be scaled exactly to +the edges of the resulting poster (minus cut margin). If you desire +a certain margin to remain around the picture after poster assembly, +you can specify this with `-w'. +.br +(This option is actually redundant, since you can obtain the same result +using -s or -i. However some might find this more convenient.) +.br +Default is 0. +.TP +-P +.br +Specify which pages of the poster to print. It consists of a comma-separated +list of single pages or page ranges (using the dash). The order in which +page number appears determines the final page order in the result PostScript +file. Page numbering starts at 1, from left to right and bottom-up. +.br +Examples: 1-2 or 1,3-4,7 +.TP +-o +Specify the name of the file to write the output into. +.br +(Only added for those poor people who cannot specify output redirection +from their command line due to a silly OS.) +.br +Default is writing to standard output. +.P +The mentioned above is a specification of horizontal and vertical size. +Only in combination with the `-i' option, the program also understands the +offset specification in the . +.br +In general: + = [][] +.br +with multipier and offset being specified optionally. + = * +.br + = +, +.br + = or +.P +Many international media names are recognised by the program, in upper and lower case, +and can be shortened to their first few characters, as long as unique. +For instance `A0', `Let'. +.br +Distance names are like `cm', `i', `ft'. + +.ne 5 +.SH EXAMPLES +The following command prints an A4 input file on 8 A3 pages, forming an A0 +poster: + poster -v -iA4 -mA3 -pA0 infile >outfile + +.ne 3 +The next command prints an eps input image on a poster of 3x3 Letter pages: + poster -v -mLet -p3x3Let image.eps > outfile + +.ne 3 +The next command enlarges an eps input image to print on a +large-media A0 capable device, maintaining 2 inch margins: + poster -v -mA0 -w2x2i image.eps > outfile + +.ne 3 +Enlarge a postscript image exactly 4 times, print on the default A4 media, +and let \fIposter\fP determine the number of pages required: + poster -v -s4 image.eps > outfile + +.ne 6 +Scale a postscript image to a poster of about 1 square meter, printing +on `Legal' media, maintaining a 10% of `Legal' size as white margin +around the poster. + poster -v -mLegal -p1x1m -w10% infile.ps >outfile + +.ne 5 +.SH "PROBLEMS & QUESTIONS" +.SS "I get a blurry image and/or interference patterns" +If your input file contains -or consists of- pixel images (as opposed +to just vector data which is essentially resolution independent), +you might have this problem. +Such pixel images are normally made to fit well to standard 300 (or 600) dpi devices. +Scaling such a picture with an uncarefully chosen factor, +can easily lead to hazy edges and interference patterns on the output. +The solution is to provide \fIposter\fP with an exact scaling factor +(with the -s option), chosen as an integer. If integer scaling is +unpractical for your purpose, +choose a fractional number made from a small integer denominator (2, 3, 4). +.SS "Can I select only a small part of a given input picture?" +Yes, for this purpose you can define both the size (width and height) +and offset (from left and bottom) of a window on the input image. +Specify these numbers as argument to a `-i' command line option. +.br +One way to obtain such numbers is previewing the original image with +ghostview, +and observing the coordinate numbers which it continually displays. +These numbers are in postscript units (points), +named by \fIposter\fP as just `p'. +.SS "Poster doesn't seem to work properly, output pages are empty" +The major cause for poster not to work correctly, is giving it +postscript files which don't conform to proper 'eps' behaviour. +Try whether your application (or printer driver) cannot generate +real 'encapsulated postscript'. +.SS "If I ask for a 50x50cm poster, it always generates something bigger" +Yes, probably. When specifying a desired output size with the `-p' option, +\fIposter\fP first determines an array of sheets to cover such an area. +Then it determines a scale factor for the picture to fill these sheets upto +their edge. As result your requested size is used as rough guess only. +If you want an exact output size, specify the scaling factor yourself +with the `-s' option (and omit the `-p'). +.SS "I want to keep the white space around the poster as in my original" +\fIPoster\fP will as default use the input image bounding box, and +scale/translate that to the edges of your poster. +If the program which generated your input file specifies an exact and tight +%%BoundingBox, you will indeed loose your white margin. +To keep the original margin, specify a `-i' option with as argument the papersize +on which the original document was formatted (such as `-iA4'). +Alternatively specify a smaller scale factor (with -s) or an explicit new +margin (with -w). + +.ne 4 +.SH "POSTER ASSEMBLY" +Our preferred method for the assembly of a poster from multiple sheets +is as follows: +.TP 2n +- +Arrange the sheets in the proper order on a large table or on the floor. +.TP +- +Remove from all sheets, except from those in the leftmost column or +bottom row, their left and bottom cutmargin. +.TP +- +In left-to-right and bottom-to-top order, glue the right (and top) cutmargin +and stick the right (and upper) neighbouring page on top of that. +.TP +- +Turn the glued-together poster face bottom, and put adhesive tape on the sheet +edges (on the backside of the poster) for more strength. +.TP +- +Remove the remaining cutmargin around the poster. + +.ne 4 +.SH "DEVICE SETTINGS" +For postscript level-2 capable printers/plotters, which is about all modern postscript +devices today, \fIposter\fP will send device settings in its output file. +This consists of a `setpagedevice' call, setting: +.TP 2n +- +the media size. +.br +This is required for all printers I know to get correct +behaviour on different media/picture sizes. +.TP +- +duplexing off. +.br +Some printers will otherwise perform double-side printing by default. +Clearly that is not what you want to print a poster. +.TP +- +manual media feed. +.br +This is given only when \fIposter\fP was executed with the `-f' +command line option. This is a convenient feature if you want to print +your job on different media than normally installed in the paper tray, +and you are submitting your job through a multi-user networking and +spooling environment. +.P +These settings cause proper device behaviour, without the need to +manually interact with the printer settings, and has been here locally +tested to work on devices like the HP300XL and HP650C. +.P +The settings thus passed in the postscript file, will affect the device +for this job only. + +.SH "DSC CONFORMANCE" +\fIPoster\fP will generate its own DSC header and other DSC lines +in the output file, according the `Document Structuring Conventions - version +3.0', +as written down in the `Postscript Language Reference Manual, 2nd ed.' from +Adobe Systems Inc, Addison Wesley Publ comp., 1990. +.P +It will copy any `%%Document...' line from the input file DSC header to its +own header output. This is used here in particular for required nonresident +fonts. +.P +However the copy(s) of the input file included in the output, +are stripped from all lines starting with a `%', since they tend to +disturb our `ghostview' previewer and take useless space anyhow. + +.SH "SEE ALSO" +ghostview(1) + +.SH "CONTRIBUTED BY" +.nf +.na +Jos van Eijndhoven (email: J.T.J.v.Eijndhoven@ele.tue.nl) +Design Automation Section (http://www.es.ele.tue.nl) +Dept. of Elec. Eng. +Eindhoven Univ of Technology +The Netherlands +24 August, 1995 + + + + + + + + + + + --- poster-20050907.orig/.pc/all-changes-to-1.1.patch/poster.c +++ poster-20050907/.pc/all-changes-to-1.1.patch/poster.c @@ -0,0 +1,1058 @@ +/* +# poster.c - a generic PS scaling program +# This program scales a PostScript page to a given size (a poster). +# The output can be tiled on multiple sheets, and output +# media size can be chosen independently. +# Each tile (sheet) of a will bear cropmarks and slightly overlapping +# image for easier poster assembly. +# +# Compile this program with: +# cc -O -o poster poster.c -lm +# or something alike. +# +# Maybe you want to change the `DefaultMedia' and `DefaultImage' +# settings in the few lines below, to reflect your local situation. +# Names can to be chosen from the `mediatable' further down. +# +# The `Gv_gs_orientbug 1' disables a feature of this program to +# ask for landscape previewing of rotated images. +# Our currently installed combination of ghostview 1.5 with ghostscript 3.33 +# cannot properly do a landscape viewing of the `poster' output. +# The problem does not exist in combination with an older ghostscript 2.x, +# and has the attention of the ghostview authors. +# (The problem is in the evaluation of the `setpagedevice' call.) +# If you have a different previewing environment, +# you might want to set `Gv_gs_orientbug 0' +# +# Jos van Eijndhoven, Eindhoven University of Technology +# email: J.T.J.v.Eijndhoven@ele.tue.nl +# September 7, 1995 +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this library; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# +*/ + +#define Gv_gs_orientbug 1 +#define DefaultMedia "A4" +#define DefaultImage "A4" +#define DefaultCutMargin "5%" +#define DefaultWhiteMargin "0" +#define BUFSIZE 1024 + +#include +#include +#include +#include +#include +#include + + +extern char *optarg; /* silently set by getopt() */ +extern int optind, opterr; /* silently set by getopt() */ + +static void usage(); +static void dsc_head1(); +static int dsc_infile( double ps_bb[4]); +static void dsc_head2( void); +static void printposter( void); +static void printprolog(); +static void tile ( int row, int col, int pagetoprint); +static void printfile( int pagetoprint); +static void postersize( char *scalespec, char *posterspec); +static void box_convert( char *boxspec, double psbox[4]); +static void boxerr( char *spec); +static void margin_convert( char *spec, double margin[2]); +static int mystrncasecmp( const char *s1, const char *s2, int n); +static char* tmpinfile( void ); +static int parsepagespec( int **page_array, int *len, int *size, char *pagespec ); +static void do_fake_mode( void ); + +int verbose; +char *myname; +char *infile; +int rotate, nrows, ncols; +int manualfeed = 0; +int tail_cntl_D = 0; +#define Xl 0 +#define Yb 1 +#define Xr 2 +#define Yt 3 +#define X 0 +#define Y 1 +double posterbb[4]; /* final image in ps units */ +double imagebb[4]; /* original image in ps units */ +double mediasize[4]; /* [34] = size of media to print on, [01] not used! */ +double cutmargin[2]; +double whitemargin[2]; +double scale; /* linear scaling factor */ +int number_pages = 1; +int *pages = NULL; +int pages_size = 0; +int pages_length = 0; +int fake_mode = 0; + +/* defaults: */ +char *imagespec = NULL; +char *posterspec = NULL; +char *mediaspec = NULL; +char *cutmarginspec = NULL; +char *whitemarginspec = NULL; +char *scalespec = NULL; +char *filespec = NULL; +char *pagespec = NULL; + +/* media sizes in ps units (1/72 inch) */ +static char *mediatable[][2] = +{ { "Letter", "612,792"}, + { "Legal", "612,1008"}, + { "Tabloid", "792,1224"}, + { "Ledger", "792,1224"}, + { "Executive","540,720"}, + { "Monarch", "279,540"}, + { "Statement","396,612"}, + { "Folio", "612,936"}, + { "Quarto", "610,780"}, + { "C5", "459,649"}, + { "C5E", "459,649"}, + { "EnvC5", "459,649"}, + { "B0", "2916,4128"}, + { "B1", "2064,2916"}, + { "B2", "1458,2064"}, + { "B3", "1032,1458"}, + { "B4", "729,1032"}, + { "B5", "516,729"}, + { "B6", "365,516"}, + { "B7", "258,365"}, + { "B8", "183,258"}, + { "B9", "129,183"}, + { "B10", "92,129"}, + { "Dl", "312,624"}, + { "A0", "2380,3368"}, + { "A1", "1684,2380"}, + { "A2", "1190,1684"}, + { "A3", "842,1190"}, + { "A4", "595,842"}, + { "A5", "421,595"}, + { "A6", "297,421"}, + { "A7", "210,297"}, + { "A8", "148,210"}, + { "A9", "105,148"}, + { "Comm10", "298,684"}, + { "COM10", "298,684"}, + { "Env10", "298,684"}, + { "DL", "312,624"}, + { "DLE", "312,624"}, + { "EnvDL", "312,624"}, + + /* as fall-back: linear units of measurement: */ + { "p", "1,1"}, + { "i", "72,72"}, + { "ft", "864,864"}, + { "mm", "2.83465,2.83465"}, + { "cm", "28.3465,28.3465"}, + { "m", "2834.65,2834.65"}, + { NULL, NULL} +}; + + +int main( int argc, char *argv[]) +{ + int opt; + double ps_bb[4]; + int got_bb; + int need_remove = 0; + + myname = argv[0]; + + while ((opt = getopt( argc, argv, "vfi:c:w:m:p:s:o:P:F")) != EOF) + { switch( opt) + { case 'v': verbose++; break; + case 'f': manualfeed = 1; break; + case 'i': imagespec = optarg; break; + case 'c': cutmarginspec = optarg; break; + case 'w': whitemarginspec = optarg; break; + case 'm': mediaspec = optarg; break; + case 'p': posterspec = optarg; break; + case 's': scalespec = optarg; break; + case 'o': filespec = optarg; break; + case 'P': pagespec = optarg; break; + case 'F': fake_mode = 1; break; + default: usage(); break; + } + } + + /*** check command line arguments ***/ + if (scalespec && posterspec) + { fprintf( stderr, "Please don't specify both -s and -p, ignoring -s!\n"); + scalespec = NULL; + } + + if (optind < argc) + infile = argv[ optind]; + else if ( !fake_mode ) + { + infile = tmpinfile(); + need_remove = 1; + } + /* + { fprintf( stderr, "Filename argument missing!\n"); + usage(); + } + */ + + /*** decide on media size ***/ + if (!mediaspec) + { mediaspec = DefaultMedia; + if (verbose) + fprintf( stderr, + "Using default media of %s\n", + mediaspec); + } + box_convert( mediaspec, mediasize); + if (mediasize[3] < mediasize[2]) + { fprintf( stderr, "Media should always be specified in portrait format!\n"); + exit(1); + } + if (mediasize[2]-mediasize[0] <= 10.0 || mediasize[3]-mediasize[1] <= 10.0) + { fprintf( stderr, "Media size is ridiculous!\n"); + exit(1); + } + + /*** defaulting poster size ? **/ + if (!scalespec && !posterspec) + { /* inherit postersize from given media size */ + posterspec = mediaspec; + if (verbose) + fprintf( stderr, + "Defaulting poster size to media size of %s\n", + mediaspec); + } + + /*** decide the cutmargin size, after knowing media size ***/ + if (!cutmarginspec) + { if (posterspec && (!strcmp( posterspec, mediaspec))) + /* zero cutmargin if printing to 1 sheet */ + cutmarginspec = "0%"; + else + cutmarginspec = DefaultCutMargin; + if (verbose) + fprintf( stderr, + "Using default cutmargin of %s\n", + cutmarginspec); + } + margin_convert( cutmarginspec, cutmargin); + + /*** decide the whitemargin size, after knowing media size ***/ + if (!whitemarginspec) + { whitemarginspec = DefaultWhiteMargin; + if (verbose) + fprintf( stderr, + "Using default whitemargin of %s\n", + whitemarginspec); + } + margin_convert( whitemarginspec, whitemargin); + + /*** parse page specification ***/ + if ( pagespec && parsepagespec( &pages, &pages_length, &pages_size, pagespec ) == 0 ) + { + fprintf( stderr, "Wrong page set specification: %s\n", pagespec ); + exit( 1 ); + } + + if ( fake_mode ) + { + do_fake_mode(); + exit( 0 ); + } + + /******************* now start doing things **************************/ + /* open output file */ + if (filespec) + { if (!freopen( filespec, "w", stdout)) + { fprintf( stderr, "Cannot open '%s' for writing!\n", + filespec); + exit(1); + } else if (verbose) + fprintf( stderr, "Opened '%s' for writing\n", + filespec); + } + + /******* I might need to read some input to find picture size ********/ + /* start DSC header on output */ + dsc_head1(); + + /* pass input DSC lines to output, get BoundingBox spec if there */ + got_bb = dsc_infile( ps_bb); + + /**** decide the input image bounding box ****/ + if (!got_bb && !imagespec) + { imagespec = DefaultImage; + if (verbose) + fprintf( stderr, + "Using default input image of %s\n", + imagespec); + } + if (imagespec) + box_convert( imagespec, imagebb); + else + { int i; + for (i=0; i<4; i++) + imagebb[i] = ps_bb[i]; + } + + if (verbose > 1) + fprintf( stderr, " Input image is: [%g,%g,%g,%g]\n", + imagebb[0], imagebb[1], imagebb[2], imagebb[3]); + + if (imagebb[2]-imagebb[0] <= 0.0 || imagebb[3]-imagebb[1] <= 0.0) + { fprintf( stderr, "Input image should have positive size!\n"); + exit(1); + } + + + /*** decide on the scale factor and poster size ***/ + postersize( scalespec, posterspec); + + if (verbose > 1) + fprintf( stderr, " Output image is: [%g,%g,%g,%g]\n", + posterbb[0], posterbb[1], posterbb[2], posterbb[3]); + + + dsc_head2(); + + printposter(); + + if ( need_remove ) + remove( infile ); + + exit (0); +} + +static void addpages( int **page_array, int p1, int p2, int n, int *size ) +{ + int i; + + while ( p2-p1+1+n > *size ) + { + *size += 100; + *page_array = ( int* )realloc( *page_array, sizeof( int ) * ( *size ) ); + } + for ( i=n+p2-p1; i>=n; i-- ) + ( *page_array )[ i ] = i+p1-n; +} + +static void do_fake_mode( void ) +{ + if ( !imagespec ) + imagespec = posterspec; + box_convert( imagespec, imagebb ); + + postersize( scalespec, posterspec ); + + fprintf( stderr, "%d %d %d %g %g %g %g %g %g %g %g %g\n", nrows, ncols, rotate, mediasize[ 2 ], mediasize[ 3 ], + cutmargin[ 0 ], cutmargin[ 1 ], posterbb[ 0 ], posterbb[ 1 ], posterbb[ 2 ], posterbb[ 3 ], scale ); + + exit( 0 ); +} + +static int parsepagespec( int **page_array, int *len, int *size, char *pagespec ) +{ + char *c = pagespec, *r = NULL; + int p1, p2; + + if ( *page_array != NULL ) + return 1; + + *size = 100; + *len = 0; + *page_array = ( int* )malloc( sizeof( int ) * ( *size ) ); + + while ( *c != '\0' ) + { + p1 = p2 = 0; + p1 = ( int )strtol( c, &r, 10 ); + if ( *r == '\0' || *r == ',' ) + p2 = p1; + else if ( *r == '-' ) + { + c = r+1; + p2 = ( int )strtol( c, &r, 10 ); + if ( *r != '\0' && *r != ',' ) + goto error; + } + else + goto error; + if ( p1 > 0 && p2 > 0 && p2 >= p1 ) + { + addpages( page_array, p1, p2, *len, size ); + *len += ( p2-p1+1 ); + } + else + goto error; + if ( *r == '\0' ) + break; + c = r+1; + } + + return 1; + +error: + free( *page_array ); + *size = 0; + return 0; +} + +static char* tmpinfile() +{ + char filename[ 256 ] = {0}; + int fd = -1; + + if ( getenv( "TEMP" ) == NULL ) + strcat( filename, "/tmp" ); + else + strcat( filename, getenv( "TEMP" ) ); + strcat( filename, "/poster.XXXXXX" ); + + fd = mkstemp( filename ); + if ( fd == -1 ) + { + fprintf( stderr, "Cannot create temporary file.\n" ); + exit( 1 ); + } + else + { + char buffer[ 4096 ]; + int n; + + do + { + n = fread( buffer, sizeof( char ), 4096, stdin ); + if ( n > 0 ) + write( fd, buffer, n ); + } while ( n == 4096 ); + + close( fd ); + return strdup( filename ); + } +} + +static void usage() +{ + fprintf( stderr, "Usage: %s infile\n\n", myname); + fprintf( stderr, "options are:\n"); + fprintf( stderr, " -v: be verbose\n"); + fprintf( stderr, " -f: ask manual feed on plotting/printing device\n"); + fprintf( stderr, " -i: specify input image size\n"); + fprintf( stderr, " -c: horizontal and vertical cutmargin\n"); + fprintf( stderr, " -w: horizontal and vertical additional white margin\n"); + fprintf( stderr, " -m: media paper size\n"); + fprintf( stderr, " -p: output poster size\n"); + fprintf( stderr, " -s: linear scale factor for poster\n"); + fprintf( stderr, " -P: comma-separated list of tile pages to print\n" ); + fprintf( stderr, " -o: output redirection to named file\n\n"); + fprintf( stderr, " At least one of -s -p -m is mandatory, and don't give both -s and -p\n"); + fprintf( stderr, " is like 'A4', '3x3letter', '10x25cm', '200x200+10,10p'\n"); + fprintf( stderr, " is either a simple or %%. Page lists are comma-\n" ); + fprintf( stderr, " separated, each element being a single page or a page range.\n" ); + fprintf( stderr, " (ex: 1,2-5,8,10-34)\n\n"); + + fprintf( stderr, " Defaults are: '-m%s', '-c%s', '-i' read from input file.\n", + DefaultMedia, DefaultCutMargin); + fprintf( stderr, " and output written to stdout.\n"); + + exit(1); +} + +#define exch( x, y) {double h; h=x; x=y; y=h;} + +static void postersize( char *scalespec, char *posterspec) +{ /* exactly one the arguments is NULL ! */ + /* media and image sizes are fixed already */ + + int nx0, ny0, nx1, ny1; + double sizex, sizey; /* size of the scaled image in ps units */ + double drawablex, drawabley; /* effective drawable size of media */ + double mediax, mediay; + double tmpposter[4]; + + /* available drawing area per sheet: */ + drawablex = mediasize[2] - 2.0*cutmargin[0]; + drawabley = mediasize[3] - 2.0*cutmargin[1]; + + /*** decide on number of pages ***/ + if (scalespec) + { /* user specified scale factor */ + scale = atof( scalespec); + if (scale < 0.01 || scale > 1.0e6) + { fprintf( stderr, "Illegal scale value %s!\n", scalespec); + exit(1); + } + sizex = (imagebb[2] - imagebb[0]) * scale + 2*whitemargin[0]; + sizey = (imagebb[3] - imagebb[1]) * scale + 2*whitemargin[1]; + + /* without rotation */ + nx0 = ceil( sizex / drawablex); + ny0 = ceil( sizey / drawabley); + + /* with rotation */ + nx1 = ceil( sizex / drawabley); + ny1 = ceil( sizey / drawablex); + + } else + { /* user specified output size */ + box_convert( posterspec, tmpposter); + if (tmpposter[0]!=0.0 || tmpposter[1]!=0.0) + { fprintf( stderr, "Poster lower-left coordinates are assumed 0!\n"); + tmpposter[0] = tmpposter[1] = 0.0; + } + if (tmpposter[2]-tmpposter[0] <= 0.0 || tmpposter[3]-tmpposter[1] <= 0.0) + { fprintf( stderr, "Poster should have positive size!\n"); + exit(1); + } + + if ((tmpposter[3]-tmpposter[1]) < (tmpposter[2]-tmpposter[0])) + { /* hmmm... landscape spec, change to portrait for now */ + exch( tmpposter[0], tmpposter[1]); + exch( tmpposter[2], tmpposter[3]); + } + + + /* Should we tilt the poster to landscape style? */ + if ((imagebb[3] - imagebb[1]) < (imagebb[2] - imagebb[0])) + { /* image has landscape format ==> make landscape poster */ + exch( tmpposter[0], tmpposter[1]); + exch( tmpposter[2], tmpposter[3]); + } + + /* without rotation */ /* assuming tmpposter[0],[1] = 0,0 */ + nx0 = ceil( 0.95 * tmpposter[2] / mediasize[2]); + ny0 = ceil( 0.95 * tmpposter[3] / mediasize[3]); + + /* with rotation */ + nx1 = ceil( 0.95 * tmpposter[2] / mediasize[3]); + ny1 = ceil( 0.95 * tmpposter[3] / mediasize[2]); + /* (rotation is considered as media versus image, which is totally */ + /* independent of the portrait or landscape style of the final poster) */ + } + + /* decide for rotation to get the minimum page count */ + rotate = nx0*ny0 > nx1*ny1; + + ncols = rotate ? nx1 : nx0; + nrows = rotate ? ny1 : ny0; + + if (verbose) + fprintf( stderr, + "Deciding for %d column%s and %d row%s of %s pages.\n", + ncols, (ncols==1)?"":"s", nrows, (nrows==1)?"":"s", + rotate?"landscape":"portrait"); + + if (nrows * ncols > 400) + { fprintf( stderr, "However %dx%d pages seems ridiculous to me!\n", + ncols, nrows); + exit(1); + } + + mediax = ncols * (rotate ? drawabley : drawablex); + mediay = nrows * (rotate ? drawablex : drawabley); + + if (!scalespec) /* no scaling number given by user */ + { double scalex, scaley; + scalex = (mediax - 2*whitemargin[0]) / (imagebb[2] - imagebb[0]); + scaley = (mediay - 2*whitemargin[1]) / (imagebb[3] - imagebb[1]); + //scalex = (tmpposter[ 2 ]-tmpposter[ 0 ]) / (imagebb[2] - imagebb[0]); + //scaley = (tmpposter[ 3 ]-tmpposter[ 1 ]) / (imagebb[3] - imagebb[1]); + scale = (scalex < scaley) ? scalex : scaley; + + if (verbose) + fprintf( stderr, + "Deciding for a scale factor of %g\n", scale); + sizex = scale * (imagebb[2] - imagebb[0]); + sizey = scale * (imagebb[3] - imagebb[1]); + } + + /* set poster size as if it were a continuous surface without margins */ + posterbb[0] = (mediax - sizex) / 2.0; /* center picture on paper */ + posterbb[1] = (mediay - sizey) / 2.0; /* center picture on paper */ + posterbb[2] = posterbb[0] + sizex; + posterbb[3] = posterbb[1] + sizey; + +} + +static void margin_convert( char *spec, double margin[2]) +{ double x; + int i, n; + + if (1==sscanf( spec, "%lf%n", &x, &n) && x==0.0 && n==strlen(spec)) + { /* margin spec of 0, dont bother about a otherwise mandatory unit */ + margin[0] = margin[1] = 0.0; + } else if (spec[ strlen( spec) - 1] == '%') + { /* margin relative to media size */ + if (1 != sscanf( spec, "%lf%%", &x)) + { fprintf( stderr, "Illegal margin specification!\n"); + exit( 1); + } + margin[0] = 0.01 * x * mediasize[2]; + margin[1] = 0.01 * x * mediasize[3]; + } else + { /* absolute margin value */ + double marg[4]; + box_convert( spec, marg); + margin[0] = marg[2]; + margin[1] = marg[3]; + } + + for (i=0; i<2; i++) + { if (margin[i] < 0 || 2.0*margin[i] >= mediasize[i+2]) + { fprintf( stderr, "Margin value '%s' out of range!\n", + spec); + exit(1); + } + } +} + +static void box_convert( char *boxspec, double psbox[4]) +{ /* convert user textual box spec into numbers in ps units */ + /* box = [fixed x fixed][+ fixed , fixed] unit */ + /* fixed = digits [ . digits] */ + /* unit = medianame | i | cm | mm | m | p */ + + double mx, my, ox, oy, ux, uy; + int n, r, i, l, inx; + char *spec; + + mx = my = 1.0; + ox = oy = 0.0; + + spec = boxspec; + /* read 'fixed x fixed' */ + if (isdigit( spec[0])) + { r = sscanf( spec, "%lfx%lf%n", &mx, &my, &n); + if (r != 2) + { r = sscanf( spec, "%lf*%lf%n", &mx, &my, &n); + if (r != 2) boxerr( boxspec); + } + spec += n; + } + + /* read '+ fixed , fixed' */ + if (1 < (r = sscanf( spec, "+%lf,%lf%n", &ox, &oy, &n))) + { if (r != 2) boxerr( boxspec); + spec += n; + } + + /* read unit */ + l = strlen( spec); + for (n=i=0; mediatable[i][0]; i++) + { if (!mystrncasecmp( mediatable[i][0], spec, l)) + { /* found */ + n++; + inx = i; + if (l == strlen( mediatable[i][0])) + { /* match is exact */ + n = 1; + break; + } + } + } + if (!n) boxerr( boxspec); + if (n>1) + { fprintf( stderr, "Your box spec '%s' is not unique! (give more chars)\n", + spec); + exit(1); + } + sscanf( mediatable[inx][1], "%lf,%lf", &ux, &uy); + + psbox[0] = ox * ux; + psbox[1] = oy * uy; + psbox[2] = mx * ux; + psbox[3] = my * uy; + + if (verbose > 1) + fprintf( stderr, " Box_convert: '%s' into [%g,%g,%g,%g]\n", + boxspec, psbox[0], psbox[1], psbox[2], psbox[3]); + + for (i=0; i<2; i++) + { if (psbox[i] < 0.0 || psbox[i+2] < psbox[i]) + { fprintf( stderr, "Your specification `%s' leads to " + "negative values!\n", boxspec); + exit(1); + } + } +} + +static void boxerr( char *spec) +{ int i; + + fprintf( stderr, "I don't understand your box specification `%s'!\n", + spec); + + fprintf( stderr, "The proper format is: ([text] meaning optional text)\n"); + fprintf( stderr, " [multiplier][offset]unit\n"); + fprintf( stderr, " with multiplier: numberxnumber\n"); + fprintf( stderr, " with offset: +number,number\n"); + fprintf( stderr, " with unit one of:"); + + for (i=0; mediatable[i][0]; i++) + fprintf( stderr, "%c%-10s", (i%7)?' ':'\n', mediatable[i][0]); + fprintf( stderr, "\nYou can use a shorthand for these unit names,\n" + "provided it resolves unique.\n"); + exit( 1); +} + +/*********************************************/ +/* output first part of DSC header */ +/*********************************************/ +static void dsc_head1() +{ + printf ("%%!PS-Adobe-3.0\n"); + printf ("%%%%Creator: %s\n", myname); +} + +/*********************************************/ +/* pass some DSC info from the infile in the new DSC header */ +/* such as document fonts and */ +/* extract BoundingBox info from the PS file */ +/*********************************************/ +static int dsc_infile( double ps_bb[4]) +{ + char *c, buf[BUFSIZE]; + int gotall, atend, level, dsc_cont, inbody, got_bb, n; + + if (freopen (infile, "r", stdin) == NULL) { + fprintf (stderr, "%s: fail to open file '%s'!\n", + myname, infile); + exit (1); + } + + got_bb = 0; + dsc_cont = inbody = gotall = level = atend = 0; + while (!gotall && (fgets(buf, BUFSIZE, stdin) != NULL)) + /*while (!gotall && (gets(buf) != NULL))*/ + { + n = strlen( buf ); + if ( buf[ n-1 ] == '\n' ) + buf[ n-1 ] = 0; + + if (buf[0] != '%') + { dsc_cont = 0; + if (!inbody) inbody = 1; + if (!atend) gotall = 1; + continue; + } + + if (!strncmp( buf, "%%+",3) && dsc_cont) + { puts( buf); + continue; + } + + dsc_cont = 0; + if (!strncmp( buf, "%%EndComments", 13)) + { inbody = 1; + if (!atend) gotall = 1; + } + else if (!strncmp( buf, "%%BeginDocument", 15) || + !strncmp( buf, "%%BeginData", 11)) level++; + else if (!strncmp( buf, "%%EndDocument", 13) || + !strncmp( buf, "%%EndData", 9)) level--; + else if (!strncmp( buf, "%%Trailer", 9) && level == 0) + inbody = 2; + else if (!strncmp( buf, "%%BoundingBox:", 14) && + inbody!=1 && !level) + { for (c=buf+14; *c==' ' || *c=='\t'; c++); + if (!strncmp( c, "(atend)", 7)) atend = 1; + else + { sscanf( c, "%lf %lf %lf %lf", + ps_bb, ps_bb+1, ps_bb+2, ps_bb+3); + got_bb = 1; + } + } + else if (!strncmp( buf, "%%Document", 10) && + inbody!=1 && !level) /* several kinds of doc props */ + { for (c=buf+10; *c && *c!=' ' && *c!='\t'; c++); + for (; *c==' ' || *c=='\t'; c++); + if (!strncmp( c, "(atend)", 7)) atend = 1; + else + { /* pass this DSC to output */ + puts( buf); + dsc_cont = 1; + } + } + else if ( !strncmp( buf, "%%Pages:", 8 ) ) + { + int n; + if ( sscanf( buf+8, "%d", &n ) == 1 ) + number_pages = n; + } + } + return got_bb; +} + +/*********************************************/ +/* output last part of DSC header */ +/*********************************************/ +static void dsc_head2() +{ + if ( pages == NULL ) + printf ("%%%%Pages: %d\n", nrows*ncols*number_pages); + else + printf ("%%%%Pages: %d\n", pages_length*number_pages); + +#ifndef Gv_gs_orientbug + printf ("%%%%Orientation: %s\n", rotate?"Landscape":"Portrait"); +#endif + printf ("%%%%DocumentMedia: %s %d %d 0 white ()\n", + mediaspec, (int)(mediasize[2]), (int)(mediasize[3])); + printf ("%%%%BoundingBox: 0 0 %d %d\n", (int)(mediasize[2]), (int)(mediasize[3])); + printf ("%%%%EndComments\n\n"); + + printf ("%% Print poster %s in %dx%d tiles with %.3g magnification\n", + infile, nrows, ncols, scale); +} + +/*********************************************/ +/* output the poster, create tiles if needed */ +/*********************************************/ +static void printposter() +{ + int row, col, page; + + printprolog(); + if ( pages == NULL ) + for ( page = 0; page < number_pages; page++ ) + for (row = 1; row <= nrows; row++) + for (col = 1; col <= ncols; col++) + tile( row, col, page); + else + for ( page = 0; page < number_pages; page++ ) + for ( row = 0; row < pages_length; row++ ) + { + int p = pages[ row ]-1; + if ( p+1 > nrows*ncols ) + fprintf( stderr, "Warning: page index out of range: %d\n", p+1 ); + tile( p/ncols+1, p%ncols+1, page ); + } + printf ("%%%%EOF\n"); + + if (tail_cntl_D) + { printf("%c", 0x4); + } +} + +/*******************************************************/ +/* output PS prolog of the scaling and tiling routines */ +/*******************************************************/ +static void printprolog() +{ + printf( "%%%%BeginProlog\n"); + + printf( "/cutmark %% - cutmark -\n" + "{ %% draw cutline\n" + " 0.23 setlinewidth 0 setgray\n" + " clipmargin\n" + " dup 0 moveto\n" + " dup neg leftmargin add 0 rlineto stroke\n" + " %% draw sheet alignment mark\n" + " dup dup neg moveto\n" + " dup 0 rlineto\n" + " dup dup lineto\n" + " 0 rlineto\n" + " closepath fill\n" + "} bind def\n\n"); + + printf( "%% usage: row col tileprolog ps-code tilepilog\n" + "%% these procedures output the tile specified by row & col\n" + "/tileprolog\n" + "{ %%def\n" + " gsave\n" + " leftmargin botmargin translate\n" + " do_turn {exch} if\n" + " /colcount exch def\n" + " /rowcount exch def\n" + " %% clip page contents\n" + " clipmargin neg dup moveto\n" + " pagewidth clipmargin 2 mul add 0 rlineto\n" + " 0 pageheight clipmargin 2 mul add rlineto\n" + " pagewidth clipmargin 2 mul add neg 0 rlineto\n" + " closepath clip\n" + " %% set page contents transformation\n" + " do_turn\n" + " { pagewidth 0 translate\n" + " 90 rotate\n" + " } if\n" + " pagewidth colcount 1 sub mul neg\n" + " pageheight rowcount 1 sub mul neg\n" + " do_turn {exch} if\n" + " translate\n" + " posterxl posteryb translate\n" + " sfactor dup scale\n" + " imagexl neg imageyb neg translate\n" + " tiledict begin\n" + " 0 setgray 0 setlinecap 1 setlinewidth\n" + " 0 setlinejoin 10 setmiterlimit [] 0 setdash newpath\n" + "} bind def\n\n"); + + printf( "/tileepilog\n" + "{ end %% of tiledict\n" + " grestore\n" + " %% print the cutmarks\n" + " gsave\n" + " leftmargin botmargin translate\n" + " pagewidth pageheight translate cutmark 90 rotate cutmark\n" + " 0 pagewidth translate cutmark 90 rotate cutmark\n" + " 0 pageheight translate cutmark 90 rotate cutmark\n" + " 0 pagewidth translate cutmark 90 rotate cutmark\n" + " grestore\n" + " %% print the page label\n" + " 0 setgray\n" + " leftmargin clipmargin 3 mul add clipmargin labelsize add neg botmargin add moveto\n" + " (Grid \\( ) show\n" + " rowcount strg cvs show\n" + " ( , ) show\n" + " colcount strg cvs show\n" + " ( \\)) show\n" + " showpage\n" + "} bind def\n\n"); + + printf( "%%%%EndProlog\n\n"); + printf( "%%%%BeginSetup\n"); + printf( "%% Try to inform the printer about the desired media size:\n" + "/setpagedevice where %% level-2 page commands available...\n" + "{ pop %% ignore where found\n" + " 3 dict dup /PageSize [ %d %d ] put\n" + " dup /Duplex false put\n%s" + " setpagedevice\n" + "} if\n", + (int)(mediasize[2]), (int)(mediasize[3]), + manualfeed?" dup /ManualFeed true put\n":""); + + printf( "/sfactor %.10f def\n" + "/leftmargin %d def\n" + "/botmargin %d def\n" + "/pagewidth %d def\n" + "/pageheight %d def\n" + "/imagexl %d def\n" + "/imageyb %d def\n" + "/posterxl %d def\n" + "/posteryb %d def\n" + "/do_turn %s def\n" + "/strg 10 string def\n" + "/clipmargin 6 def\n" + "/labelsize 9 def\n" + "/tiledict 250 dict def\n" + "tiledict begin\n" + "%% delay users showpage until cropmark is printed.\n" + "/showpage {} def\n" + "end\n", + scale, (int)(cutmargin[0]), (int)(cutmargin[1]), + (int)(mediasize[2]-2.0*cutmargin[0]), (int)(mediasize[3]-2.0*cutmargin[1]), + (int)imagebb[0], (int)imagebb[1], (int)posterbb[0], (int)posterbb[1], + rotate?"true":"false"); + + printf( "/Helvetica findfont labelsize scalefont setfont\n"); + + printf( "%%%%EndSetup\n"); +} + +/*****************************/ +/* output one tile at a time */ +/*****************************/ +static void tile ( int row, int col, int pagetoprint) +{ + static int page=1; + + if (verbose) fprintf( stderr, "print page %d\n", page); + + printf ("\n%%%%Page: (%d,%d) %d\n", pagetoprint+1, ((row-1)*ncols+col), page); + printf ("%d %d tileprolog\n", row, col); + printf ("%%%%BeginDocument: %s\n", infile); + printfile (pagetoprint); + printf ("\n%%%%EndDocument\n"); + printf ("tileepilog\n"); + + page++; +} + +/******************************/ +/* copy the PS file to output */ +/******************************/ +static void printfile (int pagetoprint) +{ + /* use a double line buffer, so that when I print */ + /* a line, I know whether it is the last or not */ + /* I surely dont want to print a 'cntl_D' on the last line */ + /* The double buffer removes the need to scan each line for each page*/ + /* Furthermore allows cntl_D within binary transmissions */ + + char buf[2][BUFSIZE]; + int bp; + char *c; + int currentpage = -1; + + if (freopen (infile, "r", stdin) == NULL) { + fprintf (stderr, "%s: fail to open file '%s'!\n", + myname, infile); + printf ("/systemdict /showpage get exec\n"); + printf ("%%%%EOF\n"); + exit (1); + } + + /* fill first buffer for the first time */ + fgets( buf[bp=0], BUFSIZE, stdin); + + /* read subsequent lines by rotating the buffers */ + while (fgets(buf[1-bp], BUFSIZE, stdin)) + { + if ( !strncmp( buf[ bp ], "%%Page:", 7 ) ) + currentpage++; + + /* print line from the previous fgets */ + /* do not print postscript comment lines: those (DSC) lines */ + /* sometimes disturb proper previewing of the result with ghostview */ + if (buf[bp][0] != '%' && ( currentpage == -1 || currentpage == pagetoprint )) + fputs( buf[bp], stdout); + bp = 1-bp; + } + + /* print buf from last successfull fgets, after removing cntlD */ + for (c=buf[bp]; *c && *c != '\04'; c++); + if (*c == '\04') + { tail_cntl_D = 1; + *c = '\0'; + } + if (buf[bp][0] != '%' && strlen( buf[bp])) + fputs( buf[bp], stdout); +} + +static int mystrncasecmp( const char *s1, const char *s2, int n) +{ /* compare case-insensitive s1 and s2 for at most n chars */ + /* return 0 if equal. */ + /* Although standard available on some machines, */ + /* this function seems not everywhere around... */ + + char c1, c2; + int i; + + if (!s1) s1 = ""; + if (!s2) s2 = ""; + + for (i=0; i Tue, 28 Dec 2021 00:55:22 +0200 + +poster (1:20050907-2) unstable; urgency=medium + + * Moved all prior changes to quilt patch all-changes-to-1.1.patch + * Bug Fix FTCBFS: (Closes: #884390), thanks to Helmut Grohne + for the report and the patch. + + Let dh_auto_build pass cross compilers to make. + + Make gcc substitutable. + + Do not strip during make install. + * Bug fix: "Manual for -P is wrong", thanks to Ole Tange + (Closes: #485924). + + -- Peter S Galbraith Tue, 19 May 2020 21:23:26 -0400 + +poster (1:20050907-1.1) unstable; urgency=medium + + * Non-maintainer upload. + * Bumped DH level to 10. (Closes: #817627) + * debian/compat: created. + * debian/control: + - Added the ${misc:Depends} variable. + - Added the Homepage field. + - Bumped Standards-Version to 3.9.8. + - Removed the Section and Priority fields from binary block. + + -- Joao Eriberto Mota Filho Wed, 12 Oct 2016 23:12:23 -0300 + +poster (1:20050907-1) unstable; urgency=low + + [ Daniel Hermann ] + * New upstream version introducing command line options necessary for + kdeprint (Closes: #379378, #379422, #464096) + * reapplying patches that previously fixed #255718, #323535 + * not applying patch that previously fixed #339038, since it no + longer fixes the problem. Instead introducing "/setpagedevice { + pop } def" (line 968), taken from diff between 19990428 and 20050907). + * could not check #361088, test file no longer available + * multi-page poster printing may be broken to allow for non-DSC-compliant + single-page poster printing (e.g. containing "%%Page:" comments from + embedded EPS images). + + -- Peter S Galbraith Thu, 27 Mar 2008 08:57:17 -0400 + +poster (1:19990428-8) unstable; urgency=low + + * Bug fix: "poster: Lines starting with '%' stripped from output ", + thanks to Antal K for the report and the patch (Closes: #255718). + * Bug fix: "Output of poster is not the correct Postscript file", thanks + to Wojtek Zabolotny for the report and the patch (Closes: #339038). + + -- Peter S Galbraith Wed, 17 May 2006 19:54:03 -0400 + +poster (1:19990428-7) unstable; urgency=low + + * Reverting back to original version since replacement has bugs and was + abandoned upstream. Introduced epoch in version number. + * Bug fix: "'man poster' typos: "multipier", "unpractical"; and + "uncarefully", thanks to A Costa (Closes: #323535). + + -- Peter S Galbraith Thu, 6 Apr 2006 21:34:18 -0400 + +poster (20020830-3) unstable; urgency=low + + * Bug fix: "poster: FTBFS: Build dependency on libpaperg-dev", changed to + libpaper-dev thanks to Kurt Roeckx (Closes: #346402). + * Bumped Standards-Version to 3.6.2 + + -- Peter S Galbraith Tue, 17 Jan 2006 20:42:47 -0500 + +poster (20020830-2) unstable; urgency=low + + * Applied band-aid patch for scale factor with the '-s' option + contributed by Dylan Thurston (closes: #186637) + * Use libpaper patch, which somehow didn't get applied in previous + upload (closes: #188349) + * Bumped Standards-Version to 3.5.9 (okay except for optimization). + + -- Peter S Galbraith Wed, 9 Apr 2003 13:01:36 -0400 + +poster (20020830-1) unstable; urgency=low + + * New upstream release with new upstream maintainer (closes: #158795). + * debian/control: better description (closes: #149914) + * Switch to debhelper (for easier handling of DEB_BUILD_OPTIONS) + * Upgraded Standards-Version to 3.5.7 (except for optimization). + + -- Peter S Galbraith Wed, 25 Sep 2002 14:36:35 -0400 + +poster (19990428-6) unstable; urgency=low + + * Upgraded Standards-Version to 3.2.1 (Added Build-Depends) + + -- Peter S Galbraith Wed, 21 Feb 2001 13:50:51 -0500 + +poster (19990428-5) unstable; urgency=low + + * New maintainer. + + -- Peter S Galbraith Sun, 21 May 2000 23:14:14 -0400 + +poster (19990428-4) unstable; urgency=low + + * debian/{rules,postinst,prerm}: Implement the /usr/doc transition. + * debian/rules: Use -isp with dpkg-gencontrol. + + -- Antti-Juhani Kaijanaho Fri, 8 Oct 1999 00:53:12 +0300 + +poster (19990428-3) unstable; urgency=low + + * Signed the changes and dsc. + + -- Antti-Juhani Kaijanaho Thu, 1 Jul 1999 15:39:05 +0300 + +poster (19990428-2) unstable; urgency=low + + * Upgraded Standards-Version to 3.0.0.0 with necessary + changes to debian/rules and debian/changelog + + -- Antti-Juhani Kaijanaho Thu, 1 Jul 1999 15:21:34 +0300 + +poster (19990428-1) unstable; urgency=low + + * Initial release. + + -- Antti-Juhani Kaijanaho Thu, 20 May 1999 17:28:45 +0300 + + --- poster-20050907.orig/debian/compat +++ poster-20050907/debian/compat @@ -0,0 +1 @@ +10 --- poster-20050907.orig/debian/control +++ poster-20050907/debian/control @@ -0,0 +1,16 @@ +Source: poster +Maintainer: Peter S Galbraith +Section: text +Priority: optional +Build-Depends: debhelper (>= 10), libpaper-dev +Standards-Version: 3.9.8 + +Package: poster +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Create large posters out of PostScript pages + Poster takes a one-page PostScript file and scales it to a specified + size. It can tile the resulting image into multiple smaller pages + that can be pasted together to form the big poster. Poster prefers + EPS as its input although freer forms of PostScript are also + understood. --- poster-20050907.orig/debian/copyright +++ poster-20050907/debian/copyright @@ -0,0 +1,27 @@ +This package was debianized by Antti-Juhani Kaijanaho +on 1999-05-20 at the request from J.H.M Dassen (Ray). + +The original source was fetched from + ftp://ftp.ics.ele.tue.nl/pub/users/jos/poster/poster.tar.gz +and the newer version (20050907) was downloaded from + ftp://ftp.kde.org/pub/kde/printing/poster-20050907.tar.bz2 + +The program has the following copyright notice: + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this library; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +The file COPYING in the source distribution contains Version 2 of the +GNU General Public License. The same version of the license is +included in Debian systems as the file /usr/share/common-licenses/GPL . --- poster-20050907.orig/debian/patches/Bug485924.patch +++ poster-20050907/debian/patches/Bug485924.patch @@ -0,0 +1,13 @@ +Bug fix: "Manual for -P is wrong", thanks to Ole Tange +(Closes: #485924). +--- a/poster.1 ++++ b/poster.1 +@@ -128,7 +128,7 @@ + Specify which pages of the poster to print. It consists of a comma-separated + list of single pages or page ranges (using the dash). The order in which + page number appears determines the final page order in the result PostScript +-file. Page numbering starts at 1, from left to right and bottom-up. ++file. Page numbering starts at 1, from right to left and bottom-up. + .br + Examples: 1-2 or 1,3-4,7 + .TP --- poster-20050907.orig/debian/patches/Bug884390.patch +++ poster-20050907/debian/patches/Bug884390.patch @@ -0,0 +1,21 @@ +Bug Fix FTCBFS: (Closes: #884390), thanks to Helmut Grohne + for the report and the patch. +--- a/Makefile ++++ b/Makefile +@@ -8,7 +8,7 @@ + #LIBS = -lm + + poster: poster.c +- gcc $(CFLAGS) -o poster $(DEFINES) poster.c $(LIBS) ++ $(CC) $(CFLAGS) -o poster $(DEFINES) poster.c $(LIBS) + + # HPUX: cc -O -Aa -D_POSIX_SOURCE -o poster poster.c -lm + # Note that this program might trigger a stupid bug in the HPUX C library, +@@ -17,7 +17,6 @@ + # or use gcc WITH the `-fwritable-strings' option. + + install: poster +- strip poster + cp poster /usr/local/bin + cp poster.1 /usr/local/man/man1 + --- poster-20050907.orig/debian/patches/all-changes-to-1.1.patch +++ poster-20050907/debian/patches/all-changes-to-1.1.patch @@ -0,0 +1,148 @@ +All changes made to poster prior to moving to quilt patches + +--- a/Makefile ++++ b/Makefile +@@ -1,8 +1,14 @@ +-CFLAGS = -g -Wall +-#CFLAGS = -O2 -Wall ++# on Debian: ++DEFINES = -DHAVE_LIBPAPER ++CFLAGS = -O2 -g -Wall ++LIBS = -lm -lpaper ++# elsewhere ++#DEFINES = # nothing ++#CFLAGS = -g -Wall ++#LIBS = -lm + + poster: poster.c +- gcc $(CFLAGS) -o poster poster.c -lm ++ gcc $(CFLAGS) -o poster $(DEFINES) poster.c $(LIBS) + + # HPUX: cc -O -Aa -D_POSIX_SOURCE -o poster poster.c -lm + # Note that this program might trigger a stupid bug in the HPUX C library, +--- a/poster.1 ++++ b/poster.1 +@@ -75,7 +75,12 @@ + -m + Specify the desired media size to print on. See below for . + .br +-The default is set at compile time, being A4 in the standard package. ++The default is obtained from the PAPERCONF environment variable. If ++it is not set, it is read from the file whose name is in the PAPERSIZE ++environment variable. If that too is not set, the default is read ++from the file /etc/papersize. See ++.BR papersize (5) ++for a full description of the format of the config file. + .TP + -p + Specify the poster size. See below for . +@@ -142,7 +147,7 @@ + In general: + = [][] + .br +-with multipier and offset being specified optionally. ++with multiplier and offset being specified optionally. + = * + .br + = +, +@@ -188,11 +193,11 @@ + to just vector data which is essentially resolution independent), + you might have this problem. + Such pixel images are normally made to fit well to standard 300 (or 600) dpi devices. +-Scaling such a picture with an uncarefully chosen factor, ++Scaling such a picture with an carelessly chosen factor, + can easily lead to hazy edges and interference patterns on the output. + The solution is to provide \fIposter\fP with an exact scaling factor + (with the -s option), chosen as an integer. If integer scaling is +-unpractical for your purpose, ++impractical for your purpose, + choose a fractional number made from a small integer denominator (2, 3, 4). + .SS "Can I select only a small part of a given input picture?" + Yes, for this purpose you can define both the size (width and height) +@@ -295,11 +300,11 @@ + fonts. + .P + However the copy(s) of the input file included in the output, +-are stripped from all lines starting with a `%', since they tend to ++are stripped from all lines starting with a `%%', since they tend to + disturb our `ghostview' previewer and take useless space anyhow. + + .SH "SEE ALSO" +-ghostview(1) ++.BR ghostview "(1), " papersize (5) + + .SH "CONTRIBUTED BY" + .nf +--- a/poster.c ++++ b/poster.c +@@ -42,10 +42,20 @@ + # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + # Boston, MA 02111-1307, USA. + # ++# Modification for Debian by Antti-Juhani Kaijanaho ++# on 1999-05-20 ++# ++# Adaptation of version 20050907 by Daniel Hermann ++# + */ + + #define Gv_gs_orientbug 1 +-#define DefaultMedia "A4" ++#ifdef HAVE_LIBPAPER ++# include ++# define DefaultMedia (systempapername()) ++#else /* HAVE_LIBPAPER */ ++# define DefaultMedia "A4" ++#endif /* HAVE_LIBPAPER */ + #define DefaultImage "A4" + #define DefaultCutMargin "5%" + #define DefaultWhiteMargin "0" +@@ -955,6 +965,7 @@ + "tiledict begin\n" + "%% delay users showpage until cropmark is printed.\n" + "/showpage {} def\n" ++ "/setpagedevice { pop } def\n" + "end\n", + scale, (int)(cutmargin[0]), (int)(cutmargin[1]), + (int)(mediasize[2]-2.0*cutmargin[0]), (int)(mediasize[3]-2.0*cutmargin[1]), +@@ -1012,16 +1023,26 @@ + /* fill first buffer for the first time */ + fgets( buf[bp=0], BUFSIZE, stdin); + ++/* DSC comment starts with %% and has at least 1 more character. */ ++#define IS_DSC(x) ( x[0]&&x[1]&&x[2] && (x[0]=='%')&&(x[1]=='%') ) ++ + /* read subsequent lines by rotating the buffers */ + while (fgets(buf[1-bp], BUFSIZE, stdin)) + { +- if ( !strncmp( buf[ bp ], "%%Page:", 7 ) ) +- currentpage++; ++ /* We can not rely on DSC compliant input that correctly ++ uses "%%Page:" comments. Embedded figures may also have ++ such comments. So multi-page poster printing seems to be ++ broken anyway. Break it a little more in favour of ++ single-page posters until a better page separator is ++ implemented (DH). ++ */ ++ /* if ( !strncmp( buf[ bp ], "%%Page:", 7 ) ) ++ currentpage++; */ + + /* print line from the previous fgets */ + /* do not print postscript comment lines: those (DSC) lines */ + /* sometimes disturb proper previewing of the result with ghostview */ +- if (buf[bp][0] != '%' && ( currentpage == -1 || currentpage == pagetoprint )) ++ if (!IS_DSC(buf[bp]) && ( currentpage == -1 || currentpage == pagetoprint )) + fputs( buf[bp], stdout); + bp = 1-bp; + } +@@ -1032,8 +1053,9 @@ + { tail_cntl_D = 1; + *c = '\0'; + } +- if (buf[bp][0] != '%' && strlen( buf[bp])) ++ if (!IS_DSC(buf[bp]) && strlen( buf[bp])) + fputs( buf[bp], stdout); ++#undef IS_DSC + } + + static int mystrncasecmp( const char *s1, const char *s2, int n) --- poster-20050907.orig/debian/patches/series +++ poster-20050907/debian/patches/series @@ -0,0 +1,3 @@ +all-changes-to-1.1.patch +Bug884390.patch +Bug485924.patch --- poster-20050907.orig/debian/rules +++ poster-20050907/debian/rules @@ -0,0 +1,61 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# This is the debhelper compatibility version to use. +#export DH_COMPAT=4 + +ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) + CFLAGS += -g +endif + +build: build-stamp + +build-stamp: + dh_testdir + dh_auto_build + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + -$(MAKE) clean + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + install -d debian/poster/usr/bin + install poster debian/poster/usr/bin + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installdocs README + dh_installman poster.1 + dh_installchangelogs + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +build-arch: build +build-indep: build +binary: binary-indep binary-arch +.PHONY: build build-arch build-indep clean binary-indep binary-arch binary install --- poster-20050907.orig/poster.1 +++ poster-20050907/poster.1 @@ -75,7 +75,12 @@ -m Specify the desired media size to print on. See below for . .br -The default is set at compile time, being A4 in the standard package. +The default is obtained from the PAPERCONF environment variable. If +it is not set, it is read from the file whose name is in the PAPERSIZE +environment variable. If that too is not set, the default is read +from the file /etc/papersize. See +.BR papersize (5) +for a full description of the format of the config file. .TP -p Specify the poster size. See below for . @@ -123,7 +128,7 @@ Specify which pages of the poster to print. It consists of a comma-separated list of single pages or page ranges (using the dash). The order in which page number appears determines the final page order in the result PostScript -file. Page numbering starts at 1, from left to right and bottom-up. +file. Page numbering starts at 1, from right to left and bottom-up. .br Examples: 1-2 or 1,3-4,7 .TP @@ -142,7 +147,7 @@ In general: = [][] .br -with multipier and offset being specified optionally. +with multiplier and offset being specified optionally. = * .br = +, @@ -188,11 +193,11 @@ to just vector data which is essentially resolution independent), you might have this problem. Such pixel images are normally made to fit well to standard 300 (or 600) dpi devices. -Scaling such a picture with an uncarefully chosen factor, +Scaling such a picture with an carelessly chosen factor, can easily lead to hazy edges and interference patterns on the output. The solution is to provide \fIposter\fP with an exact scaling factor (with the -s option), chosen as an integer. If integer scaling is -unpractical for your purpose, +impractical for your purpose, choose a fractional number made from a small integer denominator (2, 3, 4). .SS "Can I select only a small part of a given input picture?" Yes, for this purpose you can define both the size (width and height) @@ -295,11 +300,11 @@ fonts. .P However the copy(s) of the input file included in the output, -are stripped from all lines starting with a `%', since they tend to +are stripped from all lines starting with a `%%', since they tend to disturb our `ghostview' previewer and take useless space anyhow. .SH "SEE ALSO" -ghostview(1) +.BR ghostview "(1), " papersize (5) .SH "CONTRIBUTED BY" .nf --- poster-20050907.orig/poster.c +++ poster-20050907/poster.c @@ -42,10 +42,20 @@ # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # +# Modification for Debian by Antti-Juhani Kaijanaho +# on 1999-05-20 +# +# Adaptation of version 20050907 by Daniel Hermann +# */ #define Gv_gs_orientbug 1 -#define DefaultMedia "A4" +#ifdef HAVE_LIBPAPER +# include +# define DefaultMedia (systempapername()) +#else /* HAVE_LIBPAPER */ +# define DefaultMedia "A4" +#endif /* HAVE_LIBPAPER */ #define DefaultImage "A4" #define DefaultCutMargin "5%" #define DefaultWhiteMargin "0" @@ -955,6 +965,7 @@ "tiledict begin\n" "%% delay users showpage until cropmark is printed.\n" "/showpage {} def\n" + "/setpagedevice { pop } def\n" "end\n", scale, (int)(cutmargin[0]), (int)(cutmargin[1]), (int)(mediasize[2]-2.0*cutmargin[0]), (int)(mediasize[3]-2.0*cutmargin[1]), @@ -1012,16 +1023,26 @@ /* fill first buffer for the first time */ fgets( buf[bp=0], BUFSIZE, stdin); +/* DSC comment starts with %% and has at least 1 more character. */ +#define IS_DSC(x) ( x[0]&&x[1]&&x[2] && (x[0]=='%')&&(x[1]=='%') ) + /* read subsequent lines by rotating the buffers */ while (fgets(buf[1-bp], BUFSIZE, stdin)) { - if ( !strncmp( buf[ bp ], "%%Page:", 7 ) ) - currentpage++; + /* We can not rely on DSC compliant input that correctly + uses "%%Page:" comments. Embedded figures may also have + such comments. So multi-page poster printing seems to be + broken anyway. Break it a little more in favour of + single-page posters until a better page separator is + implemented (DH). + */ + /* if ( !strncmp( buf[ bp ], "%%Page:", 7 ) ) + currentpage++; */ /* print line from the previous fgets */ /* do not print postscript comment lines: those (DSC) lines */ /* sometimes disturb proper previewing of the result with ghostview */ - if (buf[bp][0] != '%' && ( currentpage == -1 || currentpage == pagetoprint )) + if (!IS_DSC(buf[bp]) && ( currentpage == -1 || currentpage == pagetoprint )) fputs( buf[bp], stdout); bp = 1-bp; } @@ -1032,8 +1053,9 @@ { tail_cntl_D = 1; *c = '\0'; } - if (buf[bp][0] != '%' && strlen( buf[bp])) + if (!IS_DSC(buf[bp]) && strlen( buf[bp])) fputs( buf[bp], stdout); +#undef IS_DSC } static int mystrncasecmp( const char *s1, const char *s2, int n)