phpword

Generate PDF from .docx generated by PHPWord

元气小坏坏 提交于 2020-01-12 14:07:39
问题 I am creating .docx files from a template using PHPWord . It works fine but now I want to convert the generated file to PDF . First I tried using tcpdf in combination with PHPWord $wordPdf = \PhpOffice\PhpWord\IOFactory::load($filename.".docx"); \PhpOffice\PhpWord\Settings::setPdfRendererPath(dirname(__FILE__)."/../../Office/tcpdf"); \PhpOffice\PhpWord\Settings::setPdfRendererName('TCPDF'); $pdfWriter = \PhpOffice\PhpWord\IOFactory::createWriter($wordPdf , 'PDF'); if (file_exists($filename."

PHPWord: Insert page break and set margin and page orientation using Laravel 4

隐身守侯 提交于 2020-01-06 14:12:34
问题 I'm using PHPOffice/PHPWord, and I have a MySQL Database with a table named trials . It contains 2 columns id and name . Both columns are VARCHAR(255) . There are several rows such as below: id | name ---+----------- A1 | Avatar B1 | Browser C1 | Calculator A2 | Align The query that I use is SELECT * FROM trials ORDER BY id ASC What I'm trying to do is Make a DOC file and add a new page for each row with (1 page for 1 id and 1 for name ). How can I insert a page break between rows? Also, how

PHPWord: Insert page break and set margin and page orientation using Laravel 4

橙三吉。 提交于 2020-01-06 14:10:04
问题 I'm using PHPOffice/PHPWord, and I have a MySQL Database with a table named trials . It contains 2 columns id and name . Both columns are VARCHAR(255) . There are several rows such as below: id | name ---+----------- A1 | Avatar B1 | Browser C1 | Calculator A2 | Align The query that I use is SELECT * FROM trials ORDER BY id ASC What I'm trying to do is Make a DOC file and add a new page for each row with (1 page for 1 id and 1 for name ). How can I insert a page break between rows? Also, how

Neither image gap nor image alignment is working in phpword

巧了我就是萌 提交于 2019-12-24 10:49:52
问题 I have two images in the same row and I want to put some space between them. Currently nothing is working even I try hard to search for solution. Here is the code: $section = $phpWord->addSection($PidPageSettings); $table = $section->addTable(); $logo = 'pearson1' . $clientid . ".png"; $logo2 = 'genesis2' . $clientid . ".png"; // $table = $section->addTable(); // $table->addRow(); // $cell = $table->addCell(20000, array('bgColor' => 'ffffff')); $table = $section->addTable(); $table->addRow();

Parse a word document with PHPWord to a string

无人久伴 提交于 2019-12-24 09:20:26
问题 I've tried several solutions to parse word documents to a string in PHP, however they sometimes have trouble with certain word documents. So I'm now trying PHPWord to attempt to parse the word document to a string. I'm looking at this sample file in PHPWord which reads a Word document and outputs to another Word document: include_once 'Sample_Header.php'; // Read contents $name = basename(__FILE__, '.php'); $source = "resources/{$name}.doc"; echo date('H:i:s'), " Reading contents from `{

Formatting a text in a table cell with PHPWord e.g. bold, font, size e.t.c

两盒软妹~` 提交于 2019-12-24 01:28:42
问题 I have the code snippet below //create a new word document $word= new PHPWord(); //create potrait orientation $section=$word->createSection(); $table = $section->addTable(); $word->addFontStyle('rStyle', array('bold'=>true, 'italic'=>true, 'size'=>16)); //header row $table->addRow(400, array('bgColor'=>'dbdbdb')); $table->addCell(2000, array('bgColor'=>'dbdbdb'))->addText('Cell 1','rStyle'); $table->addCell(3500, array('bgColor'=>'dbdbdb'))->addText('Cell 1'); $table->addCell(1500, array(

PHPWord: Replaced image doesn't gets actually replaced

我的梦境 提交于 2019-12-23 23:29:26
问题 I have a word document (template) which contains some images that I have to replace with others that are present on the drive. The images that exist in the documents are currently blank. And the ones that will replace them have some text written on them. One way to do was to edit each document and then by double-clicking the image I use the Pbrush to edit the image. Other way is below. I used PHPWord to do the job. Open the document and replace the image in the word/media . The problem: At

Add chart on phpoffice/phpword

a 夏天 提交于 2019-12-23 18:13:42
问题 I know how to add charts on PHPExcel, but I also need to insert charts on a docx file. Is it possible to manipulate charts with phpoffice/phpword? If it's not possible, do you know a good library for the job? 回答1: It's not actually possible to add chart in a PHPWord Document. But the feature is in the pipe (follow this ticket #123). But you can use of one of some libraries used (at the moment and in the future) by PHPExcel : PHP Charting Libraries . Actually, PHPExcel just use JpGraph for

PHPWord: Creating an Arabic right to left word document

﹥>﹥吖頭↗ 提交于 2019-12-23 13:00:40
问题 I'm trying to use PHPWord to create a word document that will include dynamic data pulled out from a MySQL database. The database has MySQL charset: UTF-8 Unicode (utf8) MySQL connection collation: utf8_unicode_ci and so does the table fields. Data is stored and previewed fine in HTML, however when creating the document with the arabic variables, the output in Word looks like أحÙد Ùبار٠اÙÙر٠. $PHPWord = new PHPWord(); $document = $PHPWord->loadTemplate('templates/.../wtvr.docx');

Convert HTML code to doc using PHP and PHPWord

折月煮酒 提交于 2019-12-23 09:56:10
问题 I am using PHPWord to load a docx template and replace tags like {test} . This is working perfectly fine. But I want to replace a value with html code. Directly replacing it into the template is not possible. There is now way to do this using PHPWord, as far as I know. I looked at htmltodocx. But it seams it will not work either, is it posible to transform a peace of code like <p>Test<b>test</b><br>test</p> to a working doc markup? I only need the basic code, no styleing. but Linebreaks have