LaTeX-Table-v1.0.6000755000766000024 011461437604 13503 5ustar00markusstaff000000000000LaTeX-Table-v1.0.6/Build.PL000444000766000024 233711461437604 15141 0ustar00markusstaff000000000000use 5.008; use strict; use warnings; use Module::Build; my $builder = Module::Build->new( module_name => 'LaTeX::Table', license => 'perl', dist_author => '', dist_version_from => 'lib/LaTeX/Table.pm', requires => { 'perl' => '5.8.0', 'English' => 0, 'Moose' => 0.76, 'MooseX::FollowPBP' => 0.03, 'Module::Pluggable' => 0, 'Scalar::Util' => 0, 'Carp' => 0, 'version' => 0, 'Template' => 0, 'Cwd' => 0, }, build_requires => { 'Test::More' => 0, 'Test::NoWarnings' => 0, 'File::Spec' => 0, }, recommends => { 'Text::CSV' => 0, 'LaTeX::Driver' => 0, 'LaTeX::Encode' => 0, 'Getopt::Long' => 0, 'Number::Format' => 0, 'autodie' => 0, }, script_files => [ 'bin/csv2pdf', 'bin/ltpretty' ], meta_merge => { resources => { repository => 'http://github.com/lima1/p5-latex-table', }, }, add_to_cleanup => [ 'LaTeX-Table-*' ], ); $builder->create_build_script(); LaTeX-Table-v1.0.6/Changes000444000766000024 2602011461437604 15153 0ustar00markusstaff000000000000Revision history for LaTeX-Table 1.0.6 Mon Oct 25 2010 - eor option (thanks Jens) - POD: Ascii tables of classic themes. - fixed #62016 (thanks Bowen) - ltpretty ignores empty trailing lines - ltpretty test - Evanston theme (Booktabs) 1.0.5 Wed Aug 25 2010 - Set min. version of MooseX::FollowPBP to 0.03 (older versions caused cpan test fails) 1.0.4 Tue Aug 24 2010 - fixed stupid bug in Build.PL (introduced in 1.0.3) 1.0.3 Tue Aug 24 2010 - small code cleanup - added github in Makefile.PL and Build.PL - moved author tests to xt - longtable tests 1.0.2 Wed Jul 21 2010 - Support for recent Class:MOP (patch from Ansgar, Thanks!!) 1.0.1 Tue Mar 2 2010 - POD: * CPAN email address * better example for ltpretty * better explanation how to use a theme module - Bugfixes: * multicolumn shortcut for columns > 9 * ltpretty removed all slashes, not just the trailing ones * ltpretty removes now leading and trailing spaces in columns (caused problems with multicolumn shortcut) 1.0.0 Tue Sep 8 2009 - Bugfixes: * text_wrap option still generated 0.99_5 Mon Sep 7 2009 - POD cleanup - Bugfixes: * current perlcritic passes 0.99_4 Fri Sep 4 2009 - Corrected documentation for width_environment option (alignment is possible thanks to fix of #49422) 0.99_3 Fri Sep 4 2009 - added clearer for alignment options. - Bugfixes: * Alignment of longtables is wrongly generated (#49422, thanks Jens) 0.99_2 Sat Aug 10 2009 - Bugfixes: * removed unneccessary no critic (thanks Salvatore) * min Moose version in Build.PL/Makefile.PL (caused cpantesters fails) 0.99_1 Sat Aug 08 2009 - code cleanup - POD corrections - removed all deprecated code - Bugfixes: * row id in callback functions sometimes wrong * perlcritic now passes with Pod::Spelling (thanks Salvatore and Rafael) 0.9.17 Sat Jul 26 2009 - new option tablelasttail - Template variables documented in TypeI.pm - Code cleanup: * type, colums_like_header, resize, callback, fontfamily, fontsize, xentrystretch now checked via Moose * fontfamily, fontsize, table*, xentrystretch now generated via Template * csv2pdf * Removed old deprecated code from 0.1.0 and 0.8.0 (in the next release - probably 1.0 - I will remove all deprecated code!) - Bugfix: csv2pdf --out option broken 0.9.16 Mon Jul 13 2009 - API change: header_sideways was kind of unnecessary. - csv2pdf now uses templates and the longtable and ltxtable packages - Perl::Critic passes with installed Perl::Tidy (thanks Salvatore) - removed Readonly dependency (thanks Wen) 0.9.15 Fri May 29 2009 - MISSING_VALUE in coldef_strategy - width and longtable - removed deprecated feature textwrap - changed optional requirement from Text::CSV_XS to Text::CSV - csv2pdf: Meyrin default. - POD cleanups 0.9.14 Tue Feb 24 2009 - Meyrin now default theme - sideways now works also with xtab (lscape package) - longtable package - POD cleanups 0.9.13 Wed Feb 4 2009 - continued, continuedmsg options - Minor Bug fixed: maincaption required caption. - renamed *_LINES to *_RULES - RULES_CMD in themes - examples.pdf nicer 0.9.12 Fri Jan 30 2009 - fontfamily - API change: size renamed to fontsize - custom_template - themes can now define rule width and color (only global) - Muenchen, NYC3, NYC4, Redmond and Redmond2 Themes - Perl-Critic-1.094001 passes 0.9.11 Sat Jan 3 2009 - tabulary package - STUB_ALIGN in themes - POD corrections 0.9.10 Sun Nov 23 2008 - removed unnecessary blanks and spaces in LaTeX output - LaTeX output aligned - Meyrin Theme - POD corrections 0.9.9 Wed Nov 12 2008 - removed Readonly, caused cpantester fails - shortcaption - left - right - moved more code in templates - ctable now uses tabularx - NYC2 theme 0.9.8 Sat Nov 8 2008 - support for the ctable package - sideways option - star option 0.9.7 Wed Nov 5 2008 (Obama wins :)) - Switched to Moose - themes now definable as modules. - csv2pdf. Lots of new features. 0.9.6 Thu Oct 7 2008 - Bugfix: extracolsep after first column - removed Fatal dependency (which is deprecated) - Standard LONG regex now requires at least two words (thanks to salva on perlmonks) - removed color LaTeX package dependency. xcolor is enough 0.9.5 Thu Oct 2 2008 - POD corrections - new, common exception format for invalid option usage - environment must be true for xtab packages - \belowcaptionskip instead of 10pt in tablehead, caption_top - custom_tabular_environment (e.g. for mpxtabular) 0.9.4 Wed Oct 1 2008 - coldef_strategy: column types can be defined - empty rows in headers now also produce horizontal lines for consistency - now data is only analyzed once (was twice in xtab) - tableheadmsg - Bugfix: latex commands in data counted as line (problem for _MUST_MATCH_ALL) - Bugfix: columns_like_header columns always left-justified - a few more tests 0.9.3 Fri Sep 26 2008 - leading/trailing spaces in default NUMBER regex allowed - coldef_strategy: suffix _MUST_MATCH_ALL now defines whether the specified type must match all cells in a column (or at least one). - ltpretty: howtos for vim and emacs - EXTRA_ROW_HEIGHT. now NYC theme looks better - header_sideways - API change: * DEFAULT renamed to DEFAULT_COL * DEFAULT_X renamed to DEFAULT_COL_X * IS_A_NUMBER renamed to NUMBER * IS_LONG renamed to LONG and is now a regular expression Sorry, I think it is the last big change before 1.0. It was necessary because I will add the functionality to define column types (like NUMBER and LONG) and this needs a cleaner interface. - Bugfix: first column always left-justified - a few more tests 0.9.2 Thu Sep 18 2008 - POD corrections - added ltpretty. I use it in vim to format my tables with LaTeX::Table 0.9.1 Wed Aug 27 2008 - Bugfix: no midrule without header - Bugfix: calculation of column ids (callback, coldef_strategy) now supports multicolumn shortcuts - Bugfix: specified Latex commands in data (with single column arrays) counted as rows (problem for DATA_BG_COLOR_ODD/EVEN) - colums_like_header() - more tests - Paris Theme - POD corrections 0.9.0 Sat Aug 23 2008 - caption_top - themes can now define header font color and bgcolors - multicol shortcut now automatically adds vertical lines - resizebox - Bugfix: centering now only in std. - Bugfix: callback function could destroy our multicolumn shortcut - Bugfix: callback function in header only applied when HEADER_CENTERED in theme - API change: text_wrap now deprecated. tabularx produces so much nicer tables and it does not break the callback row ids. If you really think this is useful somehow, drop me a mail 0.8.0 Thu Aug 21 2008 - centering instead of center - Bugfix: callback function overwrote values in arrays - maincaption not bold in Zurich - API change: table_environment now environment, environment can be chosen, e.g. 'sidewaystable' - API change: tablepos renamed to position - API change: tabledef renamed to coldef - API change: tabledef_strategy renamed to coldef_strategy - tabularx package - default value for long col now 30 - POD updates - examples.pdf better 0.7.0 Tue Aug 19 2008 - plain theme - POD updates 0.6.3 Fri Jul 25 2008 - commands now printed without formatting - removed the simpsons synopsis - Perl::Critic passes again 0.6.2 Wed Apr 16 2008 - made new Perl::Critic happy - Bugfix: \hline in xtab/booktabs 0.6.1 Tue Mar 04 2008 - added kwalitee test - added perl 5.8 dependency - added licence in Makefile.PL - Bugfix: \hline instead of \midrule 0.6.0 Wed Nov 07 2007 - support for booktabs.sty - Zurich standard - width - regex IS_A_NUMBER compiled only once (same bug again) 0.5.2 Tue Nov 06 2007 - tests produced latextable.tex in / - replaced Regexp::Common with perlfaq4 regexes. MUCH faster now. - new theme Berlin - custom IS_A_NUMBER regex ignored - cvs2pdf: - support for themes - Berlin default (first column contains data in CSV) 0.5.1 Tue Nov 06 2007 - xtab: last page not centered when center=1 - csv2pdf: - typos in POD - --man not working - moved to directory bin - removed "continued on next page" tabletail - xentrystretch 0.001 (more rows per page) 0.5.0 Mon Nov 05 2007 - die when value in cell is undef (fixes many warnings and funny results) - tabletail should work now - added csv2pdf 0.4.0 Sat Oct 20 2007 - tabledef_strategy 0.3.0 Sat Oct 20 2007 - generate() tests data and header - themes test - pod corrections 0.2.1 Fri Oct 19 2007 - Bugfix: callback $is_header == 1 in data 0.2.0 Fri Oct 19 2007 - use Text::Wrap for wrapping lines - callback - xtab tests 0.1.1 Thu Sep 20 2007 - minor POD corrections - Bugfixes: * perlcritic optional, passes now with severity 1 0.1.0 Thu Sep 20 2007 - API CHANGE: header and data now options - label optional - caption optional - maincaption optional - custom themes can be set in new() - POD improvements - more tests - table environment optional - added examples.pdf - Bugfixes: * META.yml missing 0.0.3 Thu Mar 5 2007 - t/perlcritic.t: required Test::Perl::Critic 0.0.2 Wed Feb 28 2007 - Added missing dependencies in Build.PL - Test::Perl::Critic passed 0.0.1 Thu Aug 3 2006 Initial release. LaTeX-Table-v1.0.6/LICENSE000444000766000024 1351211461437604 14667 0ustar00markusstaff000000000000Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder as specified below. "Copyright Holder" is whoever is named in the copyright or copyrights for the package. "You" is you, if you're thinking about copying or distributing this Package. "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as uunet.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4.You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) give non-standard executables non-standard names, and clearly document the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. You may embed this Package's interpreter within an executable of yours (by linking); this shall be construed as a mere form of aggregation, provided that the complete Standard Version of the interpreter is so embedded. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whoever generated them, and may be sold commercially, and may be aggregated with this Package. If such scripts or library files are aggregated with this Package via the so-called "undump" or "unexec" methods of producing a binary executable image, then distribution of such an image shall neither be construed as a distribution of this Package nor shall it fall under the restrictions of Paragraphs 3 and 4, provided that you do not represent such an executable image as a Standard Version of this Package. 7. C subroutines (or comparably compiled subroutines in other languages) supplied by you and linked into this Package in order to emulate subroutines and variables of the language defined by this Package shall not be considered part of this Package, but are the equivalent of input as in Paragraph 6, provided these subroutines do not change the language in any way that would cause it to fail the regression tests for the language. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End LaTeX-Table-v1.0.6/Makefile.PL000444000766000024 241611461437604 15615 0ustar00markusstaff000000000000use 5.008; use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'LaTeX::Table', AUTHOR => '', VERSION_FROM => 'lib/LaTeX/Table.pm', ABSTRACT_FROM => 'lib/LaTeX/Table.pm', ((ExtUtils::MakeMaker->VERSION() gt '6.30') ? ('LICENSE' => 'perl') : ()), PL_FILES => {}, PREREQ_PM => { 'Test::More' => 0, 'Test::NoWarnings' => 0, 'File::Spec' => 0, 'English' => 0, 'Moose' => 0.76, 'MooseX::FollowPBP' => 0.03, 'Module::Pluggable' => 0, 'Carp' => 0, 'Scalar::Util' => 0, 'version' => 0, 'Template' => 0, 'Text::CSV' => 0, 'Cwd' => 0, }, ( ( ExtUtils::MakeMaker->VERSION() gt '6.46' ) ? ( META_MERGE => { resources => { repository => 'http://github.com/lima1/p5-latex-table', }, } ) : () ), EXE_FILES => [ 'bin/csv2pdf', 'bin/ltpretty' ], dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'LaTeX-Table-*' }, ); LaTeX-Table-v1.0.6/MANIFEST000444000766000024 160611461437604 14774 0ustar00markusstaff000000000000Build.PL Changes MANIFEST LICENSE META.yml Makefile.PL README TODO bin/csv2pdf bin/ltpretty examples/generate_examples.pl examples/imdbtop40.dat examples/examples.pdf lib/LaTeX/Table.pm lib/LaTeX/Table/Types/TypeI.pm lib/LaTeX/Table/Types/Ctable.pm lib/LaTeX/Table/Types/Longtable.pm lib/LaTeX/Table/Types/Std.pm lib/LaTeX/Table/Types/Xtab.pm lib/LaTeX/Table/Themes/ThemeI.pm lib/LaTeX/Table/Themes/Beamer.pm lib/LaTeX/Table/Themes/Booktabs.pm lib/LaTeX/Table/Themes/Classic.pm lib/LaTeX/Table/Themes/Modern.pm t/00.load.t t/10.table-ctable.t t/10.table-custom.t t/10.table-longtable.t t/10.table-std.t t/10.table-xtab.t t/20.mcdef.t t/30.exceptions.t t/40.miscprivates.t t/50.synopsis.t t/60.coldef.t t/70.callback.t t/80.themes.t t/90.ltpretty.t t/ltpretty.txt t/lib/MyThemes/Custom.pm xt/release/perlcritic.t xt/release/perlcriticrc xt/release/perltidyrc xt/release/pod-coverage.t xt/release/pod.t LaTeX-Table-v1.0.6/META.yml000444000766000024 341511461437604 15114 0ustar00markusstaff000000000000--- abstract: 'Perl extension for the automatic generation of LaTeX tables.' author: - '' build_requires: File::Spec: 0 Test::More: 0 Test::NoWarnings: 0 configure_requires: Module::Build: 0.36 generated_by: 'Module::Build version 0.3607' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: LaTeX-Table provides: LaTeX::Table: file: lib/LaTeX/Table.pm version: v1.0.6 LaTeX::Table::Themes::Beamer: file: lib/LaTeX/Table/Themes/Beamer.pm version: v1.0.6 LaTeX::Table::Themes::Booktabs: file: lib/LaTeX/Table/Themes/Booktabs.pm version: v1.0.6 LaTeX::Table::Themes::Classic: file: lib/LaTeX/Table/Themes/Classic.pm version: v1.0.6 LaTeX::Table::Themes::Modern: file: lib/LaTeX/Table/Themes/Modern.pm version: v1.0.6 LaTeX::Table::Themes::ThemeI: file: lib/LaTeX/Table/Themes/ThemeI.pm version: v1.0.6 LaTeX::Table::Types::Ctable: file: lib/LaTeX/Table/Types/Ctable.pm version: v1.0.6 LaTeX::Table::Types::Longtable: file: lib/LaTeX/Table/Types/Longtable.pm version: v1.0.6 LaTeX::Table::Types::Std: file: lib/LaTeX/Table/Types/Std.pm version: v1.0.6 LaTeX::Table::Types::TypeI: file: lib/LaTeX/Table/Types/TypeI.pm version: v1.0.6 LaTeX::Table::Types::Xtab: file: lib/LaTeX/Table/Types/Xtab.pm version: v1.0.6 recommends: Getopt::Long: 0 LaTeX::Driver: 0 LaTeX::Encode: 0 Number::Format: 0 Text::CSV: 0 autodie: 0 requires: Carp: 0 Cwd: 0 English: 0 Module::Pluggable: 0 Moose: 0.76 MooseX::FollowPBP: 0.03 Scalar::Util: 0 Template: 0 perl: v5.8.0 version: 0 resources: license: http://dev.perl.org/licenses/ repository: http://github.com/lima1/p5-latex-table version: v1.0.6 LaTeX-Table-v1.0.6/README000444000766000024 426511461437604 14527 0ustar00markusstaff000000000000LaTeX-Table version 1.0.6 This module supports multipage tables via the xtab and the longtable package. For publication quality tables it utilizes the booktabs package. It also supports the tabularx and tabulary packages for nicer fixed-width tables. Furthermore, it supports the colortbl package for colored tables optimized for presentations. The powerful new ctable package is supported and especially recommended when footnotes are needed. LaTeX::Table ships with some predefined, good looking themes. INSTALLATION To install this module with CPAN (recommended), just type cpan LaTeX::Table If you have never used the cpan command before, you probably have to answer a few configuration questions. This command will automatically install missing modules required by LaTeX::Table. To install this module without CPAN, run the following commands: perl Build.PL ./Build ./Build test ./Build install If you get a warning about missing modules, install them manually or use the cpan command (see above). Alternatively, to install with ExtUtils::MakeMaker, you can use the following commands: perl Makefile.PL make make test make install Now start the script generate_examples.pl in the examples directory of this distibution. perl generate_examples.pl This script generates some LaTeX files with some example tables. Now please compile these examples with LaTeX and check if all tables look ok: pdflatex examples.tex PROGRAMS This module ships with two small utilities. The first, csv2pdf is a CSV to PDF converter. It is only about 100 lines of code short and only meant as an example application, but it is already very powerful. It requires Getopt::Long, Text::CSV, LaTeX::Encode and LaTeX::Driver, which are not installed during the installation of this module. The second utility is ltpretty. It takes a lazy formatted LaTeX table from STDIN (typically piped from Vim or emacs) and outputs a completely formatted table. This makes this module not only useful for automatically generated reports, but also saves a lot of typing work in creating custom tables. DEPENDENCIES Carp Module::Pluggable Moose MooseX::FollowPBP English Scalar::Util Template LaTeX-Table-v1.0.6/TODO000444000766000024 106011461437604 14325 0ustar00markusstaff000000000000- The OO design is a real MESS. Most of it is easy to fix without breaking the API (started) - coldef_strategy is an ugly hack. This API should be redone for a 2.0 release. - nicer examples.pdf (started) - maybe move csv2pdf and ltpretty in an extra package, because they introduce dependencies. But hey, we use Moose which requires half of CPAN anyway... - fine tune default parameters - shortcut for multirows - csvpdf should support all LT options - csv2pdf should maybe use my Text::CSV::R module - ltpretty and csv2pdf should support a config file LaTeX-Table-v1.0.6/bin000755000766000024 011461437604 14253 5ustar00markusstaff000000000000LaTeX-Table-v1.0.6/bin/csv2pdf000555000766000024 1546311461437604 15736 0ustar00markusstaff000000000000#!/usr/bin/perl use strict; use warnings; use autodie qw(open close); use English qw( -no_match_vars ); use Getopt::Long; use Pod::Usage; use Carp; use Text::CSV; use File::Basename; use Cwd; use Template; use LaTeX::Table; use LaTeX::Encode; use LaTeX::Driver; use version; our $VERSION = qv('1.0.6'); my ( $infile, $outfile, $outfiletex, $help, $man, $version ); my $sep_char = q{,}; my $latex_encode = 0; my $landscape = 0; my $outputlatex = 0; my $theme = 0; my $title = 0; my $coldef = 0; my $header = 0; my $options_ok = GetOptions( 'in=s' => \$infile, 'out=s' => \$outfile, 'sep_char=s' => \$sep_char, 'latex_encode' => \$latex_encode, 'landscape' => \$landscape, 'outputlatex' => \$outputlatex, 'theme=s' => \$theme, 'title=s' => \$title, 'coldef=s' => \$coldef, 'header=s' => \$header, 'help|?' => \$help, 'version|v' => \$version, 'man' => \$man, ) or pod2usage(2); if ($version) { print "$PROGRAM_NAME $VERSION\n" or croak q{Can't print to stdout.}; exit; } if ($man) { pod2usage( -exitstatus => 0, -verbose => 2 ); } if ( $help || !defined $infile ) { pod2usage(1); } if ( !defined $outfile ) { $outfile = q{./} . fileparse( $infile, qw(csv txt dat) ) . 'pdf'; $outfiletex = fileparse( $infile, qw(csv txt dat) ) . 'tex'; } else { $outfiletex = fileparse( $outfile, qw(pdf) ) . 'tex'; } my $csv = Text::CSV->new( { binary => 1, sep_char => $sep_char, allow_whitespace => 1 } ); my @header; my @data; if ($header) { my $status = $csv->parse($header); @header = [ $csv->fields() ]; } my $line_number = 0; open my $IN, '<', $infile; while ( my $line = <$IN> ) { chomp $line; my $status = $csv->parse($line); if ( !$header && $line_number == 0 ) { @header = [ $csv->fields() ]; } else { push @data, [ $csv->fields() ]; } $line_number++; } close $IN; my $table = LaTeX::Table->new( { header => \@header, data => \@data, type => 'longtable', tabletail => q{ }, ( $theme ? ( theme => $theme ) : () ), filename => $outfiletex, center => 0, width_environment => 'tabularx', coldef => $coldef, callback => sub { my ( $row, $col, $value, $is_header ) = @_; if ($latex_encode) { return latex_encode($value); } return $value; }, } ); $table->generate; my $latex_code = create_latex_code(); if ($outputlatex) { print $latex_code or croak q{Can't print to stdout.}; } my $drv = LaTeX::Driver->new( source => \$latex_code, output => $outfile, format => 'pdf', ); my $ok = $drv->run; sub create_latex_code { my $template_obj = Template->new(); my %template_vars = ( LANDSCAPE => $landscape ? '[landscape]' : 0, TITLE => $title ? '\title{' . $title . '}' : 0, TABLECODE => '\LTXtable{\textwidth}{' . getcwd() . q{/} . $outfiletex . '}', ); my $template = << 'EOT' \documentclass[%IF LANDSCAPE %][% LANDSCAPE %][% END %]{article} [% IF LANDSCAPE %]\usepackage[landscape]{geometry} [% END %]\usepackage{booktabs} \usepackage{xcolor} \usepackage{ltxtable} \usepackage{longtable} \usepackage{colortbl} \usepackage{array} \usepackage{helvet} [% IF TITLE %][% TITLE %][% END %] \begin{document} [% IF TITLE %]\maketitle [% END %][% TABLECODE %] \end{document}; EOT ; my $code; $template_obj->process( \$template, \%template_vars, \$code ) or croak $template_obj->error; return $code; } __END__ =head1 NAME csv2pdf - A simple but yet powerful LaTeX::Table example application. =head1 SYNOPSIS csv2pdf [OPTIONS] --in in.csv [--out out.pdf] =head1 OPTIONS =over =item C<--sep_char> The separator character. Default comma ','. =item C<--latex_encode> Use L. =item C<--landscape> Output the PDF in landscape orientation. =item C<--theme> The table theme. See L. Default I. =item C<--coldef> The column definition, e.g. 'llp{5cm}'. If unset, guessed by L. =item C<--title> If set, then uses the specified string as title. =item C<--header> Instead of the first line, use the specified string as header. --header "Header A, Header B, Header C" The separator character must be the same as in the file. If unset, then the first line is used as header. =item C<--outputlatex> Prints the LaTeX code to STDOUT. =item C<--man> Display manpage. =item C<--version> Print version number of this software. =back =head1 DESCRIPTION Converts a CSV file to PDF. Requires LaTeX. =head1 EXAMPLE csv2pdf --landscape --theme Redmond --in examples/imdbtop40.dat =head1 CONFIGURATION AND ENVIRONMENT C does not support configuration files or environment variables. =head1 DEPENDENCIES LaTeX. L, L, L, L, L, L, L, L, L, L