Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.Words can load even such a complex format as PDF. This opens up new opportunities: it is possible to convert PDF to Word or other formats that bring users far ahead in solving many applied problems.
The most popular conversion from PDF is conversion to Microsoft Word formats such as DOCX, DOC, as well as image formats such as JPG or PNG. With that said, converting a document from one format to another performs in a familiar way.
The following code example shows how to convert a document from PDF to DOCX:
Aspose.Words provides you with the PdfLoadOptions class, which allows more precise control over how PDF documents are loaded.
Most properties inherit or overload properties that already exist in the LoadOptions class. In addition to them, a number of properties are specified for PDF format. For example, you can use the pageCount and pageIndex properties to define the page range to be loaded from a PDF document, and the skipPdfImages properties to control whether images should be skipped when loading PDF. Another supported parameter is the password, which must be provided for password-protected documents.
PDF2Word currently supports the following data types:
Some features are still in early development or included in the development roadmap:
PAGE and NUMPAGES)During a PDF document conversion, one of the following exceptions might happen:
| Exception | Description |
|---|---|
| FileLoadException | A PDF file cannot be processed for some reason.
You can report the issue to the development team for a detailed investigation using the technical support.
|
| DrmProtectedFileException | A PDF file is protected by Adobe DRM and cannot be decoded by Pdf2Word. |
| PasswordProtectedFileException | The correct password must be provided for a password‑protected PDF. |
Problem: FileLoadException is thrown when loading a PDF.
Solution: Verify that the file path is correct and the file is not corrupted. Ensure the PDF version is supported by Aspose.Words. If the file is large, increase the memory limit for the Node.js process or load the document in smaller page ranges using PdfLoadOptions.PageIndex and PdfLoadOptions.PageCount.
Problem: DrmProtectedFileException occurs during conversion.
Solution: Aspose.Words does not support Adobe DRM‑protected PDFs. Remove DRM protection with a tool that can legally decrypt the file before loading it with Aspose.Words, or obtain an unprotected version of the PDF.
Problem: PasswordProtectedFileException is raised for a password‑protected PDF.
Solution: Supply the password through PdfLoadOptions. Example:
const aspose = require("aspose.words");
const loadOptions = new aspose.words.loading.PdfLoadOptions();
loadOptions.password = "MySecretPassword";
const doc = new aspose.words.Document("protected.pdf", loadOptions);
doc.save("output.docx");
Problem: Images are missing in the converted Word document.
Solution: Ensure that PdfLoadOptions.SkipPdfImages is set to false (the default). If it has been changed, reset it:
const loadOptions = new aspose.words.loading.PdfLoadOptions();
loadOptions.skipPdfImages = false; // keep images
const doc = new aspose.words.Document("source.pdf", loadOptions);
Problem: Only a subset of pages is converted or the output is empty.
Solution: Check the values of PdfLoadOptions.PageIndex and PdfLoadOptions.PageCount. Setting PageIndex to 0 and PageCount to a value greater than the total pages loads the entire document. Example:
const loadOptions = new aspose.words.loading.PdfLoadOptions();
loadOptions.pageIndex = 0; // start from the first page
loadOptions.pageCount = 0; // 0 means all pages
const doc = new aspose.words.Document("source.pdf", loadOptions);
doc.save("full_output.docx");
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.