-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Word to PDF conversion issues #1023
Comments
I have the same problem! |
To convert .docx to pdf I am checking the command line doc2pdf, I did the test with this and work ok! also I did a test using the soffice of libreoffice which mean that you need to install the libreoffice. Bc I cannot see a librery on php or python or ruby that convert correctly a docx to pdf. |
I got the same problem. |
I also have the problem. |
I got same problem. $PdfPath = realpath(DIR).'/phpoffice/phpword/vendor/tecnickcom/tcpdf'; // set default monospaced font // set image scale factor $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($pdf ,'PDF'); |
I can not solve this problem with php,I just used python.
…------------------ 原始邮件 ------------------
发件人: "moly4565"<[email protected]>;
发送时间: 2019年12月2日(星期一) 晚上6:24
收件人: "PHPOffice/PHPWord"<[email protected]>;
抄送: "罗永均"<[email protected]>;"Comment"<[email protected]>;
主题: Re: [PHPOffice/PHPWord] Word to PDF conversion issues (#1023)
I got same problem.
I lost header footer,radio button when converting word to pdf. pls help me.
my code below
define('PHPWORD_BASE_DIR', realpath(DIR));
require 'phpoffice/phpword/vendor/autoload.php';
require 'phpoffice/phpword/vendor/tecnickcom/tcpdf/tcpdf.php';
$PdfPath = realpath(DIR).'/phpoffice/phpword/vendor/tecnickcom/tcpdf';
\PhpOffice\PhpWord\Settings::setPdfRendererPath($PdfPath);
\PhpOffice\PhpWord\Settings::setPdfRendererName('TCPDF');
//echo $paths=realpath(DIR).'/'.$fpdf1;
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->AddPage();
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->setPrintHeader(true);
$pdf->setPrintFooter(true);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf = \PhpOffice\PhpWord\IOFactory::load(realpath(DIR).'/'.$file);
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($pdf ,'PDF');
$xmlWriter->save('pdf/'.substr($file,5,-5).'.pdf');
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I problem.. not converting header.. |
I am having problems with tabulators. They are just moved to the left.. |
I have the same problem. |
Anyone has a tip for it please ? |
Hello,
I am using PHPWord with Cakephp 1.3. I used TCPDF, DomPDF, and MPDF to convert a Resume/CV docx to PDF but the output file is not as expected. On page 2 onwards, it contains a lot of extra spaces, a single word is broken into multiple lines, and images (e.g. logo ) is not coming (pls see attachment). Any tips on getting this to work? Thanks
Below is the code I wrote:
Using MPDF:
App::import('Vendor', 'doctopdf/vendor/autoload');
\PhpOffice\PhpWord\Settings::setPdfRendererPath(APP.'vendors'.DS.'mpdf'.DS.'mpdf.php');
\PhpOffice\PhpWord\Settings::setPdfRendererName('MPDF');
$phpWord = \PhpOffice\PhpWord\IOFactory::load($docPath);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'PDF');
$objWriter->save($PdfPath,true);
Using TCPDF:
App::import('Vendor', 'doctopdf/vendor/autoload');
\PhpOffice\PhpWord\Settings::setPdfRendererPath(APP.'vendors'.DS.tcpdf'.DS.'tcpdf.php');
\PhpOffice\PhpWord\Settings::setPdfRendererName('TCPDF');
$phpWord = \PhpOffice\PhpWord\IOFactory::load($docPath);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'PDF');
$objWriter->save($PdfPath,true);
Using DomPDF I am getting error :
Fatal error: Uncaught exception 'DOMPDF_Exception' with message 'An input file is required (i.e. input_file _GET variable).' in C:\xampp\htdocs\recruiter\app\vendors\dompdf\dompdf.php:199 Stack trace: #0 C:\xampp\htdocs\recruiter\app\vendors\doctopdf\vendor\phpoffice\phpword\src\PhpWord\Writer\PDF\AbstractRenderer.php(89): require_once() #1 C:\xampp\htdocs\recruiter\app\vendors\doctopdf\vendor\phpoffice\phpword\src\PhpWord\Writer\PDF.php(61): PhpOffice\PhpWord\Writer\PDF\AbstractRenderer->__construct(Object(PhpOffice\PhpWord\PhpWord)) #2 C:\xampp\htdocs\recruiter\app\vendors\doctopdf\vendor\phpoffice\phpword\src\PhpWord\IOFactory.php(44): PhpOffice\PhpWord\Writer\PDF->__construct(Object(PhpOffice\PhpWord\PhpWord)) #3 C:\xampp\htdocs\recruiter\app\controllers\candidates.php(9755): PhpOffice\PhpWord\IOFactory::createWriter(Object(PhpOffice\PhpWord\PhpWord), 'PDF') #4 C:\xampp\htdocs\recruiter\app\controllers\candidates.php(8590): CandidatesController->convertDocToPdf('C:\xampp\ht in C:\xampp\htdocs\recruiter\app\vendors\dompdf\dompdf.php on line 199
Attachment: Alok_Kumar.pdf
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: