Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I need to find a way to convert MS Access files to PDF.
A co-worker recommended that I write a Perl script to do
this. But I am not very techincal and not sure where to start.

Edit kudra, 2002-05-30 Changed title

  • Comment on Would Perl be a good choice for converting MS Access files to PDF

Replies are listed 'Best First'.
Re: Would Perl be a good choice for
by George_Sherston (Vicar) on May 28, 2002 at 21:57 UTC
    Heh! Any question beginning "Would Perl be a good choice for" is going to get a 'yes'!

    Seriously, though. I don't know anything about the MS Access side, but I have been grappling a bit with creating PDFs from database output. I think you would find the module PDF::Create very useful. I've found that it has everything I need for outputting typical reports in PDF format, either as a file, or as on-the-fly sent to a web browser.

    If you are "not very technical" you may feel "surely there must be an easier way than learning how to use a module" - if you do think that, I can assure you from bitter experience, you're wrong! The learning curve is not too steep.

    One other piece of advice might be to have a go with PDF::Create and any other recommendations and then, when you've got a bit of code, even if it doesn't do everything you want, come back and ask further advice. Monks can help better if there's something to bite on.

    George Sherston
Re: Converting Microsoft Access files to PDF
by cjf (Parson) on May 28, 2002 at 21:55 UTC

    I'm not that familiar with the Access file format, but judging from this you can export data from Access as XML. From there it should be fairly easy create PDF files with PDF::API2 or a similar module.

    Update: While writing scripts is one of the best ways to learn Perl, you should have some basic knowledge about the language before you start. If you're completely new to Perl I'd follow cLive ;-)'s advice and pick up a copy of Learning Perl and read that first.

    Hope this helps :).

      "you can export data from Access as XML"

      Presuming that only the data must be printed, this is true, but if you must duplicate formatted reports, entry screens, etc., then perhaps the Adobe solution below might be your best bet.


Re: Would Perl be a good choice for
by mdillon (Priest) on May 28, 2002 at 22:58 UTC
    For getting the data out of Access, you may want to have a look at Win32::ODBC. For the PDF part, follow the suggestions other monks have given you and check out PDF::API2 or PDF::Create.

    For dealing with Access MDB files on systems where Access and/or ODBC/MSJet is unavailable, a non-Perl solution may be found in MDB Tools.

Re: Would Perl be a good choice for
by Anonymous Monk on May 29, 2002 at 03:42 UTC
    I know both Perl and Access and by far your easiest solution is to write Reports in Access and use one of the PDF creation products (eg Adobe) that runs as a Windows printer driver.

    No programming required.

      Yep, this way would most definatly be easiest. Unless you had a ton of Access reports to convert to PDFs where perhpas Perl could make a big job easier in the longrun. If not though, definately just download Adobe Acrobat PDF Writer and, as written above, run it as a printer which will convert your file right into a PDF. :)
Re: Would Perl be a good choice for
by cLive ;-) (Prior) on May 29, 2002 at 00:19 UTC

    But I am not very techincal and not sure where to start.

    I think your best bet is Learning Perl first.

    cLive ;-)


Re: Would Perl be a good choice for
by mah (Scribe) on May 29, 2002 at 08:30 UTC

    I started with Perl about 2 years ago. My previous experience was with BASIC & Pascal but I hadn't done any serious programming for about 8 years.

    I needed to sign-on to an e-mail account, download the e-mails, extract the attachments and then convert the attachments into a flat file format to go up into our production system.

    In my case all I needed was:

  • O'Reilly Learning Perl Book
  • O'Reilly Programming Perl Book
  • The CPAN library
  • The key is before coding look at what CPAN can give you. It saved me days of coding.

    As for Perl, I found it very straightforward.

    Basically: Don't try and re-invent the wheel. Look at CPAN!!

    Best of Luck

Re: Would Perl be a good choice for
by Reverend Phil (Pilgrim) on May 29, 2002 at 13:46 UTC
    As my first GUI project, I have a front-end to a (currently) MS Access database, with functionality for entering and retrieving data via DBD::ODBC. With the data, I create a PDF containing text, lines/rectangles, graphics, and barcodes. I shopped around for a decent module out of those that were available, and settled in on PDF::API2. There are some limitations of course, and there may have even been updates since I've put this into production (it was rather active if I remember correctly), but it was able to handle what I needed, and didn't take *too* long to figure out how to use without knowing a thing about the internals of a PDF. Let me know if you go that route and get stuck at all.. I'd be happy to over-comment chunks of code that are accomplishing something similar to what you are doing.