@raymondcamden/pdfservice_sdk_foxit
v1.0.0
Published
A SDK wrapper for Foxit's PDF Services and Document Generation APIs.
Downloads
32
Maintainers
Readme
Foxit PDF Services SDK
This SDK lets developers more easily use the Foxit APIs, including PDF Services and Document Generation. You will need a free set of credentials in order to call the APIs.
Usage
Copy your credentials to the environment and then instantiate the SDK. Here's a sample:
import { PDFServiceSDK } from "./PDFServiceSDK.mjs";
const clientId = process.env.CLIENT_ID;
const clientSecret = process.env.CLIENT_SECRET;
const pdfService = new PDFServiceSDK(clientId, clientSecret);
await pdfService.wordToPDF('assets/input/input.docx', 'assets/output/output_from_nodesdk.pdf');
console.log("PDF conversion completed successfully.");
// v2 change that uses new conversion method
await pdfService.conversion('assets/input/input.docx', 'assets/output/output_from_nodesdk_v2.pdf');
console.log("PDF conversion (second version)completed successfully.");You can optionally pass credentials for the 4th and 5th parameter to the constructor:
const clientId = process.env.CLIENT_ID;
const clientSecret = process.env.CLIENT_SECRET;
const dgClientId = process.env.DG_CLIENT_ID;
const dgClientSecret = process.env.DG_CLIENT_SECRET;
const host = process.env.HOST;
const pdfService = new PDFServiceSDK(clientId, clientSecret, host, dgClientId, dgClientSecret);If you don't know the host, it is https://na1.fusion.foxit.com.
Methods Supported
- conversion(inputPath, outputPath) - general conversion method
- excelToPDF, htmlToPDF, imageToPDF, pdfToExcel, pdfToHTML, pdfToImage, pdfToPowerpoint, pdfToText, pdfToWord, powerpointToWord, textToPDF, wordToPDF - all take an inputPath and outputPath argument
- url_to_pdf(url, outputPath) - convert a URL to pdf
- extractPDF(inputPath, outputPath, type (one of TEXT, IMAGE, PAGE), page_range) - extracts either text, images (zip), or pages (new pdf)
- download(docId, outputPath) - given a document id and path, will stream the data down
- upload(path) - upload a document and return a path
- compress(inputPath,outputPath,compressionLevel) - compresses a PDF, default level is LOW
- linearize(inputPath,outputPath) - linearizes a PDF
- flatten(inputPath,outputPath) - flattens a PDF
- combine(inputPaths[], outputPath, options) - combines a set of PDFs
- removePassword(inputPath,outputPath,password) - removes password
- protectPDF(input_path, output_path, config) - modifies permissions for a PDF - see API ref for details on the
configparam - splitPDF(inputPath,outputPath,pageCount) - splits a PDF into
pageCountnew PDFs. Returns a zip of the PDFs. - manipulatePDF(inputPath, outputPath, operations) - performs multiple operations for a PDF - see API ref for details on the
operationsparam - docgen(inputPath,outputPath,data) - document generation using data
To Do:
- Make output path optional and just return the doc id
- Make checking a task public and a utility pollTask to handle repeating (this and the previous two methods would let devs chain calls)
History
| Date | Change | |------|-----------| | 8/11/2025 | Added splitPDF, manipulatePDF, compare, docgen. | | 8/7/2025 | Added remove password. Corrected wrong method names above. Removed unused var in Linearize. Added protectPDF | | ??? | Initial release |
