AjousPrints is a Dolibarr module that enables advanced PDF generation using Gotenberg and HTML templates. It specializes in creating dynamic PDFs with support for barcodes, custom layouts, and JavaScript-powered content. The module is particularly useful for generating product labels, custom documents, and reports that require complex formatting or dynamic elements.
- HTML-based template system with Handlebars.js support
- Barcode generation using JsBarcode
- Custom paper sizes and margins
- Dynamic content rendering
- Automatic temp file cleanup
- Built-in Dymo label generator for products
- Support for custom document templates
- Dolibarr >= 16.0
- PHP >= 7.4
- Gotenberg server instance
- Web-accessible temp directory for HTML files
- Download the module ZIP file
- Extract to your Dolibarr's custom directory:
dolibarr/custom/ajousprints
- Go to Home > Setup > Modules
- Find and enable "AjousPrints" module
- Configure the required settings
- Navigate to Home > Setup > Modules > AjousPrints setup
- Configure these required settings:
- Gotenberg URL (e.g.,
https://gotenberg:3000
) - Temp HTML Base URL (must be accessible by Gotenberg)
- Gotenberg URL (e.g.,
- Go to any product card
- Click "Generate Document"
- Select "Dymo" format
- PDF will be generated with product info and barcode
- Default size: 80mm x 30mm
- Go to any proposal
- Click "Generate Document"
- Select "Propale1" format
- PDF will be generated with proposal data
- Default size: A4
- Create a new HTML template file in
/templates
:
<body>
<style>
body {
font-size: 10pt;
font-family: Arial, sans-serif;
width: 100%;
text-align: center;
}
</style>
<!-- Use Handlebars syntax for data -->
{{myobject.field}}
<!-- Barcode example -->
<svg class="barcode"
jsbarcode-value="{{myobject.barcode}}"
jsbarcode-format="auto"
jsbarcode-textmargin="0"
jsbarcode-height="40"
jsbarcode-width="2"
jsbarcode-fontsize="10">
</svg>
</body>
- Create a PDF generator class:
require_once DOL_DOCUMENT_ROOT.'/custom/ajousprints/functions/utils.php';
class pdf_MyTemplate extends CommonDocGenerator
{
public function write_file($object, $outputlangs)
{
$data = new stdClass();
$data->myobject = $object;
$path = $conf->mymodule->dir_output.'/'.$object->ref.'.pdf';
return savePdf($data, 'mytemplate', $path, [
'paperWidth' => "210mm",
'paperHeight' => "297mm",
'marginTop' => 0,
'marginBottom' => 0,
'marginLeft' => 0,
'marginRight' => 0
]);
}
}
For direct PDF generation from your code:
require_once DOL_DOCUMENT_ROOT.'/custom/ajousprints/functions/utils.php';
$data = new stdClass();
$data->someProperty = 'value';
$result = savePdf(
$data, // Data object
'template_name', // Template name
'/path/to/output.pdf', // Output path
[ // Optional parameters
'paperWidth' => "210mm",
'paperHeight' => "297mm",
'marginTop' => 0,
'marginBottom' => 0
]
);
Templates are composed of three parts:
-
Header (base/header.html)
- Contains required JS libraries
- Defines basic HTML structure
- Includes Handlebars and JsBarcode
-
Content (your template)
- Contains your HTML/CSS
- Uses Handlebars syntax for data
- Can include barcodes and styling
-
Footer (base/footer.html)
- Handles rendering logic
- Initializes barcodes
- Manages page ready state
- Template syntax:
{{variable}}
- Supports expressions and helpers
- Used for dynamic content
- Multiple barcode formats
- Customizable dimensions
- Auto-format detection
Data is passed to templates as a JavaScript object:
- Product templates:
{{product.field}}
- Proposal templates:
{{propale.field}}
- Custom templates:
{{your_object.field}}
<svg class="barcode"
jsbarcode-format="auto" <!-- or specific format -->
jsbarcode-value="value" <!-- barcode content -->
jsbarcode-height="40" <!-- height in px -->
jsbarcode-width="2" <!-- bar width -->
jsbarcode-fontsize="10" <!-- text size -->
jsbarcode-textmargin="0"> <!-- margin below bars -->
</svg>
ajousprints/
├── admin/
│ ├── setup.php # Module configuration
│ └── about.php # Module information
├── core/
│ └── modules/
│ ├── product/
│ │ └── pdf_Dymo.modules.php
│ └── propale/
│ └── pdf_Propale1.modules.php
├── templates/
│ ├── base/
│ │ ├── header.html
│ │ └── footer.html
│ ├── dymo.html
│ └── propale.html
├── temp/
│ └── assets/
│ └── js/
├── functions/
│ └── utils.php
└── README.md
- GitHub Issues: [Repository URL]
- Email: support@example.com
- Documentation: [Wiki URL]
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
GPLv3 or later
- Initial release
- Dymo label support
- Commercial proposal template
- Basic template system
- Dolibarr ERP & CRM
- Gotenberg
- JsBarcode
- Handlebars.js