Hi, this is my docx template: http://gestionale.ebpmi.it/phpdocx/test.docx
I'd like to replace all first page products in N products maintaing same structure and attach second page at the end.
Is it possible? How?
Hi, this is my docx template: http://gestionale.ebpmi.it/phpdocx/test.docx
I'd like to replace all first page products in N products maintaing same structure and attach second page at the end.
Is it possible? How?
Hello,
We recommend you to create a table with a placeholder foreach column and use the method replaceTableVariable (http://www.phpdocx.com/api-documentation/templates/replace-table-variable-Word-document) to add as many values as needed.
To attach a page after other you can use the MultiMerge class: mergeDocx (http://www.phpdocx.com/api-documentation/docxutilities/merge-Word-documents-with-PHP).
Regards.
Hello,
If you're using a template you can set a header as default, if you're creating the document from scratch the addHeader method allows to set a header as the default one with the headers parameter and if you are doing a merge you can overwrite the headers using the importHeadersAndFooters method (http://www.phpdocx.com/api-documentation/layout-and-general/import-headers-and-footers-Word-document-with-PHP).
Regards.
As you saw on my attach file, i need to merge second page as last and include in it last products if it is necessary because last table with totals must appear only in last page.
If i merge it as last page it remains blank...
Can you help me?
Thanks
Hello,
After you have the DOCX merged you just need to use the importHeadersAndFooters method to add the headers to all pages of the document.
The steps are:
1. Generate a new document replacing the content of the template.
2. Merge the DOCX if needed. To do this you need the document of the previous step and the other document to merge with.
3. Import the headers to the document merged in the previous step to add the headers to all pages.
If you want to attach the second page to the end, you'll need to have this second page as a standalone DOCX to be merged. You can't split an existing document.
Regards.
ok thanks. Last question, i'm in web hosting and i don't know if is possible to use libreoffice or openoffice to covert docx in pdf. I tried and no output was created. Is there an alternative method?
Thanks
Hello,
You can transform very simple documents using the TransformDoc.inc class. But to use the conversion plugin you need to install LibreOffice or OpenOffice on your server.
Regards.
Hi, if i use TransformDoc.inc and function generatePDF it gives me an error: Fatal error: Class 'DOMPDF' not found
Can you help me?
I included dompdf class but pdf is very different from original docx: it misses some styles and loses header and footer.
This is my code:
require_once 'phpdocx/classes/TransformDoc.inc';
$docx2 = new TransformDoc();
$docx2->setStrFile('phpdocx/parte1d.docx');
$docx2->generateXHTML();
$html = $docx2->getStrXHTML();
$docx2->generatePDF('phpdocx/parte1d.pdf');
Hello,
You need to include the DOMPDF lib (it's included within the package in the lib folder):
require_once 'classes/TransformDoc.inc';
require_once 'lib/pdf/dompdf_config.inc.php';
$transform = new TransformDoc();
$transform->setstrFile('Text.docx');
$transform->generatePDF();
Note you need to redirect the output of this command to save the PDF:
$ php test.php > Test.pdf
or through ob_ functions of PHP.
And as explained it only returns a good output for very simple documents. The recommended approach is using the conversion plugin.
Regards.