This documentation relates to CiviCRM version 3.2. It's not maintained anymore.
Current version of documentation.

Print PDF Letters to Contacts

Aller directement à la fin des métadonnées
Aller au début des métadonnées

This page refers to outdated version of CiviCRM. Check current version of documentation.

Documentation Search

CiviCRM 3.2 Documentation

Support and Participation

Developer Resources

CiviCRM book!

Make sure to check out Understanding CiviCRM as well! You can also support this project by ordering a hard copy.

The purpose of this documentation is to show you how to use the feature Print PDF Letter for Contacts in a meaningful and useful way.

First a little background...many organizations want to print paper letters to send to their constituents for a variety of reasons. 

1. Find who you want to send letters to, either via Search or by using Groups.  Once you have found the Contacts who should receive a letter, select this option from the results.

The next step will be to draft a letter using HTML.  This can be a little tricky because normally HTML is used to make websites, not paper letters.  To make a PDF letter using HTML that actually doesn't look like embarrassing piece of junk, you should have a little knowledge of writing HTML or find someone who does.  Then use the techniques I am going to show you to put on the finishing touches.

2. Your Logo is an important part of any letter.  If you have paper letterhead with your logo already printed on it, you are in luck.  You can totally skip this step.  If not, read on.  You must get a copy of your logo in hi-res format.  A common mistake is to use your logo from your website, which never works.  Here's why: because the web is using 72dpi, much less than the necessary resolution of 300dpi for your printer.  Web logos always look like crap when they are printed, all grainy and fuzzy. 

Get the logo in 300dpi format (ask your graphic designer or print shop if you have to) and open up Photoshop.  If you don't have Photoshop, you can use the open-source GIMP software.  If you are totally lost at this point already, you need to hire a professional. 

Make sure your logo is saved using the Save As feature of Photoshop, and NOT Save for Web.   Save for Web automatically converts any images to 72dpi, which is bad for printing.  Save As with a white background (assuming that your paper is white) and upload this file using FTP or SFTP to somewhere on your web server.  Note the path at which it will live, such as: Size the logo to however many inches across you want, I'd recommend more than 3" but less than 7". Here's what it should look like:

3. Signatures or Other Images are desirable for many letters.  Follow the same steps as option #1, sizing them appropriately and uploading to a place on your web server.

4. Making the HTML is the trickiest part. CiviCRM uses a 3rd party library called DomPDF that turns HTML into PDFs.  DomPDF requires the php-xml submodule, which is installed on most web servers.  If you get a blank white page while attempting to make PDFs, contact your server administrator and ask for "submodule php-xml".  DomPDF works "ok", and that is a very qualified, unenthusiastic "ok", but it is manageable.  I am going to share with you the techniques I found, largely by trial and error, to make a nice looking letter.  Here are some general guidelines first, and then examples later.

  • First of all, use tables to separate images from HTML.  Avoid excessive use of CSS.  Floating <div>s and other nonsense will not be tolerated by DomPDF.
  • Do not use <ul> or <li> tags for your bullets.  Instead use a simple asterisk *  or other characters
  • Avoid using <p> - instead use <br><br> to make line spaces
  • Avoid using width attributes (such as width="500") to contain text or define areas, as this will likely be ignored by DomPDF
  • Make sure your <img src= tags include a border=0 attribute and do NOT include the image size tags
  • You will find that your font sizes print very small when left to their defaults.  You will need to use CSS to specify your font size.  Font sizes under 14px tend to print very small, I recommend 14px or larger.
  • Use tokens to insert basic things like names, addresses and other information.  Some data may not be available as tokens.

Here is an actual working example of my HTML, and it prints a very nice letter.  Take note of how simple the HTML is, that's because DomPDF is less likely to mess up simple HTML!

5. Saving the HTML can be done in CiviCRM: Administer > Configure > Message Templates so you can use your template again. 

6. Printing the Letter should be done by using Print Preview first, so you don't waste a lot of paper.  On my machine I found that the option "Fit to Printable Area" served me well.  Here is an example.

Ok that should just about do it!  Happy printing!  Any questions ask on the CiviCRM Forums.

  • Aucun

Creative Commons License
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-Share Alike 3.0 United States Licence.