summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfaxguy <faxguy>2010-12-11 22:48:16 +0000
committerfaxguy <faxguy>2010-12-11 22:48:16 +0000
commit3f9fd8fc4a124746a9b538ab4835165e1cdc691d (patch)
tree92aea3a0682e2ee04fbbbf0b379b64d72d44e704
parentab04fd7544381f861e235ace417e61610cf8e783 (diff)
downloadlibtiff-3f9fd8fc4a124746a9b538ab4835165e1cdc691d.tar.gz
* tools/tiff2pdf.c: add fill-page option
http://bugzilla.maptools.org/show_bug.cgi?id=2051
-rw-r--r--ChangeLog5
-rw-r--r--man/tiff2pdf.15
-rw-r--r--tools/tiff2pdf.c26
3 files changed, 31 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 96cdabab..363dc24b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2010-12-11 Lee Howard <faxguy@howardsilvan.com>
+ * tools/tiff2pdf.c: add fill-page option
+ http://bugzilla.maptools.org/show_bug.cgi?id=2051
+
+2010-12-11 Lee Howard <faxguy@howardsilvan.com>
+
* libtiff/tif_dirread.c: modify warnings
http://bugzilla.maptools.org/show_bug.cgi?id=2016
diff --git a/man/tiff2pdf.1 b/man/tiff2pdf.1
index fe4baa17..c0c79894 100644
--- a/man/tiff2pdf.1
+++ b/man/tiff2pdf.1
@@ -1,4 +1,4 @@
-.\" $Id: tiff2pdf.1,v 1.6 2006-04-20 12:17:19 dron Exp $
+.\" $Id: tiff2pdf.1,v 1.6.2.1 2010-12-11 22:48:16 faxguy Exp $
.\"
.\" Copyright (c) 2003 Ross Finlayson
.\"
@@ -162,6 +162,9 @@ Set paper size, e.g.,
.BR legal ,
.BR A4 .
.TP
+.B \-F
+Cause the tiff to fill the PDF page.
+.TP
.BR \-u " [" i | m ]
Set distance unit,
.B i
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index 09ddc8d3..ee97ad0b 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -1,4 +1,4 @@
-/* $Id: tiff2pdf.c,v 1.37.2.16 2010-11-28 15:35:44 faxguy Exp $
+/* $Id: tiff2pdf.c,v 1.37.2.17 2010-12-11 22:48:16 faxguy Exp $
*
* tiff2pdf - converts a TIFF image to a PDF document
*
@@ -183,6 +183,7 @@ typedef struct {
float pdf_pagelength;
float pdf_imagewidth;
float pdf_imagelength;
+ int pdf_image_fillpage; /* 0 (default: no scaling, 1:scale imagesize to pagesize */
T2P_BOX pdf_mediabox;
T2P_BOX pdf_imagebox;
uint16 pdf_majorversion;
@@ -515,6 +516,7 @@ t2p_unmapproc(thandle_t handle, tdata_t data, toff_t offset)
-l: length in units
-r: 'd' for resolution default, 'o' for resolution override
-p: paper size, eg "letter", "legal", "a4"
+ -F: make the tiff fill the PDF page
-f: set pdf "fit window" user preference
-b: set PDF "Interpolate" user preference
-e: date, overrides image or current date/time default, YYYYMMDDHHMMSS
@@ -569,7 +571,7 @@ int main(int argc, char** argv){
while (argv &&
(c = getopt(argc, argv,
- "o:q:u:x:y:w:l:r:p:e:c:a:t:s:k:jzndifbh")) != -1){
+ "o:q:u:x:y:w:l:r:p:e:c:a:t:s:k:jzndifbhF")) != -1){
switch (c) {
case 'o':
outfilename = optarg;
@@ -650,6 +652,9 @@ int main(int argc, char** argv){
case 'i':
t2p->pdf_colorspace_invert=1;
break;
+ case 'F':
+ t2p->pdf_image_fillpage = 1;
+ break;
case 'f':
t2p->pdf_fitwindow=1;
break;
@@ -798,6 +803,7 @@ void tiff2pdf_usage(){
" -l: length in units",
" -r: 'd' for resolution default, 'o' for resolution override",
" -p: paper size, eg \"letter\", \"legal\", \"A4\"",
+ " -F: make the tiff fill the PDF page",
" -f: set PDF \"Fit Window\" user preference",
" -e: date, overrides image or current date/time default, YYYYMMDDHHMMSS",
" -c: sets document creator, overrides image software default",
@@ -4141,6 +4147,8 @@ void t2p_compose_pdf_page(T2P* t2p){
uint32 tilelength=0;
int istiled=0;
float f=0;
+ float width_ratio=0;
+ float length_ratio=0;
t2p->pdf_xres = t2p->tiff_xres;
t2p->pdf_yres = t2p->tiff_yres;
@@ -4152,8 +4160,18 @@ void t2p_compose_pdf_page(T2P* t2p){
t2p->pdf_xres = t2p->pdf_defaultxres;
if(t2p->pdf_yres == 0.0)
t2p->pdf_yres = t2p->pdf_defaultyres;
- if (t2p->tiff_resunit != RESUNIT_CENTIMETER /* RESUNIT_NONE and */
- && t2p->tiff_resunit != RESUNIT_INCH) { /* other cases */
+ if (t2p->pdf_image_fillpage) {
+ width_ratio = t2p->pdf_defaultpagewidth/t2p->tiff_width;
+ length_ratio = t2p->pdf_defaultpagelength/t2p->tiff_length;
+ if (width_ratio < length_ratio ) {
+ t2p->pdf_imagewidth = t2p->pdf_defaultpagewidth;
+ t2p->pdf_imagelength = t2p->tiff_length * width_ratio;
+ } else {
+ t2p->pdf_imagewidth = t2p->tiff_width * length_ratio;
+ t2p->pdf_imagelength = t2p->pdf_defaultpagelength;
+ }
+ } else if (t2p->tiff_resunit != RESUNIT_CENTIMETER /* RESUNIT_NONE and */
+ && t2p->tiff_resunit != RESUNIT_INCH) { /* other cases */
t2p->pdf_imagewidth = ((float)(t2p->tiff_width))/t2p->pdf_xres;
t2p->pdf_imagelength = ((float)(t2p->tiff_length))/t2p->pdf_yres;
} else {