Developing a Print Forms Module for 1C-Bitrix
Bitrix lacks built-in document generation mechanism. Orders can be printed via browser, but yield unformatted pages without details, signatures, and branding. Legally significant documents — invoice, packing list, act — must be created manually. Print forms module closes this gap: manager clicks button and gets PDF.
Required Documents
Typical e-commerce set:
- Invoice — seller/buyer details, product table, total in words
- Packing List TORG-12 — unified form with filled fields
- Act of Services — for services
- UPD — universal transfer document
- Contract — with buyer data and order parameters
Document set determined per project.
PDF Generation Approaches
Approach 1: HTML → PDF via mPDF/TCPDF — Document template written as HTML/CSS, then converted to PDF. Easier to edit — designer works with standard HTML. Drawback: complex table forms with exact positioning render worse.
Approach 2: PhpSpreadsheet → XLSX/PDF — Document template is Excel file with cells and formulas. Data substituted into named cells, document saved as XLSX or converted to PDF. Perfect for precise table forms (TORG-12, UPD).
In practice, first approach for invoices/acts, second for packing lists.
Module Architecture
local/modules/vendor.printforms/
├── lib/
│ ├── DocumentFactory.php # Document factory
│ ├── Template/
│ │ ├── BaseTemplate.php
│ │ ├── InvoiceTemplate.php # Invoice
│ │ └── Torg12Template.php # TORG-12
│ ├── Renderer/
│ │ ├── MpdfRenderer.php
│ │ └── XlsxRenderer.php
│ └── AmountInWords.php # Sum in words
├── templates/ # Document HTML templates
└── admin/ # Admin pages
Data Substitution
Document data collected from multiple sources:
class InvoiceTemplate extends BaseTemplate
{
public function getData(int $orderId): array
{
$order = \Bitrix\Sale\Order::load($orderId);
$basket = $order->getBasket();
$propertyCollection = $order->getPropertyCollection();
$buyer = [
'name' => $propertyCollection->getPayerName()->getValue(),
'inn' => $propertyCollection->getItemByCode('INN')?->getValue(),
'address' => $propertyCollection->getAddress()->getValue(),
];
// ... more data
}
}
Generation on Demand
In order admin page, "Download Invoice" button triggers:
GET /bitrix/admin/order_print.php?ORDER_ID=123&DOCUMENT=invoice
Script renders template, passes to renderer, returns PDF with appropriate headers.
Сроки разработки
| Stage | Duration |
|---|---|
| Base setup, Invoice + TORG-12 | 8–10 days |
| + Act, UPD, Contract templates | 12–16 days |
| + Admin UI, batch generation, email sending | 16–20 days |







