Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

313
Views
How to convert docx file to pdf using tbszip

Hello I want to convert my doc file to pdf. In this code I changed newfile.docx to newfile.pdf but it won't work. How do I save the file as pdf?

$x = "Hello World!";

include_once('includes/tbszip.php');

$zip = new clsTbsZip();

// Open the document
$zip->Open('mydoc.docx');
$content = $zip->FileRead('word/document.xml');
$p = strpos($content, '</w:body>');
if ($p===false) exit("Tag </w:body> not found in document.");

// Add the text at the end
$content = substr_replace($content, '<w:p><w:r><w:t>'.$x.'</w:t></w:r></w:p>', $p, 0);
$zip->FileReplace('word/document.xml', $content, TBSZIP_STRING);

// Save as a new file
$zip->Flush(TBSZIP_FILE, 'newfile.pdf');
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

TbsZip can read (and write) a zip archive, such as a DOCX. But it cannot make file conversion.

A file conversion is not simply changing extension. It consists in converting all structured data. A DOCX is made of several XML sub-files, while a PDF is binary.

I don't know any PHP library that can convert DOCX to PDF.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!