Make PDF or Word file in PHP SDK

To create a document from scratch programmatically use our powerful PHP library

With this solution, PHP developers can easily make documents in PDF, DOC, DOCX, HTML, EPUB and many other formats with just a few lines of code. Our solution will provide you with everything you need to create a file using PHP SDK.

View code snippet

Make a document using PHP

With our REST API, PHP developers can create documents in almost any format. To do this, you need to perform a few steps using our PHP Cloud SDK:

  1. Set file name
  2. Call the 'CreateDocument' method to create a document in PHP
  3. Save the output file in the selected format

Since an empty document is supposed to formally contain one paragraph, when you programmatically create a document, you will get just such a basic structure.

Note that it is possible to add content to a newly created document instantly. Thus, you will get not just an empty document, but a document that contains the required content. For more information on how to modify a document, see the 'Edit a Document' page.

Create a document in PHP

As already mentioned, our PHP Cloud SDK allows you to programmatically create documents in any supported format. For example, you can make PDF, DOCX, DOC, RTF, ODT, EPUB, HTML and files in other formats. You can try our powerful functionality and evaluate how to create a document using the following PHP example:

Select the target format from the list
Run code
use Aspose\Words\WordsApi;

$wordsApi = new WordsApi("##################", '##################');
$fileName = "Output.docx";

$createDocumentRequest = new CreateDocumentRequest(
    $fileName, NULL, NULL
);
$wordsApi->createDocument($createDocumentRequest);

$downloadDocumentRequest = new DownloadFileRequest(
    $fileName, NULL, NULL
);
$wordsApi->downloadFile($downloadDocumentRequest);
Run code
  
Copy PHP code to the clipboard

How to make Word or PDF document programmatically

  1. Install Aspose.Words Cloud for PHP
  2. Add a library reference (import the library) to your PHP project
  3. Configure API using your app keys
  4. Set the name of a new document
  5. Create a request to make a document, passing the name of this document
  6. Call the createDocument() method, passing the request
  7. Get the result of the document creation operation as a separate file

PHP library to use document creating

Install 'Aspose.Words Cloud SDK for PHP' from Packagist repository. Just run composer require aspose-cloud/aspose-words-cloud to install the SDK, then use require_once('vendor/autoload.php'); to import it into your project.

As an alternative, you can manually clone Aspose.Words Cloud SDK for PHP source code from GitHub. Please follow these Instructions to quickly get the necessary security credentials and access our REST API.

System Requirements

PHP 7.1 or newer

Refer to the Repository Documentation to see more details.

Most popular formats for operations to make a document

5%

Subscribe to Aspose Product Updates

Get monthly newsletters and offers directly delivered to your mailbox.

© Aspose Pty Ltd 2001-2024. All Rights Reserved.