diff --git a/CRM/Contribute/Form/Task/PDFLatex.php b/CRM/Contribute/Form/Task/PDFLatex.php
new file mode 100644
index 0000000..f353e00
--- /dev/null
+++ b/CRM/Contribute/Form/Task/PDFLatex.php
@@ -0,0 +1,147 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2013
+ * $Id$
+ *
+ */
+
+/**
+ * This class provides the functionality to create PDF letter for a group of
+ * contacts or a single contact.
+ */
+class CRM_Contribute_Form_Task_PDFLatex extends CRM_Contribute_Form_Task {
+
+  /**
+   * all the existing templates in the system
+   *
+   * @var array
+   */
+  public $_templates = NULL;
+
+  public $_single = NULL;
+
+  public $_cid = NULL;
+
+  /**
+   * build all the data structures needed to build the form
+   *
+   * @return void
+   * @access public
+   */
+  function preProcess() {
+    $this->skipOnHold = $this->skipDeceased = FALSE;
+    CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
+
+    // store case id if present
+    $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Positive', $this, FALSE);
+
+    // retrieve contact ID if this is 'single' mode
+    $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
+
+    $this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
+
+    if ($cid) {
+      CRM_Contact_Form_Task_PDFLetterCommon::preProcessSingle($this, $cid);
+      $this->_single = TRUE;
+      $this->_cid = $cid;
+    }
+    else {
+      parent::preProcess();
+    }
+    $this->assign('single', $this->_single);
+  }
+
+  function setDefaultValues() {
+    $defaults = array();
+    if (isset($this->_activityId)) {
+      $params = array('id' => $this->_activityId);
+      CRM_Activity_BAO_Activity::retrieve($params, $defaults);
+      $defaults['html_message'] = $defaults['details'];
+    }
+    $defaults = $defaults + CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues();
+    return $defaults;
+  }
+
+  /**
+   * Build the form
+   *
+   * @access public
+   *
+   * @return void
+   */
+  public function buildQuickForm() {
+    //enable form element
+    $this->assign('suppressForm', FALSE);
+
+    // use contact form as a base
+    CRM_Contact_Form_Task_PDFLetterCommon::buildQuickForm($this);
+
+    // specific need for contributions
+    $this->add('static', 'more_options_header', NULL, ts('Record Update Options'));
+    $this->add('checkbox', 'receipt_update', ts('Update receipt dates for these contributions'), FALSE);
+    $this->add('checkbox', 'thankyou_update', ts('Update thank-you dates for these contributions'), FALSE);
+
+    // Group options for tokens are not yet implemented. dgg
+    $options = array(ts('Contact'), ts('Recurring'));
+    $this->addRadio('is_group_by', ts('Grouping contributions in one letter based on'), $options, array(), "<br/>", FALSE);
+
+    $this->addButtons(array(
+        array(
+          'type' => 'submit',
+          'name' => ts('Make Thank-you Letters'),
+          'isDefault' => TRUE,
+        ),
+        array(
+          'type' => 'cancel',
+          'name' => ts('Done'),
+        ),
+      )
+    );
+
+  }
+
+  /**
+   * process the form after the input has been submitted and validated
+   *
+   * @access public
+   *
+   * @return None
+   */
+  public function postProcess() {
+    // TODO: rewrite using contribution token and one letter by contribution
+    $this->setContactIDs();
+
+		CRM_Contribute_Form_Task_PDFLatexCommon::postProcess($this);
+  }
+
+
+}
+
diff --git a/CRM/Contribute/Form/Task/PDFLatexCommon.php b/CRM/Contribute/Form/Task/PDFLatexCommon.php
new file mode 100644
index 0000000..862b03f
--- /dev/null
+++ b/CRM/Contribute/Form/Task/PDFLatexCommon.php
@@ -0,0 +1,116 @@
+<?php
+
+/**
+ * This class provides the common functionality for creating PDF letter for
+ * one or a group of contact ids.
+ */
+class CRM_Contribute_Form_Task_PDFLatexCommon extends CRM_Contact_Form_Task_PDFLetterCommon {
+
+  /**
+   * process the form after the input has been submitted and validated
+   *
+   * @access public
+   *
+   * @return None
+   */
+  static function postProcess(&$form) {
+
+    list($formValues, $categories, $html_message, $messageToken, $returnProperties) = self::processMessageTemplate($form);
+	  //CRM_Core_Error::debug_log_message(":2 $html_message"); //OK
+
+    // update dates ?
+    $receipt_update  = isset($formValues['receipt_update']) ? $formValues['receipt_update'] : FALSE;
+    $thankyou_update = isset($formValues['thankyou_update']) ? $formValues['thankyou_update'] : FALSE;
+    $nowDate         = date('YmdHis');
+    $receipts        = 0;
+    $thanks          = 0;
+    $updateStatus    = '';
+
+    // skip some contacts ?
+    $skipOnHold = isset($form->skipOnHold) ? $form->skipOnHold : FALSE;
+    $skipDeceased = isset($form->skipDeceased) ? $form->skipDeceased : TRUE;
+
+    foreach ($form->getVar('_contributionIds') as $item => $contributionId) {
+
+      // get contact information
+      $contactId = civicrm_api("Contribution", "getvalue", array('version' => '3', 'id' => $contributionId, 'return' => 'contact_id'));
+      $params = array('contact_id' => $contactId);
+
+      list($contact) = CRM_Utils_Token::getTokenDetails($params,
+        $returnProperties,
+        $skipOnHold,
+        $skipDeceased,
+        NULL,
+        $messageToken,
+        'CRM_Contribution_Form_Task_PDFLetterCommon'
+      );
+      if (civicrm_error($contact)) {
+        $notSent[] = $contributionId;
+        continue;
+      }
+
+      // get contribution information
+      $params = array('contribution_id' => $contributionId);
+      $contribution = CRM_Utils_Token::getContributionTokenDetails($params,
+        $returnProperties,
+        NULL,
+        $messageToken,
+        'CRM_Contribution_Form_Task_PDFLetterCommon'
+      );
+      if (civicrm_error($contribution)) {
+        $notSent[] = $contributionId;
+        continue;
+      }
+	  
+      $tokenHtml = CRM_Utils_Token::replaceContactTokens($html_message, $contact[$contactId], FALSE, $messageToken);
+      $tokenHtml = CRM_Utils_Token::replaceContributionTokens($tokenHtml, $contribution[$contributionId], TRUE, $messageToken);
+      $tokenHtml = CRM_Utils_Token::replaceHookTokens($tokenHtml, $contact[$contactId], $categories, TRUE);
+
+      if (defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY) {
+        $smarty = CRM_Core_Smarty::singleton();
+        // also add the tokens to the template
+        $smarty->assign_by_ref('contact', $contact);
+        $tokenHtml = $smarty->fetch("string:$tokenHtml");
+      }
+
+      $html[] = $tokenHtml;
+
+      // update dates (do it for each contribution including grouped recurring contribution)
+      if ($receipt_update) {
+        $result = CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'receipt_date', $nowDate);
+        // We can't use CRM_Core_Error::fatal here because the api error elevates the exception level. FIXME. dgg
+        if ($result) {
+          $receipts++;
+      }
+      }
+      if ($thankyou_update) {
+        $result = CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'thankyou_date', $nowDate);
+        // We can't use CRM_Core_Error::fatal here because the api error elevates the exception level. FIXME. dgg
+        if ($result) {
+          $thanks++;
+      }
+    }
+    }
+
+    self::createActivities($form, $html_message, $form->_contactIds);
+
+    CRM_Utils_PDF_Utils::latex2pdf($html, "CiviLatex.pdf", FALSE, $formValues);
+
+    $form->postProcessHook();
+
+    if ($receipts) {
+      $updateStatus = ts('Receipt date has been updated for %1 contributions.', array(1 => $receipts));
+    }
+    if ($thanks) {
+      $updateStatus .= ' ' . ts('Thank-you date has been updated for %1 contributions.', array(1 => $thanks));
+    }
+
+    if ($updateStatus) {
+      CRM_Core_Session::setStatus($updateStatus);
+    }
+    
+    CRM_Utils_System::civiExit(1);
+  }
+  //end of function
+}
+
diff --git a/CRM/Contribute/Task.php b/CRM/Contribute/Task.php
index 987b280..129cb45 100644
--- a/CRM/Contribute/Task.php
+++ b/CRM/Contribute/Task.php
@@ -39,7 +39,7 @@
  *
  */
 class CRM_Contribute_Task {
-  CONST DELETE_CONTRIBUTIONS = 1, PRINT_CONTRIBUTIONS = 2, EXPORT_CONTRIBUTIONS = 3, BATCH_CONTRIBUTIONS = 4, EMAIL_CONTACTS = 5, UPDATE_STATUS = 6, PDF_RECEIPT = 7;
+  CONST DELETE_CONTRIBUTIONS = 1, PRINT_CONTRIBUTIONS = 2, EXPORT_CONTRIBUTIONS = 3, BATCH_CONTRIBUTIONS = 4, EMAIL_CONTACTS = 5, UPDATE_STATUS = 6, PDF_RECEIPT = 7, LATEX_TEST = 9;
 
   /**
    * the task array
@@ -106,6 +106,10 @@ static function &tasks() {
           'class' => 'CRM_Contribute_Form_Task_PDFLetter',
           'result' => FALSE,
         ),
+        9 => array('title' => ts('Latex Letters for Contributions'),
+          'class' => 'CRM_Contribute_Form_Task_PDFLatex',
+          'result' => FALSE,
+        ),
       );
 
       //CRM-4418, check for delete
diff --git a/CRM/Utils/PDF/Utils.php b/CRM/Utils/PDF/Utils.php
index 72d4880..e9d59b9 100644
--- a/CRM/Utils/PDF/Utils.php
+++ b/CRM/Utils/PDF/Utils.php
@@ -34,6 +34,69 @@
  */
 class CRM_Utils_PDF_Utils {
 
+  static function latex2pdf(&$text, $fileName = 'civicrm.pdf', $output = FALSE, $pdfFormat = NULL) {
+	  /* FIXME: get $paper_size, $orientation, $margins */
+
+    if (is_array($text)) {
+      $pages = &$text;
+    }
+    else {
+      $pages = array($text);
+    }
+
+
+    $head='\documentclass[12pt]{letter}
+\oddsidemargin 0in
+\evensidemargin 0in
+\textwidth 6.5in
+
+\topmargin -.25in
+\textheight 8.15in
+
+\address{\vspace{0.354in}}
+
+\begin{document}
+
+';
+		 $footer='
+\end{document}';
+
+    $latex = $head;
+    foreach ($pages as $page) {
+			$latex.=$page;
+		}
+    $latex.=$footer;
+
+		$descriptorspec = array(
+  	 0 => array("pipe", "r"),
+   	 1 => array("pipe", "w")
+		);
+
+
+
+		$process = proc_open("/usr/local/bin/pdflatex_wrapper.sh", $descriptorspec, $pipes);
+
+
+	  if (is_resource($process)) {
+			fwrite($pipes[0], $latex);
+			fclose($pipes[0]);
+
+      $pdf = stream_get_contents($pipes[1]);
+			fclose($pipes[1]);
+	  } else {
+			CRM_Core_Error::debug_log_message("ERROR creating PDF. Check /tmp/pdflatex_*");
+		}
+
+    if ($output) {
+      return $pdf;
+    }
+    else {
+      header('Content-Type: application/pdf');
+      header('Content-Disposition: attachment; filename="' . $fileName . '"');
+      echo $pdf;
+    }
+	}
+
   static function html2pdf(&$text, $fileName = 'civicrm.pdf', $output = FALSE, $pdfFormat = NULL) {
     if (is_array($text)) {
       $pages = &$text;
diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php
index 28ca941..e8df124 100644
--- a/CRM/Utils/Token.php
+++ b/CRM/Utils/Token.php
@@ -619,7 +619,10 @@ function ($matches) use(&$contact, $html, $returnBlankToken, $escapeSmarty) {
       $str
     );
 
-    $str = preg_replace('/\\\\|\{(\s*)?\}/', ' ', $str);
+		// 2013-08-31 nico@fsf.org this replacement is stripping all the '{' and '}'  from the LaTeX files
+		// maybe it got solved at some point. maybe it has undesired collateral effects. I'm bugging the
+		// CiviCRM community to take a look at this pull request.
+    //$str = preg_replace('/\\\\|\{(\s*)?\}/', ' ', $str);
     return $str;
   }
 
diff --git a/templates/CRM/Contact/Form/Task/PDFLatexCommon.tpl b/templates/CRM/Contact/Form/Task/PDFLatexCommon.tpl
new file mode 100644
index 0000000..1f75f97
--- /dev/null
+++ b/templates/CRM/Contact/Form/Task/PDFLatexCommon.tpl
@@ -0,0 +1,312 @@
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*}
+{*common template for compose PDF letters*}
+{if $form.template.html}
+<table class="form-layout-compressed">
+    <tr>
+        <td class="label-left">{$form.template.label}</td>
+      <td>{$form.template.html}</td>
+    </tr>
+</table>
+{/if}
+
+<div class="crm-accordion-wrapper collapsed">
+    <div class="crm-accordion-header">
+        {$form.pdf_format_header.html}
+    </div>
+    <div class="crm-accordion-body">
+      <div class="crm-block crm-form-block crm-pdf-format-form-block">
+    <table class="form-layout-compressed">
+      <tr>
+        <td class="label-left">{$form.format_id.label}</td><td>{$form.format_id.html}{help id="id-pdf-format" file="CRM/Contact/Form/Task/PDFLetterCommon.hlp"}</td>
+        <td colspan="2">&nbsp;</td>
+            </tr>
+      <tr>
+        <td class="label-left">{$form.paper_size.label}</td><td>{$form.paper_size.html}</td>
+        <td class="label-left">{$form.orientation.label}</td><td>{$form.orientation.html}</td>
+      </tr>
+      <tr>
+        <td class="label-left">{$form.metric.label}</td><td>{$form.metric.html}</td>
+        <td colspan="2">&nbsp;</td>
+      </tr>
+      <tr>
+        <td>{$form.paper_dimensions.html}</td><td id="paper_dimensions">&nbsp;</td>
+        <td colspan="2">&nbsp;</td>
+      </tr>
+      <tr>
+        <td class="label-left">{$form.margin_top.label}</td><td>{$form.margin_top.html}</td>
+        <td class="label-left">{$form.margin_bottom.label}</td><td>{$form.margin_bottom.html}</td>
+      </tr>
+      <tr>
+        <td class="label-left">{$form.margin_left.label}</td><td>{$form.margin_left.html}</td>
+        <td class="label-left">{$form.margin_right.label}</td><td>{$form.margin_right.html}</td>
+      </tr>
+    </table>
+        <div id="bindFormat">{$form.bind_format.html}&nbsp;{$form.bind_format.label}</div>
+        <div id="updateFormat" style="display: none">{$form.update_format.html}&nbsp;{$form.update_format.label}</div>
+      </div>
+  </div>
+</div>
+
+<div class="crm-accordion-wrapper crm-html_email-accordion ">
+<div class="crm-accordion-header">
+    {$form.html_message.label}
+</div><!-- /.crm-accordion-header -->
+ <div class="crm-accordion-body">
+  {if $action neq 4}
+  <span class="helpIcon" id="helphtml">
+  <a href="#" onClick="return showToken('Html', 1);">{$form.token1.label}</a>
+  {help id="id-token-html" file="CRM/Contact/Form/Task/Email.hlp" tplFile=$tplFile isAdmin=$isAdmin editor=$editor}
+  <div id="tokenHtml" style="display:none;">
+      <input style="border:1px solid #999999;" type="text" id="filter1" size="20" name="filter1" onkeyup="filter(this, 1)"/><br />
+      <span class="description">{ts}Begin typing to filter list of tokens{/ts}</span><br/>
+      {$form.token1.html}
+  </div>
+  </span>
+  {/if}
+    <div class="clear"></div>
+    <div class='html'>
+  {if $editor EQ 'textarea'}
+      <div class="help description">{ts}The content of this page should be LaTeX.{/ts}</div>
+  {/if}
+  {$form.html_message.html}<br />
+    </div>
+
+<div id="editMessageDetails">
+    <div id="updateDetails" >
+        {$form.updateTemplate.html}&nbsp;{$form.updateTemplate.label}
+    </div>
+    <div>
+        {$form.saveTemplate.html}&nbsp;{$form.saveTemplate.label}
+    </div>
+</div>
+
+<div id="saveDetails" class="section">
+    <div class="label">{$form.saveTemplateName.label}</div>
+    <div class="content">{$form.saveTemplateName.html|crmAddClass:huge}</div>
+</div>
+
+  </div><!-- /.crm-accordion-body -->
+</div><!-- /.crm-accordion-wrapper -->
+
+{include file="CRM/Mailing/Form/InsertTokens.tpl"}
+
+{literal}
+<script type="text/javascript">
+cj(function() {
+    cj().crmAccordions();
+});
+
+var currentWidth;
+var currentHeight;
+var currentMetric = document.getElementById('metric').value;
+showBindFormatChkBox();
+selectPaper( document.getElementById('paper_size').value );
+
+function tokenReplHtml ( )
+{
+    var token1 = cj("#token1").val( )[0];
+    var editor = {/literal}"{$editor}"{literal};
+    if ( editor == "tinymce" ) {
+        var content= tinyMCE.get('html_message').getContent() +token1;
+        tinyMCE.get('html_message').setContent(content);
+    } else if ( editor == "joomlaeditor" ) {
+        tinyMCE.execCommand('mceInsertContent',false, token1);
+        var msg       = document.getElementById(html_message).value;
+        var cursorlen = document.getElementById(html_message).selectionStart;
+        var textlen   = msg.length;
+        document.getElementById(html_message).value = msg.substring(0, cursorlen) + token1 + msg.substring(cursorlen, textlen);
+        var cursorPos = (cursorlen + token1.length);
+        document.getElementById(html_message).selectionStart = cursorPos;
+        document.getElementById(html_message).selectionEnd   = cursorPos;
+        document.getElementById(html_message).focus();
+  } else if ( editor == "ckeditor" ) {
+        oEditor = CKEDITOR.instances[html_message];
+        oEditor.insertHtml(token1.toString() );
+    } else if ( editor == "drupalwysiwyg" ) {
+        Drupal.wysiwyg.instances[html_message].insert(token1.toString());
+    } else {
+    var msg       = document.getElementById(html_message).value;
+        var cursorlen = document.getElementById(html_message).selectionStart;
+        var textlen   = msg.length;
+        document.getElementById(html_message).value = msg.substring(0, cursorlen) + token1 + msg.substring(cursorlen, textlen);
+        var cursorPos = (cursorlen + token1.length);
+        document.getElementById(html_message).selectionStart = cursorPos;
+        document.getElementById(html_message).selectionEnd   = cursorPos;
+        document.getElementById(html_message).focus();
+    }
+    verify();
+}
+
+function showBindFormatChkBox()
+{
+    var templateExists = true;
+    if ( document.getElementById('template') == null || document.getElementById('template').value == '' ) {
+        templateExists = false;
+    }
+    var formatExists = true;
+    if ( document.getElementById('format_id').value == 0 ) {
+        formatExists = false;
+    }
+    if ( templateExists && formatExists ) {
+        document.getElementById("bindFormat").style.display = "block";
+    } else if ( formatExists && document.getElementById("saveTemplate") != null && document.getElementById("saveTemplate").checked ) {
+        document.getElementById("bindFormat").style.display = "block";
+        var yes = confirm( '{/literal}{$useThisPageFormat}{literal}' );
+        if ( yes ) {
+            document.getElementById("bind_format").checked = true;
+        }
+    } else {
+        document.getElementById("bindFormat").style.display = "none";
+        document.getElementById("bind_format").checked = false;
+    }
+}
+
+function showUpdateFormatChkBox()
+{
+    if ( document.getElementById('format_id').value != 0 ) {
+        document.getElementById("updateFormat").style.display = "block";
+    }
+}
+
+function hideUpdateFormatChkBox()
+{
+    document.getElementById("update_format").checked = false;
+    document.getElementById("updateFormat").style.display = "none";
+}
+
+function selectFormat( val, bind )
+{
+    if ( val == null || val == 0 ) {
+        val = 0;
+        bind = false;
+    }
+    var dataUrl = {/literal}"{crmURL p='civicrm/ajax/pdfFormat' h=0 }"{literal};
+    cj.post( dataUrl, {formatId: val}, function( data ) {
+        cj("#format_id").val( data.id );
+        cj("#paper_size").val( data.paper_size );
+        cj("#orientation").val( data.orientation );
+        cj("#metric").val( data.metric );
+        cj("#margin_top").val( data.margin_top );
+        cj("#margin_bottom").val( data.margin_bottom );
+        cj("#margin_left").val( data.margin_left );
+        cj("#margin_right").val( data.margin_right );
+        selectPaper( data.paper_size );
+        hideUpdateFormatChkBox();
+        document.getElementById('bind_format').checked = bind;
+        showBindFormatChkBox();
+    }, 'json');
+}
+
+function selectPaper( val )
+{
+    dataUrl = {/literal}"{crmURL p='civicrm/ajax/paperSize' h=0 }"{literal};
+    cj.post( dataUrl, {paperSizeName: val}, function( data ) {
+        cj("#paper_size").val( data.name );
+        metric = document.getElementById('metric').value;
+        currentWidth = convertMetric( data.width, data.metric, metric );
+        currentHeight = convertMetric( data.height, data.metric, metric );
+        updatePaperDimensions( );
+    }, 'json');
+}
+
+function selectMetric( metric )
+{
+    convertField( 'margin_top', currentMetric, metric );
+    convertField( 'margin_bottom', currentMetric, metric );
+    convertField( 'margin_left', currentMetric, metric );
+    convertField( 'margin_right', currentMetric, metric );
+    currentWidth = convertMetric( currentWidth, currentMetric, metric );
+    currentHeight = convertMetric( currentHeight, currentMetric, metric );
+    updatePaperDimensions( );
+}
+
+function updatePaperDimensions( )
+{
+    metric = document.getElementById('metric').value;
+    width = new String( currentWidth.toFixed( 2 ) );
+    height = new String( currentHeight.toFixed( 2 ) );
+    if ( document.getElementById('orientation').value == 'landscape' ) {
+        width = new String( currentHeight.toFixed( 2 ) );
+        height = new String( currentWidth.toFixed( 2 ) );
+    }
+    document.getElementById('paper_dimensions').innerHTML = parseFloat( width ) + ' ' + metric + ' x ' + parseFloat( height ) + ' ' + metric;
+    currentMetric = metric;
+}
+
+function convertField( id, from, to )
+{
+    val = document.getElementById( id ).value;
+    if ( val == '' || isNaN( val ) ) return;
+    val = convertMetric( val, from, to );
+    val = new String( val.toFixed( 3 ) );
+    document.getElementById( id ).value = parseFloat( val );
+}
+
+function convertMetric( value, from, to ) {
+    switch( from + to ) {
+        case 'incm': return value * 2.54;
+        case 'inmm': return value * 25.4;
+        case 'inpt': return value * 72;
+        case 'cmin': return value / 2.54;
+        case 'cmmm': return value * 10;
+        case 'cmpt': return value * 72 / 2.54;
+        case 'mmin': return value / 25.4;
+        case 'mmcm': return value / 10;
+        case 'mmpt': return value * 72 / 25.4;
+        case 'ptin': return value / 72;
+        case 'ptcm': return value * 2.54 / 72;
+        case 'ptmm': return value * 25.4 / 72;
+    }
+    return value;
+}
+
+function showSaveDetails(chkbox)  {
+    var formatSelected = ( document.getElementById('format_id').value > 0 );
+    var templateSelected = ( document.getElementById('template') != null && document.getElementById('template').value > 0 );
+    if (chkbox.checked) {
+        document.getElementById("saveDetails").style.display = "block";
+        document.getElementById("saveTemplateName").disabled = false;
+        if ( formatSelected && ! templateSelected ) {
+            document.getElementById("bindFormat").style.display = "block";
+            var yes = confirm( '{/literal}{$useSelectedPageFormat}{literal}' );
+            if ( yes ) {
+                document.getElementById("bind_format").checked = true;
+            }
+        }
+    } else {
+        document.getElementById("saveDetails").style.display = "none";
+        document.getElementById("saveTemplateName").disabled = true;
+        if ( ! templateSelected ) {
+            document.getElementById("bindFormat").style.display = "none";
+            document.getElementById("bind_format").checked = false;
+        }
+    }
+}
+
+</script>
+{/literal}
+
diff --git a/templates/CRM/Contribute/Form/Task/PDFLatex.tpl b/templates/CRM/Contribute/Form/Task/PDFLatex.tpl
new file mode 100644
index 0000000..a7fb259
--- /dev/null
+++ b/templates/CRM/Contribute/Form/Task/PDFLatex.tpl
@@ -0,0 +1,48 @@
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*}
+<div class="crm-form-block crm-block crm-contact-task-pdflatex-form-block">
+<h3>{ts}Thank-you Letter In Latex for Contributions (PDF){/ts}</h3>
+{if $single eq false}
+    <div class="messages status no-popup">{include file="CRM/Contribute/Form/Task.tpl"}</div>
+{/if}
+
+<div class="crm-accordion-wrapper crm-html_email-accordion ">
+  <div class="crm-accordion-header">
+    {$form.more_options_header.html}
+  </div><!-- /.crm-accordion-header -->
+  <div class="crm-accordion-body">
+    <table class="form-layout-compressed">
+      <tr><td class="label-left">{$form.thankyou_update.html} {$form.thankyou_update.label}</td><td></td></tr>
+      <tr><td class="label-left">{$form.receipt_update.html} {$form.receipt_update.label}</td><td></td></tr>
+      <!--tr><td class="label-left">{$form.is_group_by.label} (<a href="#" title="unselect" onclick="unselectRadio('is_group_by'); return false;" >{ts}clear{/ts}</a>)</td><td>{$form.is_group_by.html}</td></tr-->
+    </table>
+  </div><!-- /.crm-accordion-body -->
+</div><!-- /.crm-accordion-wrapper -->
+
+{include file="CRM/Contact/Form/Task/PDFLatexCommon.tpl"}
+
+<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
+</div>
-- 
1.8.4

