* tools/tiff2pdf.c: Preserve input file directory order when pages

are tagged with the same page number.
This commit is contained in:
Olivier Paquet 2014-10-20 17:52:05 +00:00
parent 9885124f1e
commit e4f269ed3f
2 changed files with 13 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2014-10-20 Olivier Paquet <olivier.paquet@gmail.com>
* tools/tiff2pdf.c: Preserve input file directory order when pages
are tagged with the same page number.
2014-08-31 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> 2014-08-31 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
* libtiff/tif_dirread.c (TIFFReadDirEntryOutputErr): Incorrect * libtiff/tif_dirread.c (TIFFReadDirEntryOutputErr): Incorrect

View File

@ -1,4 +1,4 @@
/* $Id: tiff2pdf.c,v 1.73 2013-09-20 15:35:37 faxguy Exp $ /* $Id: tiff2pdf.c,v 1.74 2014-10-20 17:52:05 olivier Exp $
* *
* tiff2pdf - converts a TIFF image to a PDF document * tiff2pdf - converts a TIFF image to a PDF document
* *
@ -1197,12 +1197,18 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){
/* /*
* This function is used by qsort to sort a T2P_PAGE* array of page structures * This function is used by qsort to sort a T2P_PAGE* array of page structures
* by page number. * by page number. If the page numbers are the same, we fall back to comparing
* directory numbers to preserve the order of the input file.
*/ */
int t2p_cmp_t2p_page(const void* e1, const void* e2){ int t2p_cmp_t2p_page(const void* e1, const void* e2){
return( ((T2P_PAGE*)e1)->page_number - ((T2P_PAGE*)e2)->page_number ); int d;
d = (int32)(((T2P_PAGE*)e1)->page_number) - (int32)(((T2P_PAGE*)e2)->page_number);
if(d == 0){
d = (int32)(((T2P_PAGE*)e1)->page_directory) - (int32)(((T2P_PAGE*)e2)->page_directory);
}
return d;
} }
/* /*