Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > PDF, Excel, LaTeX, and possibly R and sweave

Reply
Thread Tools

PDF, Excel, LaTeX, and possibly R and sweave

 
 
ccc31807
Guest
Posts: n/a
 
      11-01-2013
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:DF. 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.
 
Reply With Quote
 
 
 
 
John Bokma
Guest
Posts: n/a
 
      11-01-2013
ccc31807 <(E-Mail Removed)> 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:DF. 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-ex...for-books.html
 
Reply With Quote
 
 
 
 
ccc31807
Guest
Posts: n/a
 
      11-02-2013
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.
 
Reply With Quote
 
ccc31807
Guest
Posts: n/a
 
      11-02-2013
On Friday, November 1, 2013 11:57:43 PM UTC-4, Ben Morrow wrote:
> Does such a creature exist? (Beyond the likes of LaTeX:river, 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.
 
Reply With Quote
 
Mart van de Wege
Guest
Posts: n/a
 
      11-03-2013
ccc31807 <(E-Mail Removed)> 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:river 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:river, that's the way I would do it.
 
Reply With Quote
 
ccc31807
Guest
Posts: n/a
 
      11-04-2013
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:river 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:river, 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.

 
Reply With Quote
 
Dr Eberhard Lisse
Guest
Posts: n/a
 
      11-07-2013
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:river 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:river, 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.
>


 
Reply With Quote
 
ccc31807
Guest
Posts: n/a
 
      11-07-2013
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting XML/HTML to LaTeX/PDF John Redmond XML 0 02-28-2009 09:39 AM
Convert XML to Latex/PDF and XHTML John Redmond XML 0 02-24-2009 03:33 AM
PDF::Writer, create pdf and insert in other pdf file. Ricardo Pog Ruby 1 03-26-2008 08:24 PM
Generate PDF or LaTeX ? Sinclair Python 2 01-13-2004 03:48 PM
from XHTML to PDF in Java: LaTeX 3? Marcus Beyer Java 1 11-20-2003 12:13 PM



Advertisments