PDF, Excel, LaTeX, and possibly R and sweave

Discussion in 'Perl Misc' started by ccc31807, Nov 1, 2013.

  1. ccc31807

    ccc31807 Guest

    I've been asked about the automation of a series of reports that are now being created by hand and printed as hard copies for distribution. I have twoquestions for the combined experience of this group, both concerning PDF.

    First, I produce reports now as csv files, and using Excel::Writer::XLSX asExcel 2010 files. I have no problem with either, as they are both quick, easy, and effective.

    Second, I have been using PDF::API2 for years, with good results, but mightneed to look at other options, such as CAM::pDF. If I'm happy with PDF::API2, is there an incentive to look at other libraries for the creation of PDF files? I might be looking for an excuse to use another library, so this is a case where any reason might be good enough.

    Third, I am accustomed to using LaTeX as my general purpose tool for creating documents (as opposed, for example, to creating them in Word and printing them as a PDF file). What are the advantages/disadvantages to using a Perl binding to LaTex, generating LaTeX source by hand and printing with pdflatex, or continuing to use PDF::API2? I'm much more familiar with LaTeX and comfortable using it than PDF::API2, and again any reason to start using Perl/LaTeX might be good enough.

    Finally, I suspect that this project might involve the creation of graphics.. I have used both gnuplot and R to manually create graphics, and it seems to me that, if I use LaTeX, sweave might be a good solution for producing PDFs with embedded graphics. I'm just wondering of anyone has experience with this, or even just an opinion.

    Thanks, CC.
    ccc31807, Nov 1, 2013
    #1
    1. Advertising

  2. ccc31807

    John Bokma Guest

    ccc31807 <> writes:

    > I've been asked about the automation of a series of reports that are
    > now being created by hand and printed as hard copies for
    > distribution. I have two questions for the combined experience of this
    > group, both concerning PDF.
    >
    > First, I produce reports now as csv files, and using
    > Excel::Writer::XLSX as Excel 2010 files. I have no problem with
    > either, as they are both quick, easy, and effective.
    >
    > Second, I have been using PDF::API2 for years, with good results, but
    > might need to look at other options, such as CAM::pDF. If I'm happy
    > with PDF::API2, is there an incentive to look at other libraries for
    > the creation of PDF files? I might be looking for an excuse to use
    > another library, so this is a case where any reason might be good
    > enough.
    >
    > Third, I am accustomed to using LaTeX as my general purpose tool for
    > creating documents (as opposed, for example, to creating them in Word
    > and printing them as a PDF file). What are the
    > advantages/disadvantages to using a Perl binding to LaTex, generating
    > LaTeX source by hand and printing with pdflatex, or continuing to use
    > PDF::API2? I'm much more familiar with LaTeX and comfortable using it
    > than PDF::API2, and again any reason to start using Perl/LaTeX might
    > be good enough.
    >
    > Finally, I suspect that this project might involve the creation of
    > graphics. I have used both gnuplot and R to manually create graphics,
    > and it seems to me that, if I use LaTeX, sweave might be a good
    > solution for producing PDFs with embedded graphics. I'm just wondering
    > of anyone has experience with this, or even just an opinion.


    I generate my invoices as follows:

    text file -> [ Perl program ] -> xml -> [ saxon ] -> fo -> [ FOP ] -> PDF
    _
    xslt /|

    If you want to learn something new, XSLT/XSL-FO is something I enjoy
    having in my toolbox.

    You might also want to have a peek at pandoc.

    --
    John Bokma j3b

    Blog: http://johnbokma.com/ Perl Consultancy: http://castleamber.com/
    Perl for books: http://johnbokma.com/perl/help-in-exchange-for-books.html
    John Bokma, Nov 1, 2013
    #2
    1. Advertising

  3. ccc31807

    ccc31807 Guest

    On Friday, November 1, 2013 5:47:09 PM UTC-4, John Bokma wrote:

    > text file -> [ Perl program ] -> xml -> [ saxon ] -> fo -> [ FOP ] -> PDF
    > _
    >
    > xslt /|
    >
    >
    >
    > If you want to learn something new, XSLT/XSL-FO is something I enjoy
    > having in my toolbox.


    Years ago, probably around 2003, I used XSLT, and you are right in that it's a great tool to have. I'm not sure what this project will entail, and I thank you for reminding me about XSLT. It may be useful.

    I generate most of my work like this:

    data-files -> Perl-script -> (csv|HTML|PDF|Excel|email)

    CC.
    ccc31807, Nov 2, 2013
    #3
  4. ccc31807

    ccc31807 Guest

    On Friday, November 1, 2013 11:57:43 PM UTC-4, Ben Morrow wrote:
    > Does such a creature exist? (Beyond the likes of LaTeX::Driver, which
    > just automates running latex on generated source.)


    I don't know, which is why I asked the question. Yes, I searched CPAN, but sometimes things are not obvious and we overlook them.

    > > generating LaTeX source by hand and printing with pdflatex,

    > When you say 'by hand', I assume you mean 'with Perl'? If I were
    > generating PDFs, this is what I'd do. (Actually I'd use ConTeXt, since
    > it's easier to control, but that's immaterial here.)


    'by hand' means typing the commands, like this:
    \paragraph{Example}This is a paragraph.

    I generate HTML files with Perl like this:
    my $var = 'paragraph';
    print OUT qq(<html><body><p>This is a $var.</p></body></html>);

    I generate csv files the same way:
    print CSV qq("$col1","$col2","$col3"\n);

    However, I generate Excel files using the OO syntax of the package.

    I'm at a point where I will need to do significant new work, and this strikes me as a good time to investigate alternatives. After all, if I'm going to be doing a lot of work, I might as well use it as an opportunity to learn something new and different.

    CC.
    ccc31807, Nov 2, 2013
    #4
  5. ccc31807 <> writes:
    >
    > Third, I am accustomed to using LaTeX as my general purpose tool for
    > creating documents (as opposed, for example, to creating them in Word
    > and printing them as a PDF file). What are the
    > advantages/disadvantages to using a Perl binding to LaTex, generating
    > LaTeX source by hand and printing with pdflatex, or continuing to use
    > PDF::API2? I'm much more familiar with LaTeX and comfortable using it
    > than PDF::API2, and again any reason to start using Perl/LaTeX might
    > be good enough.
    >
    > Finally, I suspect that this project might involve the creation of
    > graphics. I have used both gnuplot and R to manually create graphics,
    > and it seems to me that, if I use LaTeX, sweave might be a good
    > solution for producing PDFs with embedded graphics. I'm just wondering
    > of anyone has experience with this, or even just an opinion.
    >

    At my previous employer I used to autogenerate reports for our customers
    using LaTeX::Driver with great success.

    I also used to generate the graphs for those reports using
    SVG::TT::Graph. Not because SVG was easy to bind into LaTeX (that sucked
    actually), but because SVG::TT::Graph had a nice API to generate graphs
    IMO. I used the ImageMagick bindings to convert the output into
    something that LaTeX would like, and Template Toolkit to fill in the
    LaTeX documents and generate the links to the graphs.

    So, use your favourite graphing module to create your graphics, use
    TT LaTeX templates to build your documents, and run the output of the
    processed templates through LaTeX::Driver, that's the way I would do it.
    Mart van de Wege, Nov 3, 2013
    #5
  6. ccc31807

    ccc31807 Guest

    On Sunday, November 3, 2013 3:29:32 PM UTC-5, Mart van de Wege wrote:
    > At my previous employer I used to autogenerate reports for our customers
    > using LaTeX::Driver with great success.


    Mart,

    Thanks very much for your input. Part of my problem is that I haven't figured out what I'm supposed to be doing. The largest part of my job is to takeinput (almost always as CSV files) and munge them into some kind of output(mostly these days as Excel, CSV, or PDF). I /think/ that I will be producing a report with a mixture of file formats, including PDF and Excel, with dynamically generated graphical elements -- I'm not sure but it looks like it's headed this way.

    I'm very comfortable generating Excel files and PDF files (with PDF::API2).I also like using R and LaTex. I've been casting a covetous eye on Sweave but haven't actually used it. And of course, I use Perl for the heavy lifing.

    > I also used to generate the graphs for those reports using
    > SVG::TT::Graph. Not because SVG was easy to bind into LaTeX (that sucked
    > actually), but because SVG::TT::Graph had a nice API to generate graphs
    > IMO. I used the ImageMagick bindings to convert the output into
    > something that LaTeX would like, and Template Toolkit to fill in the
    > LaTeX documents and generate the links to the graphs.


    I like using SVG when I can. Normally, when using LaTeX, I target my outputimages to EPS. EPS works well, but I would really like to try SVG. Unfortunately, R is limited in the kinds of graphical output formats it has, and Iwill definitely NOT be using JPEG, GIF, BMP, or PNG!

    > So, use your favourite graphing module to create your graphics, use
    > TT LaTeX templates to build your documents, and run the output of the
    > processed templates through LaTeX::Driver, that's the way I would do it.


    I will give this a great deal of thought. I can auto generate graphics, andI can certainly embed them in a PDF module, but I think that will be a kludge. I like the idea of Sweave because I like the idea of embedding R code in LaTeX, and I really like LaTex. I just don't know how this will work with Perl, and the bottom line is that Perl is essential for the data munging that underlies all the output stuff.

    CC.
    ccc31807, Nov 4, 2013
    #6
  7. Generating SVG is easy by using the R svg device.

    I find that rsvg-convert has a small footprint and produces excellent
    results, much better than ImageMagick and as good as Inkscape.


    el

    on 2013-11-04 17:47 ccc31807 said the following:
    > On Sunday, November 3, 2013 3:29:32 PM UTC-5, Mart van de Wege
    > wrote:
    >> At my previous employer I used to autogenerate reports for our
    >> customers using LaTeX::Driver with great success.

    >
    > Mart,
    >
    > Thanks very much for your input. Part of my problem is that I
    > haven't figured out what I'm supposed to be doing. The largest
    > part of my job is to take input (almost always as CSV files) and
    > munge them into some kind of output (mostly these days as Excel,
    > CSV, or PDF). I /think/ that I will be producing a report with a
    > mixture of file formats, including PDF and Excel, with dynamically
    > generated graphical elements -- I'm not sure but it looks like
    > it's headed this way.
    >
    > I'm very comfortable generating Excel files and PDF files (with
    > PDF::API2). I also like using R and LaTex. I've been casting a
    > covetous eye on Sweave but haven't actually used it. And of
    > course, I use Perl for the heavy lifing.
    >
    >> I also used to generate the graphs for those reports using
    >> SVG::TT::Graph. Not because SVG was easy to bind into LaTeX
    >> (that sucked actually), but because SVG::TT::Graph had a nice API
    >> to generate graphs IMO. I used the ImageMagick bindings to
    >> convert the output into something that LaTeX would like, and
    >> Template Toolkit to fill in the LaTeX documents and generate the
    >> links to the graphs.

    >
    > I like using SVG when I can. Normally, when using LaTeX, I target
    > my output images to EPS. EPS works well, but I would really like
    > to try SVG. Unfortunately, R is limited in the kinds of graphical
    > output formats it has, and I will definitely NOT be using JPEG,
    > GIF, BMP, or PNG!
    >
    >> So, use your favourite graphing module to create your graphics,
    >> use TT LaTeX templates to build your documents, and run the
    >> output of the processed templates through LaTeX::Driver, that's
    >> the way I would do it.

    >
    > I will give this a great deal of thought. I can auto generate
    > graphics, and I can certainly embed them in a PDF module, but I
    > think that will be a kludge. I like the idea of Sweave because I
    > like the idea of embedding R code in LaTeX, and I really like
    > LaTex. I just don't know how this will work with Perl, and the
    > bottom line is that Perl is essential for the data munging that
    > underlies all the output stuff.
    >
    > CC.
    >
    Dr Eberhard Lisse, Nov 7, 2013
    #7
  8. ccc31807

    ccc31807 Guest

    On Thursday, November 7, 2013 5:01:52 AM UTC-5, Dr Eberhard Lisse wrote:
    > Generating SVG is easy by using the R svg device.
    > I find that rsvg-convert has a small footprint and produces excellent
    > results, much better than ImageMagick and as good as Inkscape.


    I got started with the project yesterday, and have decided to use Excel::Writer, PDF::API2, and Statistics::R. I have generally used EPS for my graphics, but I'll try SVG. I will need to embed the graphics in a PDF file, and use epstopdf to convert my EPS graphics to PDF. I guess I'll find out how well SVG works.

    Thanks, CC.
    ccc31807, Nov 7, 2013
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcus Beyer

    from XHTML to PDF in Java: LaTeX 3?

    Marcus Beyer, Nov 19, 2003, in forum: Java
    Replies:
    1
    Views:
    4,034
    Marcus Beyer
    Nov 20, 2003
  2. Sinclair

    Generate PDF or LaTeX ?

    Sinclair, Jan 13, 2004, in forum: Python
    Replies:
    2
    Views:
    490
    Brian Elmegaard
    Jan 13, 2004
  3. vasudevram
    Replies:
    0
    Views:
    330
    vasudevram
    Dec 24, 2006
  4. John Redmond

    Convert XML to Latex/PDF and XHTML

    John Redmond, Feb 24, 2009, in forum: XML
    Replies:
    0
    Views:
    2,108
    John Redmond
    Feb 24, 2009
  5. John Redmond

    Converting XML/HTML to LaTeX/PDF

    John Redmond, Feb 28, 2009, in forum: XML
    Replies:
    0
    Views:
    683
    John Redmond
    Feb 28, 2009
Loading...

Share This Page