--- pdftk-1.12.orig/debian/rules +++ pdftk-1.12/debian/rules @@ -29,8 +29,8 @@ debian-clean: dh_testdir dh_testroot - -cd $(CURDIR)/itext-1.1 && $(MAKE) clean - -rm -f $(CURDIR)/pdftk/pdftk + -make -C pdftk -f Makefile.Debian clean + -make -C $(CURDIR)/java_libs/ clean -rm -f *-stamp install: build --- pdftk-1.12.orig/debian/changelog +++ pdftk-1.12/debian/changelog @@ -1,3 +1,88 @@ +pdftk (1.12-11) unstable; urgency=low + + * Mixing different versions of g++ and gcj does not work, explicitely + use gcj-4.1 and g++-4.1. + + -- Aurelien Jarno Sat, 20 May 2006 00:40:04 +0200 + +pdftk (1.12-10) unstable; urgency=low + + * Added -O2 to GCJFLAGS (closes: bug#366661) . + * Bumped Standards-Version to 3.7.2 (no changes). + + -- Aurelien Jarno Wed, 10 May 2006 10:56:37 +0200 + +pdftk (1.12-9) unstable; urgency=low + + * Fix previous FDF patch (closes: bug#365084). + + -- Aurelien Jarno Thu, 27 Apr 2006 23:27:01 +0200 + +pdftk (1.12-8) unstable; urgency=low + + * Added a patch to support page rotating. Thanks to David Fabel. + * Bumped Standards-Version to 3.6.2 (no changes). + + -- Aurelien Jarno Mon, 24 Apr 2006 22:03:59 +0200 + +pdftk (1.12-7) unstable; urgency=low + + * Build with -fdollars-in-identifiers to workaround a gcc bug on arm + (closes: bug#334642). + + -- Aurelien Jarno Wed, 19 Oct 2005 19:31:00 +0200 + +pdftk (1.12-6) unstable; urgency=low + + * Fixed FTBFS. + + -- Aurelien Jarno Sun, 16 Oct 2005 21:21:49 +0200 + +pdftk (1.12-5) unstable; urgency=low + + * C++ ABI transition. + + -- Aurelien Jarno Wed, 6 Jul 2005 01:03:57 +0200 + +pdftk (1.12-4) unstable; urgency=low + + * Suggests: xpdf-utils (closes: bug#306625). + + -- Aurelien Jarno Sun, 1 May 2005 11:27:28 +0200 + +pdftk (1.12-3) unstable; urgency=low + + * Depends on libgcj-dev instead of libgcj4-dev. + * Build with gcj instead of gcj-3.3. + + -- Aurelien Jarno Wed, 30 Mar 2005 16:44:02 +0200 + +pdftk (1.12-2) unstable; urgency=low + + * Added a patch from Bernhard R. Link to adds a new generate_fdf + action to generate a FDF out of a PDF file. The patch will also be + added in the next upstream version (closes: bug#289846). + + -- Aurelien Jarno Tue, 11 Jan 2005 23:22:59 +0100 + +pdftk (1.12-1) unstable; urgency=low + + * New upstream release. + + -- Aurelien Jarno Wed, 10 Nov 2004 21:04:25 +0000 + +pdftk (1.11-1) unstable; urgency=low + + * New upstream version. + + -- Aurelien Jarno Fri, 5 Nov 2004 09:42:53 +0000 + +pdftk (1.10-1) unstable; urgency=low + + * New upstream version. + + -- Aurelien Jarno Wed, 27 Oct 2004 14:15:40 +0000 + pdftk (1.00-1) unstable; urgency=low * New upstream version. --- pdftk-1.12.orig/debian/control +++ pdftk-1.12/debian/control @@ -2,12 +2,13 @@ Maintainer: Aurelien Jarno Section: text Priority: optional -Build-Depends: debhelper (>= 4.0.0), libgcj4-dev (>= 3.3.0) -Standards-Version: 3.6.1 +Build-Depends: debhelper (>= 4.0.0), gcj-4.1, g++-4.1 +Standards-Version: 3.7.2 Package: pdftk Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} +Suggests: xpdf-utils Description: A useful tool for manipulating PDF documents If PDF is electronic paper, then pdftk is an electronic stapler-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses. Pdftk is a --- pdftk-1.12.orig/debian/pdftk.1 +++ pdftk-1.12/debian/pdftk.1 @@ -44,7 +44,7 @@ .br [\fBcat\fR | \fBattach_files\fR | \fBunpack_files\fR | \fBburst\fR | .br - \fBfill_form\fR | \fBbackground\fR | + \fBfill_form\fR | \fBbackground\fR | \fBgenerate_fdf\fR .br \fBdump_data\fR | \fBdump_data_fields\fR | \fBupdate_info\fR] .br @@ -65,6 +65,8 @@ .br * Fill PDF Forms with FDF Data and/or Flatten Forms .br +* Generate FDF Data Stencil from PDF Forms +.br * Apply a Background Watermark .br * Report PDF Metrics such as Metadata and Bookmarks @@ -122,7 +124,7 @@ applying all of the output options, like encryption and compression. Available operations are: \fBcat\fR, \fBattach_files\fR, \fBunpack_files\fR, \fBburst\fR, \fBfill_form\fR, -\fBbackground\fR, \fBdump_data\fR, \fBdump_data_fields\fR, \fBupdate_info\fR. Some operations +\fBbackground\fR, \fBdump_data\fR, \fBdump_data_fields\fR, \fBgenerate_fdf\fR, \fBupdate_info\fR. Some operations takes additional arguments, described below. .RS 3 .TP @@ -243,6 +245,11 @@ Reads a single, input PDF file and reports form field statistics to the given output filename or (if no output is given) to stdout. Does not create a new PDF. .TP +.B generate_fdf +Reads a single, input PDF file and generates a FDF file suitable for \fBfill_form\fR +out of it to the given output +filename or (if no output is given) to stdout. Does not create a new PDF. +.TP .B update_info Changes the metadata stored in a single PDF's Info dictionary to match the input data file. The input data file uses the same syntax as the --- pdftk-1.12.orig/pdftk/report.h +++ pdftk-1.12/pdftk/report.h @@ -27,6 +27,9 @@ itext::PdfReader* reader_p ); void +ReportGenerateFDF(java::OutputStream* ofs_p, itext::PdfReader* reader_p ); + +void ReportOnPdf( ostream& ofs, itext::PdfReader* reader_p ); --- pdftk-1.12.orig/pdftk/Makefile.Debian +++ pdftk-1.12/pdftk/Makefile.Debian @@ -12,7 +12,7 @@ # tools TOOLPATH= -VERSUFF= -3.3 +VERSUFF=-4.1 CXX= $(TOOLPATH)g++$(VERSUFF) export GCJ= $(TOOLPATH)gcj$(VERSUFF) export GCJH= $(TOOLPATH)gcjh$(VERSUFF) @@ -23,11 +23,11 @@ # if you want pdftk to ask before overwriting a file, set # ASK_ABOUT_WARNINGS to true; otherwise: false; override this default # with the dont_ask or do_ask command-line options -CPPFLAGS= -O3 -DPATH_DELIM=0x2f -DASK_ABOUT_WARNINGS=false +CPPFLAGS= -O3 -DPATH_DELIM=0x2f -DASK_ABOUT_WARNINGS=false -fdollars-in-identifiers CXXFLAGS= -lgcj # itext compiler flags -export GCJFLAGS= +export GCJFLAGS= -O2 # export ARFLAGS= rs --- pdftk-1.12.orig/pdftk/pdftk.cc +++ pdftk-1.12/pdftk/pdftk.cc @@ -62,6 +62,7 @@ #include "com/lowagie/text/pdf/PdfEncryptor.h" #include "com/lowagie/text/pdf/PdfNameTree.h" #include "com/lowagie/text/pdf/FdfReader.h" +#include "com/lowagie/text/pdf/FdfWriter.h" #include "com/lowagie/text/pdf/AcroFields.h" #include "com/lowagie/text/pdf/PdfIndirectReference.h" #include "com/lowagie/text/pdf/PdfIndirectObject.h" @@ -294,6 +295,11 @@ strcmp( ss_copy, "datadump" )== 0 ) { return dump_data_k; } + else if( strcmp( ss_copy, "generate_fdf" )== 0 || + strcmp( ss_copy, "fdfgen" )== 0 || + strcmp( ss_copy, "fdfdump" )== 0 ) { + return generate_fdf_k; + } else if( strcmp( ss_copy, "dump_data_fields" )== 0 ) { return dump_data_fields_k; } @@ -438,7 +444,7 @@ TK_Session::is_valid() const { return( m_valid_b && - ( m_operation== dump_data_k || m_operation== dump_data_fields_k || m_authorized_b ) && + ( m_operation== dump_data_k || m_operation== dump_data_fields_k || generate_fdf_k || m_authorized_b ) && !m_input_pdf.empty() && m_input_pdf_readers_opened_b && @@ -454,6 +460,7 @@ ( m_operation== burst_k || m_operation== dump_data_k || m_operation== dump_data_fields_k || + m_operation== generate_fdf_k || m_operation== unpack_files_k || !m_output_filename.empty() ) ); } @@ -520,6 +527,9 @@ case dump_data_fields_k: cout << " dump_data_fields - Report form field data on a single, input PDF." << endl; break; + case generate_fdf_k: + cout << " generate_fdf_k - Generate a dummy FDF file from a PDF." << endl; + break; case unpack_files_k: cout << " unpack_files - Copy PDF file attachments into given directory." << endl; break; @@ -805,6 +815,10 @@ m_operation= dump_data_fields_k; arg_state= output_e; } + else if( arg_keyword== generate_fdf_k ) { + m_operation= generate_fdf_k; + arg_state= output_e; + } else if( arg_keyword== fill_form_k ) { m_operation= filter_k; arg_state= form_data_filename_e; // look for an FDF filename @@ -1047,6 +1061,10 @@ if( hyphen_loc ) *hyphen_loc= 0; + //DF declare rotate vars + PageRotate page_rotate= NORTH; + PageRotateAbsolute page_rotate_absolute= false; + //// // start of page range @@ -1054,9 +1072,55 @@ for( ; argv[ii][jj] && isdigit(argv[ii][jj]); ++jj ) { page_num_beg= page_num_beg* 10+ argv[ii][jj]- '0'; } + + // DF detect rotate arg + switch( argv[ii][jj] ) { + case 'N': + page_rotate= NORTH; // rotate 0 + page_rotate_absolute= true; + ++jj; + break; + + case 'W': + page_rotate= WEST; // rotate 90 + page_rotate_absolute= true; + ++jj; + break; + + case 'E': + page_rotate= EAST; // rotate 180 + page_rotate_absolute= true; + ++jj; + break; + + case 'S': + page_rotate= SOUTH; // rotate 270 + page_rotate_absolute= true; + ++jj; + break; + + case 'L': + page_rotate_absolute= false; + page_rotate= WEST; // rotate -90 + ++jj; + break; + + case 'R': + page_rotate_absolute= false; + page_rotate= EAST; // rotate +90 + ++jj; + break; + + case 'D': + page_rotate_absolute= false; + page_rotate= SOUTH; // rotate 180 + ++jj; + break; + } if( argv[ii][jj] ) { // process possible text keyword in page range start if( page_num_beg ) { // error: can't have numbers ~and~ a keyword at the beginning + cerr << "Error: Unexpected combination of digits and text in" << endl; cerr << " page range start, here: " << argv[ii] << endl; cerr << " Exiting." << endl; @@ -1121,6 +1185,51 @@ page_num_end= page_num_end* 10+ argv[ii][jj]- '0'; } + // DF detect rotate arg + switch( argv[ii][jj] ) { + case 'N': + page_rotate= NORTH; // rotate 0 + page_rotate_absolute= true; + ++jj; + break; + + case 'W': + page_rotate= WEST; // rotate 90 + page_rotate_absolute= true; + ++jj; + break; + + case 'E': + page_rotate= EAST; // rotate 180 + page_rotate_absolute= true; + ++jj; + break; + + case 'S': + page_rotate= SOUTH; // rotate 270 + page_rotate_absolute= true; + ++jj; + break; + + case 'L': + page_rotate= WEST; // rotate -90 + page_rotate_absolute= false; + ++jj; + break; + + case 'R': + page_rotate= EAST; // rotate +90 + page_rotate_absolute= false; + ++jj; + break; + + case 'D': + page_rotate= SOUTH; // rotate 180 + page_rotate_absolute= false; + ++jj; + break; + } + // trailing text while( argv[ii][jj] ) { @@ -1203,7 +1312,9 @@ } // if( it== m_input_pdf[range_pdf_index].m_readers.end() ) { + // need to create a new reader for kk + if( add_reader( &(m_input_pdf[range_pdf_index]) ) ) { m_input_pdf[range_pdf_index].m_readers.back().first.insert( kk ); } @@ -1215,7 +1326,7 @@ } // - temp_page_seq.push_back( PageRef(range_pdf_index, kk) ); + temp_page_seq.push_back( PageRef(range_pdf_index, kk, page_rotate, page_rotate_absolute) ); // DF rotate } else { // error; break later to get most feedback @@ -1397,7 +1508,7 @@ InputPdf& input_pdf= m_input_pdf[ii]; for( PageNumber jj= 1; jj<= input_pdf.m_num_pages; ++jj ) { - m_page_seq.push_back( PageRef( ii, jj ) ); + m_page_seq.push_back( PageRef( ii, jj, NORTH, false) ); // DF rotace m_input_pdf[ii].m_readers.back().first.insert( jj ); // mark our claim } } @@ -1827,7 +1938,7 @@ InputPdf& input_pdf= m_input_pdf[ it->m_input_pdf_index ]; if( m_verbose_reporting_b ) { - cout << " Adding page " << it->m_page_num; + cout << " Adding page " << it->m_page_num << " X" << it->m_page_rot << "X "; cout << " from " << input_pdf.m_filename << endl; } @@ -1851,11 +1962,25 @@ else if( m_output_compress_b ) { remove_mark_from_page( input_reader_p, it->m_page_num ); } - itext::PdfImportedPage* page_p= writer_p->getImportedPage( input_reader_p, it->m_page_num ); + // DF rotace + com::lowagie::text::pdf::PdfDictionary* input_dict_page= + input_reader_p->getPageN(it->m_page_num); + int page_rotation; + if (it->m_page_abs) { + page_rotation= it->m_page_rot; + } + else { + page_rotation= input_reader_p->getPageRotation(it->m_page_num) + it->m_page_rot; + } + input_dict_page->put(com::lowagie::text::pdf::PdfName::ROTATE, + new itext::PdfNumber((jint) page_rotation)); + writer_p->addPage( page_p ); + + } else { // error cerr << "Internal Error: no reader found for page: "; @@ -2181,6 +2306,7 @@ } break; + case generate_fdf_k : case dump_data_fields_k : case dump_data_k: { // report on input document @@ -2194,6 +2320,26 @@ itext::PdfReader* input_reader_p= m_input_pdf.begin()->m_readers.front().second; + if( m_operation== generate_fdf_k ) { + java::OutputStream* ofs_p= 0; + + if( m_output_filename.empty() || m_output_filename== "-" ) { + ofs_p = + ofs_p = get_output_stream( "-", + m_ask_about_warnings_b ); + } else { + ofs_p = get_output_stream( m_output_filename, + m_ask_about_warnings_b ); + } + + if( ofs_p ) { + ReportGenerateFDF( ofs_p, input_reader_p ); + } + else { // error + cerr << "Error: unable to open file for output: " << m_output_filename << endl; + } + } + else if( m_output_filename.empty() || m_output_filename== "-" ) { if( m_operation== dump_data_k ) { ReportOnPdf( cout, input_reader_p ); @@ -2336,7 +2482,7 @@ may be empty, or:\n\ [cat | attach_files | unpack_files | burst |\n\ fill_form | background |\n\ - dump_data | dump_data_fields | update_info]\n\ + dump_data | dump_data_fields | generate_fdf | update_info]\n\ \n\ For Complete Help: pdftk --help\n"; } @@ -2418,8 +2564,8 @@ sion.\n\ \n\ Available operations are: cat, attach_files,\n\ - unpack_files, burst, fill_form, background,\n\ - dump_data, dump_data_fields, update_info. Some\n\ + unpack_files, generata_fdf, fill_form, background,\n\ + dump_data, burst, dump_data_fields, update_info. Some\n\ operations takes additional arguments, described\n\ below.\n\ \n\ @@ -2429,8 +2575,9 @@ the order of the given page ranges. Page ranges\n\ are described like this:\n\ \n\ - [[-[]]]\n\ + \n\ + [[]\n\ + [-[][]]]\n\ \n\ Where the handle identifies one of the input PDF\n\ files, and the beginning and ending page numbers\n\ @@ -2441,6 +2588,17 @@ then the pages are taken from the first input\n\ PDF.\n\ \n\ + Rotation is defined absolutely\n\ + N - North (0°)\n\ + E - East (90°)\n\ + S - South (180°)\n\ + W - West (270°)\n\ +\n\ + or relative:\n\ + R - right (+90°)\n\ + L - left (-90°)\n\ + D - upsize down (+180°)\n\ +\n\ If no arguments are passed to cat, then pdftk\n\ combines all input PDFs in the order they were\n\ given to create the output.\n\ @@ -2456,11 +2614,15 @@ * The handle may be used alone to represent the\n\ entire PDF document, e.g., B1-end is the same\n\ as B.\n\ + * Ranges B1L-1, B1-1L, B1R-1L, B1L is identical\n\ \n\ Page range examples:\n\ - A1-21\n\ + A1L-21\n\ + A1-21R\n\ Bend-1odd\n\ + Bend-1Dodd\n\ A72\n\ + A72W\n\ A1-21 Beven A72\n\ \n\ attach_files \n\ @@ -2571,6 +2733,10 @@ (if no output is given) to stdout. Does not\n\ create a new PDF.\n\ \n\ + generate_fdf\n\ + Reads a single, input PDF file and generate\n\ + and generate a FDF file from it.\n\ +\n\ update_info \n\ Changes the metadata stored in a single PDF's\n\ Info dictionary to match the input data file.\n\ @@ -2692,10 +2858,15 @@ or (using wildcards):\n\ pdftk *.pdf cat output combined.pdf\n\ \n\ - Remove 'page 13' from in1.pdf to create out1.pdf\n\ - pdftk in.pdf cat 1-12 14-end output out1.pdf\n\ + Remove 'page 4' from in1.pdf to create out1.pdf and rotate\n\ + 'page 6' upsize down and 'pages 7 to end' to South\n\ + pdftk in1.pdf cat 1-3 5 6D 7S-end output out1.pdf\n\ + or:\n\ + pdftk in1.pdf cat 1-3 5 6D 7-Send output out1.pdf\n\ + or:\n\ + pdftk A=in1.pdf cat A1-3 A5 A6D A7S-end output out1.pdf\n\ or:\n\ - pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf\n\ + pdftk A=in1.pdf cat A1-3 A5 A6D A7-Send output out1.pdf\n\ \n\ Apply 40-bit encryption to output, revoking all permis-\n\ sions (the default). Set the owner PW to 'foopass'.\n\ --- pdftk-1.12.orig/pdftk/pdftk.h +++ pdftk-1.12/pdftk/pdftk.h @@ -69,6 +69,7 @@ filter_k, // apply 'filters' to a single, input PDF based on output args dump_data_k, // no PDF output dump_data_fields_k, + generate_fdf_k, unpack_files_k, // unpack files from input; no PDF output // first_operation_k= cat_k, @@ -129,13 +130,18 @@ keyword m_operation; typedef unsigned long PageNumber; - + typedef enum { NORTH= 0, EAST= 90, SOUTH= 180, WEST= 270 } PageRotate; // DF rotation + typedef bool PageRotateAbsolute; // DF absolute / relative rotation + struct PageRef { InputPdfIndex m_input_pdf_index; PageNumber m_page_num; // 1-based + PageRotate m_page_rot; // DF rotation + PageRotateAbsolute m_page_abs; //DF absolute / relative rotation - PageRef( InputPdfIndex input_pdf_index, PageNumber page_num ) : - m_input_pdf_index( input_pdf_index ), m_page_num( page_num ) {} + PageRef( InputPdfIndex input_pdf_index, PageNumber page_num, PageRotate page_rot, PageRotateAbsolute page_abs ) : + m_input_pdf_index( input_pdf_index ), m_page_num( page_num ), m_page_rot( page_rot ), m_page_abs( page_abs ) {} + }; vector< PageRef > m_page_seq; --- pdftk-1.12.orig/pdftk/report.cc +++ pdftk-1.12/pdftk/report.cc @@ -65,6 +65,7 @@ #include "com/lowagie/text/pdf/PdfEncryptor.h" #include "com/lowagie/text/pdf/PdfNameTree.h" #include "com/lowagie/text/pdf/FdfReader.h" +#include "com/lowagie/text/pdf/FdfWriter.h" #include "com/lowagie/text/pdf/AcroFields.h" #include "com/lowagie/text/pdf/PdfIndirectReference.h" #include "com/lowagie/text/pdf/PdfIndirectObject.h" @@ -909,6 +910,219 @@ return ret_val_b; } +static void +ReportGenerateFDF( itext::PdfArray* array, itext::PdfArray* kids_array_p, itext::PdfReader* reader_p ) +{ + java::ArrayList* kids_p= kids_array_p->getArrayList(); + if( kids_p ) { + for( jint kids_ii= 0; kids_ii< kids_p->size(); ++kids_ii ) { + + itext::PdfDictionary* kid_p= (itext::PdfDictionary*) + reader_p->getPdfObject( (itext::PdfDictionary*)(kids_p->get(kids_ii)) ); + if( kid_p && kid_p->isDictionary() ) { + itext::PdfDictionary* dict = new itext::PdfDictionary(); + + // field type + if( kid_p->contains( itext::PdfName::FT ) ) { + itext::PdfName* ft_p= (itext::PdfName*) + reader_p->getPdfObject( kid_p->get( itext::PdfName::FT ) ); + if( ft_p && ft_p->isName() ) { + + + if( ft_p->equals( itext::PdfName::TX ) ) { // text + } + else if( ft_p->equals( itext::PdfName::CH ) ) { // choice + } + else if( ft_p->equals( itext::PdfName::SIG ) ) { // signature + } else + continue; + } + } + + // field name; special inheritance rule: prepend parent name + if( kid_p->contains( itext::PdfName::T ) ) { + itext::PdfString* pdfs_p= (itext::PdfString*) + reader_p->getPdfObject( kid_p->get( itext::PdfName::T ) ); + if( pdfs_p ) { + dict->put( itext::PdfName::T, pdfs_p); + } + } + + // field alt. name + if( kid_p->contains( itext::PdfName::TU ) ) { + itext::PdfString* pdfs_p= (itext::PdfString*) + reader_p->getPdfObject( kid_p->get( itext::PdfName::TU ) ); + if( pdfs_p ) { + dict->put( itext::PdfName::T, pdfs_p); + } + } + + // field value; inheritable; may be string or name + if( kid_p->contains( itext::PdfName::V ) ) { + itext::PdfObject* pdfs_p= + reader_p->getPdfObject( kid_p->get( itext::PdfName::V ) ); + if( pdfs_p ) { + dict->put( itext::PdfName::V, pdfs_p); + } + } else + if( kid_p->contains( itext::PdfName::DV ) ) { + itext::PdfObject* pdfs_p= + reader_p->getPdfObject( kid_p->get( itext::PdfName::DV ) ); + if( pdfs_p ) { + dict->put( itext::PdfName::V, pdfs_p); + } + } else { + dict->put( itext::PdfName::V, new itext::PdfString(JvNewStringLatin1("\n%%EOF\n"))); + } + + // rich text value; may be a string or a stream + if( kid_p->contains( itext::PdfName::RV ) ) { + itext::PdfObject* pdfo_p= (itext::PdfObject*) + reader_p->getPdfObject( kid_p->get( itext::PdfName::RV ) ); + if( pdfo_p ) { + dict->put( itext::PdfName::RV, pdfo_p); + } + } + +/* IT would be nice to also process those somehow... + // available states + if( kid_p->contains( itext::PdfName::AP ) ) { + itext::PdfDictionary* ap_p= (itext::PdfDictionary*) + reader_p->getPdfObject( kid_p->get( itext::PdfName::AP ) ); + if( ap_p && ap_p->isDictionary() ) { + + // this is one way to cull button option names: iterate over + // appearance state names + + // N + if( ap_p->contains( itext::PdfName::N ) ) { + itext::PdfObject* n_p= + reader_p->getPdfObject( ap_p->get( itext::PdfName::N ) ); + if( n_p && n_p->isDictionary() ) { + java::Set* n_set_p= ((itext::PdfDictionary*)n_p)->getKeys(); + for( java::Iterator* it= n_set_p->iterator(); it->hasNext(); ) { + itext::PdfName* key_p= (itext::PdfName*)it->next(); + + ostringstream oss; + OutputPdfName( oss, key_p ); + acc_state.m_states.insert( oss.str() ); + } + } + } + + // D + if( ap_p->contains( itext::PdfName::D ) ) { + itext::PdfObject* n_p= + reader_p->getPdfObject( ap_p->get( itext::PdfName::D ) ); + if( n_p && n_p->isDictionary() ) { + java::Set* n_set_p= ((itext::PdfDictionary*)n_p)->getKeys(); + for( java::Iterator* it= n_set_p->iterator(); it->hasNext(); ) { + itext::PdfName* key_p= (itext::PdfName*)it->next(); + + ostringstream oss; + OutputPdfName( oss, key_p ); + acc_state.m_states.insert( oss.str() ); + } + } + } + + // R + if( ap_p->contains( itext::PdfName::R ) ) { + itext::PdfObject* n_p= + reader_p->getPdfObject( ap_p->get( itext::PdfName::N ) ); + if( n_p && n_p->isDictionary() ) { + java::Set* n_set_p= ((itext::PdfDictionary*)n_p)->getKeys(); + for( java::Iterator* it= n_set_p->iterator(); it->hasNext(); ) { + itext::PdfName* key_p= (itext::PdfName*)it->next(); + + ostringstream oss; + OutputPdfName( oss, key_p ); + acc_state.m_states.insert( oss.str() ); + } + } + } + + } + } + + // list-box / combo-box possible states + if( kid_p->contains( itext::PdfName::OPT ) ) { + itext::PdfArray* kid_opts_p= (itext::PdfArray*) + reader_p->getPdfObject( kid_p->get( itext::PdfName::OPT ) ); + if( kid_opts_p && kid_opts_p->isArray() ) { + java::ArrayList* opts_p= kid_opts_p->getArrayList(); + for( jint opts_ii= 0; opts_ii< opts_p->size(); ++opts_ii ) { + itext::PdfString* opt_p= (itext::PdfString*) + reader_p->getPdfObject( (itext::PdfObject*)(opts_p->get(opts_ii)) ); + if( opt_p && opt_p->isString() ) { + ostringstream name_oss; + OutputPdfString( name_oss, opt_p ); + acc_state.m_states.insert( name_oss.str() ); + } + } + } + } +*/ + + if( kid_p->contains( itext::PdfName::KIDS ) ) { // recurse + itext::PdfArray* kid_kids_p= (itext::PdfArray*) + reader_p->getPdfObject( kid_p->get( itext::PdfName::KIDS ) ); + if( kid_kids_p && kid_kids_p->isArray() ) { + itext::PdfArray* kida = new itext::PdfArray(); + + ReportGenerateFDF(kida, kid_kids_p, reader_p ); + + dict->put( itext::PdfName::KIDS, kida); + + } + else { // error + } + } + if( kid_p->contains( itext::PdfName::T ) ) { + itext::PdfObject* pdfo_p= (itext::PdfObject*) + reader_p->getPdfObject( kid_p->get( itext::PdfName::T ) ); + if( pdfo_p ) { + dict->put( itext::PdfName::T, pdfo_p); + } + + } + + array->add(dict); + } + } + } + else { // error + cerr << "Internal Error: unable to get ArrayList in ReportAcroFormFields()" << endl; + } +} + +void ReportGenerateFDF(java::OutputStream* ofs_p, itext::PdfReader* reader_p ) +{ + itext::PdfDictionary* catalog_p= reader_p->catalog; + if( catalog_p && catalog_p->isDictionary() ) { + itext::PdfArray* array = new itext::PdfArray(); + + itext::PdfDictionary* acro_form_p= (itext::PdfDictionary*) + reader_p->getPdfObject( catalog_p->get( itext::PdfName::ACROFORM ) ); + if( acro_form_p && acro_form_p->isDictionary() ) { + + itext::PdfArray* fields_p= (itext::PdfArray*) + reader_p->getPdfObject( acro_form_p->get( itext::PdfName::FIELDS ) ); + if( fields_p && fields_p->isArray() ) { + + // enter recursion + ReportGenerateFDF( array, fields_p, reader_p ); + } + } + itext::FdfWriter* writer = new itext::FdfWriter(); + writer->setVerbField(array); + writer->writeTo(ofs_p); + } + else { // error + cerr << "Internal Error: unable to access PDF catalog from ReportAcroFormFields()" << endl; + } +} + void ReportAcroFormFields( ostream& ofs, itext::PdfReader* reader_p ) --- pdftk-1.12.orig/java_libs/com/lowagie/text/pdf/FdfWriter.java +++ pdftk-1.12/java_libs/com/lowagie/text/pdf/FdfWriter.java @@ -62,6 +62,7 @@ public class FdfWriter { static byte[] HEADER_FDF = DocWriter.getISOBytes("%FDF-1.2\n%\u00e2\u00e3\u00cf\u00d3\n"); HashMap fields = new HashMap(); + PdfArray verbfields = null; /** The PDF file associated with the FDF. */ private String file; @@ -79,7 +80,11 @@ Wrt wrt = new Wrt(os, this); wrt.writeTo(); } - + + void setVerbField(PdfArray array) { + verbfields = array; + } + boolean setField(String field, PdfObject value) { HashMap map = fields; StringTokenizer tk = new StringTokenizer(field, "."); @@ -300,7 +305,10 @@ void writeTo() throws DocumentException, IOException { PdfDictionary dic = new PdfDictionary(); - dic.put(PdfName.FIELDS, calculate(fdf.fields)); + if( fdf.verbfields != null ) + dic.put(PdfName.FIELDS, fdf.verbfields); + else + dic.put(PdfName.FIELDS, calculate(fdf.fields)); if (fdf.file != null) dic.put(PdfName.F, new PdfString(fdf.file, PdfObject.TEXT_UNICODE)); PdfDictionary fd = new PdfDictionary(); --- pdftk-1.12.orig/java_libs/com/lowagie/text/pdf/codec/PngImage.java +++ pdftk-1.12/java_libs/com/lowagie/text/pdf/codec/PngImage.java @@ -93,7 +93,7 @@ import com.lowagie.text.ExceptionConverter; import com.lowagie.text.Image; -//SID import com.lowagie.text.ImgRaw; +import com.lowagie.text.ImgRaw; import com.lowagie.text.pdf.ByteBuffer; import com.lowagie.text.pdf.PdfArray; import com.lowagie.text.pdf.PdfDictionary; --- pdftk-1.12.orig/pdftk.1.txt +++ pdftk-1.12/pdftk.1.txt @@ -103,8 +103,9 @@ the order of the given page ranges. Page ranges are described like this: - [[-[]]] + + [[] + [-[][]]] Where the handle identifies one of the input PDF files, and the beginning and ending page numbers @@ -115,6 +116,17 @@ then the pages are taken from the first input PDF. + Rotation is either defined absolutely + N - North (0°) + E - East (90°) + S - South (180°) + W - West (270°) + + or relative: + R - right (+90°) + L - left (-90°) + D - upsize down (+180°) + If no arguments are passed to cat, then pdftk combines all input PDFs in the order they were given to create the output. @@ -133,8 +145,12 @@ Page range examples: A1-21 + A1L-21 + A1-21R Bend-1odd + Bend-1Dodd A72 + A72W A1-21 Beven A72 attach_files @@ -366,10 +382,15 @@ or (using wildcards): pdftk *.pdf cat output combined.pdf - Remove 'page 13' from in1.pdf to create out1.pdf - pdftk in.pdf cat 1-12 14-end output out1.pdf + Remove 'page 4' from in1.pdf to create out1.pdf and rotate + 'page 6' upsize down and 'pages 7 to end' to South + pdftk in1.pdf cat 1-3 5 6D 7S-end output out1.pdf + or: + pdftk in1.pdf cat 1-3 5 6D 7-Send output out1.pdf + or: + pdftk A=in1.pdf cat A1-3 A5 A6D A7S-end output out1.pdf or: - pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf + pdftk A=in1.pdf cat A1-3 A5 A6D A7-Send output out1.pdf Apply 40-bit encryption to output, revoking all permis- sions (the default). Set the owner PW to 'foopass'. --- pdftk-1.12.orig/pdftk.1.html +++ pdftk-1.12/pdftk.1.html @@ -236,8 +236,8 @@ <input PDF handle>[<begin page -number>[-<end page -number>[<qualifier>]]] +number>[<rotation>][-<end page +number>[<rotation>][<qualifier>]]] @@ -259,6 +259,60 @@ cols="2" cellspacing="0" cellpadding="0">
+Rotation is defined absolutely
+ + + +
+N - North (0°)
+ + + +
+E - East (90°)
+ + + +
+S - South (180°)
+ + + +
+W - West (270°)
+ + + +
+or relative:
+ + + +
+R - right (+90°)
+ + + +
+L - left (-90°)
+ + + +
+D - upsize down (+180°)
+ + + +
If no arguments are passed to cat, then pdftk combines all input PDFs in the order they were given to create the output.
@@ -301,13 +355,25 @@ cols="2" cellspacing="0" cellpadding="0"> +* Ranges B1L-1, B1-1L, B1R-1L, B1L is identical + + + +
Page range examples:
-A1-21
+A1L-21 + + + +
+A1-21R
@@ -319,12 +385,24 @@ cols="2" cellspacing="0" cellpadding="0">
+Bend-1Dodd
+ + + +
A72
+A72W
+ + + +
A1-21 Beven A72
-Remove 'page 13' from in1.pdf to create -out1.pdf
+Remove 'page 4' from in1.pdf to create out1.pdf +and rotate 'page 6' upsize down and 'pages 7 to end' to +South
-pdftk in.pdf cat 1-12 14-end output out1.pdf
+pdftk in1.pdf cat 1-3 5 6D 7S-end output out1.pdf
+or:
+pdftk in1.pdf cat 1-3 5 6D 7-Send output out1.pdf
+or:
+pdftk A=in1.pdf cat A1-3 A5 A6D A7S-end output +out1.pdf
or:
-pdftk A=in1.pdf cat A1-12 A14-end output +pdftk A=in1.pdf cat A1-3 A5 A6D A7-Send output out1.pdf