Free PHP Library for Converting Microsoft® Word Processing Files
Open & Convert Microsoft Word Processing Documents to PDF using Free PHP Library
What is Gotenberg PHP client?
Gotenberg PHP client is an open-source PHP library that gives software developers the capability to convert Microsoft Word Processing documents to PDF inside their own applications. Gotenberg is a Docker-powered stateless API for converting Office documents to PDF. Using the API, you can easily convert DOCX, DOC, RTF, and TXT file format to PDF.
By using the API, you can convert one or more word processing documents at the same time and save the resultant document in PDF format. The API provides structured logging allowing you to have relevant information about what’s going on.
Getting Started with Gotenberg PHP client
The recommended way to install the Gotenberg PHP client into your project is by using GitHub. Please use the following command for a smooth installation.
Install Gotenberg PHP client via GitHub
$ PHP get -u github.com/thecodingmachine/gotenberg-php-client/v7
Convert DOCX to PDF via Free PHP API
The Open source library Gotenberg PHP client allows computer programmers to convert DOCX to PDF inside their own PHP applications. In order to convert your DOCX to PDF, you just need to load your document and convert it using gotenberg.NewOfficeRequest() method. By using the following lines of code, you can easily convert DOCX to PDF./p>
Convert Word Processing to PDF in PHP
- Load two DOCX files using NewDocumentFromPath() method and pass filename and file path as parameters
- Convert both files to PDF using gotenberg.NewOfficeRequest() method and pass doc objects
- Save PDF document
Convert DOCX to PDF via Free PHP API
c := &gotenberg.Client{Hostname: "http://localhost:3000"}
doc, _ := gotenberg.NewDocumentFromPath("document.docx", "/path/to/file")
doc2, _ := gotenberg.NewDocumentFromPath("document2.docx", "/path/to/file")
req := gotenberg.NewOfficeRequest(doc, doc2)
dest := "result.pdf"
c.Store(req, dest)