Office to PDF (Foxit conversion engine)
Foxit Office to PDF is powered by Foxit's proprietary high-performance conversion engine. It gives developers robust Office-to-PDF conversion for docx, xlsx, and pptx files. The engine can be integrated as a standalone SDK library or as a plugin in Foxit PDF SDK, extending the SDK's use cases.
See the Office to PDF example configuration and run guide for setup steps and sample code.
To learn more about Foxit's conversion engine, see Explore Foxit Conversion SDK.
The sample code below shows how to use the Office2PDF module in Foxit PDF SDK to convert different Office document types to PDF without relying on third-party engines.
Convert Office files to PDF files
c++
#include "include/common/fs_common.h"
#include "include/addon/conversion/office2pdf/fs_office2pdf.h"
...
// If you want to convert office files to PDF whitout other third-party engines, you can use the Office2PDF module.
WString library_path = L""; / Path of Foxit PDF Conversion SDK library, please ensure the path is valid.
// Initialize the Office2PDF module.
foxit::addon::conversion::office2pdf::Office2PDF::Initialize(library_path);
// Use default Office2PDFSettingData values.
foxit::addon::conversion::office2pdf::Office2PDFSettingData office2pdf_setting_data;
// A valid path of a folder which contains resource data files.
office2pdf_setting_data.resource_folder_path = L"";
// Conver Excel file to PDF file.
output_path = output_directory + L"word2pdf_result_foxit.pdf";
foxit::addon::conversion::office2pdf::Office2PDF::ConvertFromWord(word_file_path, L"", output_path, office2pdf_setting_data);
// Conver Excel file to PDF file.
output_path = output_directory + L"excel2pdf_result_foxit.pdf";
foxit::addon::conversion::office2pdf::Office2PDF::ConvertFromExcel(excel_file_path, L"", output_path, office2pdf_setting_data);
// Conver PowerPoint file to PDF file.
output_path = output_directory + L"ppt2pdf_result_foxit.pdf";
foxit::addon::conversion::office2pdf::Office2PDF::ConvertFromPowerPoint(ppt_file_path, L"", output_path, office2pdf_setting_data);
// Release the Office2PDF module.
foxit::addon::conversion::office2pdf::Office2PDF::Release();C
#include "include/fs_basictypes_c.h"
#include "include/fs_common_c.h"
#include "include/fs_office2pdf_c.h"
...
// If you want to convert office files to PDF whitout other third-party engines, you can use the Office2PDF module.
const wchar_t* library_path = L"";/ Path of Foxit PDF Conversion SDK library, please ensure the path is valid.
// Initialize the Office2PDF module.
FSDK_Office2PDF_Initialize(library_path);
FSOffice2PDFSettingData office2pdf_setting_data;
// A valid path of a folder which contains resource data files.
office2pdf_setting_data.resource_folder_path.str = L"";
office2pdf_setting_data.resource_folder_path.len = 0;
office2pdf_setting_data.is_embed_font = FALSE;
office2pdf_setting_data.word_setting_data.is_generate_bookmark = FALSE;
office2pdf_setting_data.excel_setting_data.is_separate_workbook = FALSE;
office2pdf_setting_data.excel_setting_data.is_output_hidden_workbook = FALSE;
office2pdf_setting_data.excel_setting_data.workbook_names_array = NULL;
office2pdf_setting_data.excel_setting_data.workbook_names_array_length = 0;
// Conver Word file to PDF file.
swprintf_s(output_file, MAX_FILE_PATH, L"%lsword2pdf_result_foxit.pdf", output_directory);
error_code = FSDK_Office2PDF_ConvertFromWord(word_file_path, L"", output_file, office2pdf_setting_data, &ret_value);
// Conver Excel file to PDF file.
swprintf_s(output_file, MAX_FILE_PATH, L"%lsexcel2pdf_result_foxit.pdf", output_directory);
error_code = FSDK_Office2PDF_ConvertFromExcel(excel_file_path, L"", output_file, office2pdf_setting_data, &ret_value);
// Conver PowerPoint file to PDF file.
swprintf_s(output_file, MAX_FILE_PATH, L"%lsppt2pdf_result_foxit.pdf", output_directory);
error_code = FSDK_Office2PDF_ConvertFromPowerPoint(ppt_file_path, L"", output_file, office2pdf_setting_data, &ret_value);
// Release the Office2PDF module.
FSDK_Office2PDF_Release();java
import com.foxit.sdk.addon.conversion.office2pdf.Office2PDF;
import com.foxit.sdk.addon.conversion.office2pdf.Office2PDFSettingData;
...
// If you want to convert office files to PDF whitout other third-party engines, you can use the Office2PDF module.
String library_path = "";/ Path of Foxit PDF Conversion SDK library, please ensure the path is valid.
// Initialize the Office2PDF module.
Office2PDF.initialize(library_path);
// Use default Office2PDFSettingData values.
Office2PDFSettingData office2pdf_setting_data = new Office2PDFSettingData();
// A valid path of a folder which contains resource data files.
office2pdf_setting_data.setResource_folder_path("");
// Conver Word file to PDF file.
saved_pdf_path = output_path + "word2pdf_result_foxit.pdf";
Office2PDF.convertFromWord(word_file_path, "", saved_pdf_path, office2pdf_setting_data);
// Conver Excel file to PDF file.
saved_pdf_path = output_path + "excel2pdf_result_foxit.pdf";
Office2PDF.convertFromExcel(excel_file_path, "", saved_pdf_path, office2pdf_setting_data);
// Conver PowerPoint file to PDF file.
saved_pdf_path = output_path + "ppt2pdf_result_foxit.pdf";
Office2PDF.convertFromPowerPoint(ppt_file_path, "", saved_pdf_path, office2pdf_setting_data);
// Release the Office2PDF module.
Office2PDF.release();py
# If you want to convert office files to PDF whitout other third-party engines, you can use the Office2PDF module.
library_path = "" # Path of Foxit PDF Conversion SDK library, please ensure the path is valid.
# Initialize the Office2PDF module.
Office2PDF.Initialize(library_path)
# Use default Office2PDFSettingData values.
office2pdf_setting_data = Office2PDFSettingData()
# A valid path of a folder which contains resource data files.
office2pdf_setting_data.resource_folder_path = ""
# Conver Word file to PDF file.
output_path = output_directory + "word2pdf_result_foxit.pdf"
Office2PDF.ConvertFromWord(word_file_path, "", output_path, office2pdf_setting_data)
# Conver Excel file to PDF file.
output_path = output_directory + "excel2pdf_result_foxit.pdf"
Office2PDF.ConvertFromExcel(excel_file_path, "", output_path, office2pdf_setting_data)
# Conver PowerPoint file to PDF file.
output_path = output_directory + "ppt2pdf_result_foxit.pdf"
Office2PDF.ConvertFromPowerPoint(ppt_file_path, "", output_path, office2pdf_setting_data)
# Release the Office2PDF module.
Office2PDF.Release()js
const FSDK = require("@fuxinsoft/foxit-pdf-sdk-node");
...
// If you want to convert office files to PDF whitout other third-party engines, you can use the Office2PDF module.
let library_path = ""; / Path of Foxit PDF Conversion SDK library, please ensure the path is valid.
// Initialize the Office2PDF module.
FSDK.Office2PDF.Initialize(library_path);
// Use default Office2PDFSettingData values.
let office2pdf_setting_data = new FSDK.Office2PDFSettingData();
// A valid path of a folder which contains resource data files.
office2pdf_setting_data.resource_folder_path = "";
// Conver Word file to PDF file.
output_path = output_directory + "word2pdf_result_foxit.pdf";
FSDK.Office2PDF.ConvertFromWord(word_file_path, "", output_path, office2pdf_setting_data);
// Conver Excel file to PDF file.
output_path = output_directory + "excel2pdf_result_foxit.pdf";
FSDK.Office2PDF.ConvertFromExcel(excel_file_path, "", output_path, office2pdf_setting_data);
// Conver PowerPoint file to PDF file.
output_path = output_directory + "ppt2pdf_result_foxit.pdf";
FSDK.Office2PDF.ConvertFromPowerPoint(ppt_file_path, "", output_path, office2pdf_setting_data);
// Release the Office2PDF module.
FSDK.Office2PDF.Release();csharp
using foxit;
...
// If you want to convert office files to PDF whitout other third-party engines, you can use the Office2PDF module.
string library_path = ""; / Path of Foxit PDF Conversion SDK library, please ensure the path is valid.
// Initialize the Office2PDF module.
foxit.addon.conversion.office2pdf.Office2PDF.Initialize(library_path);
// Use default Office2PDFSettingData values.
using (foxit.addon.conversion.office2pdf.Office2PDFSettingData office2pdf_setting_data = new foxit.addon.conversion.office2pdf.Office2PDFSettingData())
{
/ A valid path of a folder which contains resource data files.
office2pdf_setting_data.resource_folder_path = "";
/ Convert Word file to PDF file.
saved_pdf_path = output_path + "word2pdf_result_foxit.pdf";
foxit.addon.conversion.office2pdf.Office2PDF.ConvertFromWord(word_file_path, "", saved_pdf_path, office2pdf_setting_data);
/ Convert Excel file to PDF file.
saved_pdf_path = output_path + "excel2pdf_result_foxit.pdf";
foxit.addon.conversion.office2pdf.Office2PDF.ConvertFromExcel(excel_file_path, "", saved_pdf_path, office2pdf_setting_data);
/ Convert PowerPoint file to PDF file.
saved_pdf_path = output_path + "ppt2pdf_result_foxit.pdf";
foxit.addon.conversion.office2pdf.Office2PDF.ConvertFromPowerPoint(ppt_file_path, "", saved_pdf_path, office2pdf_setting_data);
}
// Release the Office2PDF module.
foxit.addon.conversion.office2pdf.Office2PDF.Release();go
# If you want to convert office files to PDF whitout other third-party engines, you can use the Office2PDF module.
library_path := "" # Path of Foxit PDF Conversion SDK library, please ensure the path is valid.
# Initialize the Office2PDF module.
Office2PDFInitialize(library_path)
# Use default Office2PDFSettingData values.
office2pdf_setting_data := NewOffice2PDFSettingData()
# A valid path of a folder which contains resource data files.
office2pdf_setting_data.SetResource_folder_path("")
# Conver Word file to PDF file.
output_path := output_directory + "word2pdf_result_foxit.pdf"
Office2PDFConvertFromWord(word_file_path, "", output_path, office2pdf_setting_data)
# Conver Excel file to PDF file.
output_path = output_directory + "excel2pdf_result_foxit.pdf"
Office2PDFConvertFromExcel(excel_file_path, "", output_path, office2pdf_setting_data)
# Conver PowerPoint file to PDF file.
output_path = output_directory + "ppt2pdf_result_foxit.pdf"
Office2PDFConvertFromPowerPoint(ppt_file_path, "", output_path, office2pdf_setting_data)
# Release the Office2PDF module.
Office2PDFRelease()