PDF Conversion

Convert to and from PDF

Drop a PDF to turn it into Word, Excel, PowerPoint or Markdown. Drop any of those to get a PDF. Powered by Foxit PDF Conversion SDK 4.0; no Microsoft Office involved.

Machine
No file handy? Try a sample: · · · ·

How it works

Your file goes to a small C++ program built on Foxit PDF Conversion SDK 4.0. It makes one SDK call for the conversion, with the options you set, and hands the result back. The eight conversions and the calls behind them:

ConversionSDK callAccepts
PDF → WordPDF2Office::StartConvertToWordPDF
PDF → ExcelPDF2Office::StartConvertToExcelPDF
PDF → PowerPointPDF2Office::StartConvertToPowerPointPDF
PDF → MarkdownPDF2Md::ConvertToMarkdownPDF with a text layer
Word → PDFOffice2PDF::ConvertFromWord.docx, .doc, and .docm, .dotx, .dotm
Excel → PDFOffice2PDF::ConvertFromExcel.xlsx, and .xlsm, .xltx, .xltm
PowerPoint → PDFOffice2PDF::ConvertFromPowerPoint.pptx, and .pptm, .ppsx, .ppsm, .potx, .potm
Markdown → PDFMd2PDF::ConvertFromMarkdown.md, or a .zip of one .md with its images

PDF to Office rebuilds structure rather than tracing the page: paragraphs reflow, tables become real tables, headers and footers go where Word keeps them. Turn on machine-learning layout recognition for borderless tables and awkward layouts; it is slower.

Office to PDF uses Foxit’s own layout engine. Microsoft Office is not installed on either machine. The SDK goes by the file’s extension and knows .doc, .docx, .xlsx and .pptx; macro-enabled and template files are the same format inside, so this demo hands them over under the plain extension. Older binary files (.xls, .ppt) and password-protected Office files are not supported.

Markdown is new in 4.0. PDF to Markdown writes images to a folder beside the .md file, so a PDF with pictures comes back as a zip. That zip can be dropped straight back in to make a PDF.

Pick the machine. The same source file (foxit_convert.cpp) is compiled for Windows and for Linux. Converting to PDF depends on the fonts installed on the machine, so the two can lay out the same document a little differently: where a font is missing, the SDK substitutes the nearest match.

Sample implementation code

The same four conversion families in every language the SDK ships for. Each sample sets a few options and makes one call per family.

#include "common/fs_common.h"
#include "conversion/fs_pdf2office.h"
#include "conversion/fs_office2pdf.h"
#include "conversion/fs_pdf2md.h"
#include "conversion/fs_md2pdf.h"

using namespace foxit;
using namespace foxit::common;
using namespace foxit::conversion;

static void convert_all() {
  // --- PDF -> Word / Excel / PowerPoint (progressive) ---
  pdf2office::PDF2OfficeSettingData to_office;
  to_office.metrics_data_folder_path = L"res/metrics_data";   // ships with the SDK
  to_office.enable_ml_recognition = true;                     // borderless tables
  to_office.page_range.AddSegment(0, 1);                      // pages 1-2 (0-based)
  to_office.word_setting_data.enable_generate_headers_and_footers = true;
  to_office.excel_setting_data.workbook_settings =
      pdf2office::PDF2ExcelSettingData::e_WorkbookSettingsEachTable;

  Progressive p = pdf2office::PDF2Office::StartConvertToWord(
      L"report.pdf", L"" /* password */, L"./report.docx", to_office);
  // StartConvertToExcel / StartConvertToPowerPoint take the same arguments.
  if (p.GetRateOfProgress() != 100) {
    Progressive::State state = Progressive::e_ToBeContinued;
    while (state == Progressive::e_ToBeContinued) state = p.Continue();
  }

  // --- Word / Excel / PowerPoint -> PDF ---
  office2pdf::Office2PDFSettingData to_pdf;
  to_pdf.resource_folder_path = L"res/office2pdf";            // ships with the SDK
  to_pdf.is_embed_font = true;
  to_pdf.word_setting_data.is_generate_bookmark = true;       // headings -> bookmarks
  office2pdf::Office2PDF::ConvertFromWord(L"report.docx", NULL, L"report.pdf", to_pdf);
  office2pdf::Office2PDF::ConvertFromExcel(L"table.xlsx", NULL, L"table.pdf", to_pdf);
  office2pdf::Office2PDF::ConvertFromPowerPoint(L"deck.pptx", NULL, L"deck.pdf", to_pdf);

  // --- PDF -> Markdown (images go to a folder beside the .md) ---
  pdf2md::PDF2MdSettingData to_md;
  to_md.table_format = pdf2md::PDF2MdSettingData::e_TableFormatMarkdown;
  to_md.skip_ocr_pages = true;        // skip scanned pages instead of throwing e_ErrNeedOCR
  pdf2md::PDF2Md::ConvertToMarkdown(L"report.pdf", L"", L"report.md", L"images", to_md);

  // --- Markdown -> PDF (sizes in points) ---
  md2pdf::Md2PDFSettingData from_md;
  from_md.page_width = 595; from_md.page_height = 842;        // A4
  from_md.base_font_size = 11;
  md2pdf::Md2PDF::ConvertFromMarkdown(L"report.md", L"", L"report.pdf", from_md);
}

int main() {
  if (Library::Initialize(sn, key) != e_ErrSuccess) return 1;
  try {
    convert_all();           // SDK objects must be gone before Release()
  } catch (const Exception& e) {
    // e_ErrPassword, e_ErrNeedOCR, e_ErrNoPDF2OfficeModuleRight, ...
    printf("%s\n", (const char*)e.GetMessage());
  }
  Library::Release();
  return 0;
}
#include <wchar.h>
#include <stdio.h>
#include "fs_basictypes_c.h"
#include "fs_common_c.h"
#include "fs_pdf2office_c.h"
#include "fs_office2pdf_c.h"
#include "fs_pdf2md_c.h"
#include "fs_md2pdf_c.h"

#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif

static FS_BOOL need_to_pause(void* user_data) { return FALSE; }
static void progress(void* user_data, int converted_count, int total_count) {}

static FS_WSTR wstr(const wchar_t* s) {
  FS_WSTR w; w.str = (wchar_t*)s; w.len = s ? wcslen(s) : 0; return w;
}

int main(void) {
  FS_BOOL ok = FALSE;
  if (FSDK_Library_Initialize(sn, key) != e_FSErrSuccess) return 1;

  /* --- PDF -> Word / Excel / PowerPoint (progressive) --- */
  FSPDF2OfficeSettingData to_office;
  to_office.metrics_data_folder_path = wstr(L"res/metrics_data");   /* ships with the SDK */
  to_office.enable_ml_recognition = TRUE;                           /* borderless tables */
  to_office.include_pdf_comments = TRUE;
  to_office.include_images = TRUE;
  to_office.enable_trailing_space = TRUE;
  to_office.enable_matching_system_fonts = FALSE;
  FSDK_Range_Create1(0, 1, e_FSAll, &to_office.page_range);        /* pages 1-2 (0-based) */

  to_office.word_setting_data.enable_retain_page_layout = FALSE;
  to_office.word_setting_data.enable_generate_headers_and_footers = TRUE;
  to_office.word_setting_data.enable_generate_footnotes_and_endnotes = FALSE;
  to_office.word_setting_data.enable_generate_page_rendered_break = FALSE;
  to_office.word_setting_data.max_blank_paragraphs_per_page_bottom = 0;
  to_office.power_point_setting_data.enable_aggressively_split_sections = FALSE;
  to_office.power_point_setting_data.enable_adapt_to_largest_page = FALSE;
  to_office.excel_setting_data.decimal_symbol.str = NULL;          /* automatic */
  to_office.excel_setting_data.decimal_symbol.len = 0;
  to_office.excel_setting_data.thousands_separator.str = NULL;
  to_office.excel_setting_data.thousands_separator.len = 0;
  to_office.excel_setting_data.workbook_settings = e_FSWorkbookSettingsEachTable;
  to_office.excel_setting_data.enable_aggressive_table_repair = TRUE;
  to_office.excel_setting_data.include_watermarks = FALSE;

  FSConvertCallback callback;
  callback.user_data = NULL;
  callback.NeedToPause = need_to_pause;
  callback.ProgressNotify = progress;

  FS_PROGRESSIVE_HANDLE progressive = NULL;
  FSErrorCode err = FSDK_PDF2Office_StartConvertToWord(
      L"report.pdf", NULL /* password */, L"./report.docx", to_office, &callback, &progressive);
  /* FSDK_PDF2Office_StartConvertToExcel / ...ToPowerPoint take the same arguments. */
  if (err == e_FSErrSuccess) {
    int rate = 0;
    FSDK_Progressive_GetRateOfProgress(progressive, &rate);
    if (rate != 100) {
      FSState state = e_FSToBeContinued;
      while (state == e_FSToBeContinued) FSDK_Progressive_Continue(progressive, &state);
    }
    FSDK_Progressive_Release(progressive);
  } else {
    printf("PDF to Word failed: %d\n", err);      /* e.g. e_FSErrNoPDF2OfficeModuleRight */
  }
  FSDK_Range_Release(to_office.page_range);

  /* --- Word / Excel / PowerPoint -> PDF --- */
  FSOffice2PDFSettingData to_pdf;
  to_pdf.resource_folder_path = wstr(L"res/office2pdf");            /* ships with the SDK */
  to_pdf.is_embed_font = TRUE;
  to_pdf.word_setting_data.is_generate_bookmark = TRUE;             /* headings -> bookmarks */
  to_pdf.excel_setting_data.is_separate_workbook = FALSE;
  to_pdf.excel_setting_data.is_output_hidden_worksheets = FALSE;
  to_pdf.excel_setting_data.worksheet_names_array = NULL;           /* all worksheets */
  to_pdf.excel_setting_data.worksheet_names_array_length = 0;
  FSDK_Office2PDF_ConvertFromWord(L"report.docx", L"", L"report.pdf", to_pdf, &ok);
  FSDK_Office2PDF_ConvertFromExcel(L"table.xlsx", L"", L"table.pdf", to_pdf, &ok);
  FSDK_Office2PDF_ConvertFromPowerPoint(L"deck.pptx", L"", L"deck.pdf", to_pdf, &ok);

  /* --- PDF -> Markdown (images go to a folder beside the .md) --- */
  FSPDF2MdSettingData to_md;
  to_md.table_format = e_FSTableFormatMarkdown;
  to_md.include_header_footer = FALSE;
  to_md.enable_italic = TRUE;
  to_md.enable_bold = FALSE;
  to_md.skip_ocr_pages = TRUE;                    /* skip scanned pages instead of failing */
  FSDK_PDF2Md_ConvertToMarkdown(L"report.pdf", L"", L"report.md", L"images", to_md, &ok);

  /* --- Markdown -> PDF (sizes in points) --- */
  FSMd2PDFSettingData from_md;
  from_md.page_width = 595.0f;  from_md.page_height = 842.0f;       /* A4 */
  from_md.margin_top = from_md.margin_bottom = 72.0f;
  from_md.margin_left = from_md.margin_right = 72.0f;
  from_md.base_font_size = 11.0f;
  from_md.custom_font_path = wstr(L"");
  from_md.style_config_path = wstr(L"");
  from_md.is_embed_font = FALSE;
  FSDK_Md2PDF_ConvertFromMarkdown(L"report.md", L"", L"report.pdf", from_md, &ok);

  FSDK_Library_Release();
  return 0;
}
using System;
using foxit;
using foxit.common;
using foxit.conversion.pdf2office;
using foxit.conversion.office2pdf;
using foxit.conversion.pdf2md;
using foxit.conversion.md2pdf;

class Convert
{
    static void Main()
    {
        if (Library.Initialize(sn, key) != ErrorCode.e_ErrSuccess) return;
        try
        {
            // --- PDF -> Word / Excel / PowerPoint (progressive) ---
            using (var toOffice = new PDF2OfficeSettingData())
            using (var word = new PDF2WordSettingData())
            using (var excel = new PDF2ExcelSettingData())
            using (var pages = new foxit.common.Range())
            {
                toOffice.metrics_data_folder_path = "res/metrics_data";   // ships with the SDK
                toOffice.enable_ml_recognition = true;                    // borderless tables
                pages.AddSegment(0, 1);                                   // pages 1-2 (0-based)
                toOffice.page_range = pages;
                word.enable_generate_headers_and_footers = true;
                toOffice.word_setting_data = word;
                excel.workbook_settings = PDF2ExcelSettingData.WorkbookSettings.e_WorkbookSettingsEachTable;
                toOffice.excel_setting_data = excel;

                using (Progressive p = PDF2Office.StartConvertToWord(
                           "report.pdf", "" /* password */, "./report.docx", toOffice, null))
                {
                    // StartConvertToExcel / StartConvertToPowerPoint take the same arguments.
                    if (p.GetRateOfProgress() != 100)
                    {
                        Progressive.State state = Progressive.State.e_ToBeContinued;
                        while (state == Progressive.State.e_ToBeContinued) state = p.Continue();
                    }
                }
            }

            // --- Word / Excel / PowerPoint -> PDF ---
            using (var toPdf = new Office2PDFSettingData())
            using (var fromWord = new Word2PDFSettingData())
            {
                toPdf.resource_folder_path = "res/office2pdf";            // ships with the SDK
                toPdf.is_embed_font = true;
                fromWord.is_generate_bookmark = true;                     // headings -> bookmarks
                toPdf.word_setting_data = fromWord;
                Office2PDF.ConvertFromWord("report.docx", "", "report.pdf", toPdf);
                Office2PDF.ConvertFromExcel("table.xlsx", "", "table.pdf", toPdf);
                Office2PDF.ConvertFromPowerPoint("deck.pptx", "", "deck.pdf", toPdf);
            }

            // --- PDF -> Markdown (images go to a folder beside the .md) ---
            using (var toMd = new PDF2MdSettingData())
            {
                toMd.table_format = PDF2MdSettingData.TableFormat.e_TableFormatMarkdown;
                toMd.skip_ocr_pages = true;     // skip scanned pages instead of throwing e_ErrNeedOCR
                PDF2Md.ConvertToMarkdown("report.pdf", "", "report.md", "images", toMd);
            }

            // --- Markdown -> PDF (sizes in points) ---
            using (var fromMd = new Md2PDFSettingData())
            {
                fromMd.page_width = 595; fromMd.page_height = 842;        // A4
                fromMd.base_font_size = 11;
                Md2PDF.ConvertFromMarkdown("report.md", "", "report.pdf", fromMd);
            }
        }
        catch (PDFException e)
        {
            // e_ErrPassword, e_ErrNeedOCR, e_ErrNoPDF2OfficeModuleRight, ...
            Console.WriteLine("{0}: {1}", e.GetErrorCode(), e.Message);
        }
        Library.Release();
    }
}
import com.foxit.sdk.PDFException;
import com.foxit.sdk.common.Library;
import com.foxit.sdk.common.Progressive;
import com.foxit.sdk.common.Range;
import com.foxit.sdk.conversion.pdf2office.*;
import com.foxit.sdk.conversion.office2pdf.*;
import com.foxit.sdk.conversion.pdf2md.*;
import com.foxit.sdk.conversion.md2pdf.*;

import static com.foxit.sdk.common.Constants.e_ErrSuccess;

public class Convert {
    static { System.loadLibrary("fpdfconversionsdk_java_linux64"); }   // _win64 on Windows

    public static void main(String[] args) {
        if (Library.initialize(sn, key) != e_ErrSuccess) return;
        try {
            // --- PDF -> Word / Excel / PowerPoint (progressive) ---
            PDF2OfficeSettingData toOffice = new PDF2OfficeSettingData();
            toOffice.setMetrics_data_folder_path("res/metrics_data");   // ships with the SDK
            toOffice.setEnable_ml_recognition(true);                    // borderless tables
            Range pages = new Range();
            pages.addSegment(0, 1, Range.e_All);                        // pages 1-2 (0-based)
            toOffice.setPage_range(pages);
            PDF2WordSettingData word = new PDF2WordSettingData();
            word.setEnable_generate_headers_and_footers(true);
            toOffice.setWord_setting_data(word);
            PDF2ExcelSettingData excel = new PDF2ExcelSettingData();
            excel.setWorkbook_settings(PDF2ExcelSettingData.e_WorkbookSettingsEachTable);
            toOffice.setExcel_setting_data(excel);

            Progressive p = PDF2Office.startConvertToWord(
                    "report.pdf", "" /* password */, "./report.docx", toOffice, null);
            // startConvertToExcel / startConvertToPowerPoint take the same arguments.
            if (p.getRateOfProgress() != 100) {
                int state = Progressive.e_ToBeContinued;
                while (state == Progressive.e_ToBeContinued) state = p.resume();
            }

            // --- Word / Excel / PowerPoint -> PDF ---
            Office2PDFSettingData toPdf = new Office2PDFSettingData();
            toPdf.setResource_folder_path("res/office2pdf");            // ships with the SDK
            toPdf.setIs_embed_font(true);
            Word2PDFSettingData fromWord = new Word2PDFSettingData();
            fromWord.setIs_generate_bookmark(true);                     // headings -> bookmarks
            toPdf.setWord_setting_data(fromWord);
            Office2PDF.convertFromWord("report.docx", "", "report.pdf", toPdf);
            Office2PDF.convertFromExcel("table.xlsx", "", "table.pdf", toPdf);
            Office2PDF.convertFromPowerPoint("deck.pptx", "", "deck.pdf", toPdf);

            // --- PDF -> Markdown (images go to a folder beside the .md) ---
            PDF2MdSettingData toMd = new PDF2MdSettingData();
            toMd.setTable_format(PDF2MdSettingData.e_TableFormatMarkdown);
            toMd.setSkip_ocr_pages(true);       // skip scanned pages instead of throwing
            PDF2Md.convertToMarkdown("report.pdf", "", "report.md", "images", toMd);

            // --- Markdown -> PDF (sizes in points) ---
            Md2PDFSettingData fromMd = new Md2PDFSettingData();
            fromMd.setPage_width(595); fromMd.setPage_height(842);      // A4
            fromMd.setBase_font_size(11);
            Md2PDF.convertFromMarkdown("report.md", "", "report.pdf", fromMd);
        } catch (PDFException e) {
            // e_ErrPassword, e_ErrNeedOCR, e_ErrNoPDF2OfficeModuleRight, ...
            System.out.println(e.getLastError() + ": " + e.getMessage());
        }
        Library.release();
    }
}
from FoxitPDFConversionSDKPython3 import *

if Library.Initialize(sn, key) != e_ErrSuccess:
    raise SystemExit(1)
try:
    # --- PDF -> Word / Excel / PowerPoint (progressive) ---
    to_office = PDF2OfficeSettingData()
    to_office.metrics_data_folder_path = "res/metrics_data"    # ships with the SDK
    to_office.enable_ml_recognition = True                     # borderless tables
    pages = Range()
    pages.AddSegment(0, 1)                                     # pages 1-2 (0-based)
    to_office.page_range = pages
    word = PDF2WordSettingData()
    word.enable_generate_headers_and_footers = True
    to_office.word_setting_data = word
    excel = PDF2ExcelSettingData()
    excel.workbook_settings = PDF2ExcelSettingData.e_WorkbookSettingsEachTable
    to_office.excel_setting_data = excel

    progressive = PDF2Office.StartConvertToWord(
        "report.pdf", "", "./report.docx", to_office, None)   # "" = no password
    # StartConvertToExcel / StartConvertToPowerPoint take the same arguments.
    if progressive.GetRateOfProgress() != 100:
        state = Progressive.e_ToBeContinued
        while state == Progressive.e_ToBeContinued:
            state = progressive.Continue()

    # --- Word / Excel / PowerPoint -> PDF ---
    to_pdf = Office2PDFSettingData()
    to_pdf.resource_folder_path = "res/office2pdf"             # ships with the SDK
    to_pdf.is_embed_font = True
    from_word = Word2PDFSettingData()
    from_word.is_generate_bookmark = True                      # headings -> bookmarks
    to_pdf.word_setting_data = from_word
    Office2PDF.ConvertFromWord("report.docx", "", "report.pdf", to_pdf)
    Office2PDF.ConvertFromExcel("table.xlsx", "", "table.pdf", to_pdf)
    Office2PDF.ConvertFromPowerPoint("deck.pptx", "", "deck.pdf", to_pdf)

    # --- PDF -> Markdown (images go to a folder beside the .md) ---
    to_md = PDF2MdSettingData()
    to_md.table_format = PDF2MdSettingData.e_TableFormatMarkdown
    to_md.skip_ocr_pages = True       # skip scanned pages instead of raising e_ErrNeedOCR
    PDF2Md.ConvertToMarkdown("report.pdf", "", "report.md", "images", to_md)

    # --- Markdown -> PDF (sizes in points) ---
    from_md = Md2PDFSettingData()
    from_md.page_width, from_md.page_height = 595, 842         # A4
    from_md.base_font_size = 11
    Md2PDF.ConvertFromMarkdown("report.md", "", "report.pdf", from_md)
except (RuntimeError, Exception) as ex:
    # SDK errors arrive as RuntimeError: wrong password, scanned PDF, module not
    # licensed, ... (The star import replaces Exception with the SDK's own class,
    # so "except Exception" alone would miss them.)
    print(ex)
finally:
    Library.Release()
const {
  ErrorCode, State, Library, Range,
  PDF2Office, PDF2OfficeSettingData, PDF2WordSettingData, PDF2PowerPointSettingData,
  PDF2ExcelSettingData, WorkbookSettings,
  Office2PDF, Office2PDFSettingData, Word2PDFSettingData, Excel2PDFSettingData,
  PDF2Md, PDF2MdSettingData, TableFormat,
  Md2PDF, Md2PDFSettingData,
} = require('@foxitsoftware/foxit-pdf-conversion-sdk-node');

if (Library.Initialize(sn, key) !== ErrorCode.e_ErrSuccess) process.exit(1);
try {
  // --- PDF -> Word / Excel / PowerPoint (progressive) ---
  // Settings are passed to the constructors, in the order of the C++ classes.
  const word = new PDF2WordSettingData(
      false,   // retain page layout
      true,    // generate headers and footers
      false,   // generate footnotes and endnotes
      false,   // break pages where the PDF did
      0);      // blank paragraphs kept at page bottom
  const powerpoint = new PDF2PowerPointSettingData(false, false);
  const excel = new PDF2ExcelSettingData(
      '', '',                                        // decimal symbol, thousands separator
      WorkbookSettings.e_WorkbookSettingsEachTable,
      true,                                          // aggressive table repair
      false);                                        // include watermarks
  const toOffice = new PDF2OfficeSettingData(
      'res/metrics_data',   // ships with the SDK
      true,                 // machine-learning recognition (borderless tables)
      new Range(),          // empty range = all pages
      true,                 // include PDF comments
      word, powerpoint, excel,
      true,                 // keep trailing spaces
      true,                 // include images
      false);               // match system fonts

  const progressive = PDF2Office.StartConvertToWordWithPath(
      'report.pdf', '' /* password */, './report.docx', toOffice, null);
  // StartConvertToExcelWithPath / StartConvertToPowerPointWithPath take the same arguments.
  if (progressive.GetRateOfProgress() !== 100) {
    let state = State.e_ToBeContinued;
    while (state === State.e_ToBeContinued) state = progressive.Continue();
  }

  // --- Word / Excel / PowerPoint -> PDF ---
  const toPdf = new Office2PDFSettingData(
      'res/office2pdf',                        // ships with the SDK
      true,                                    // embed fonts
      new Word2PDFSettingData(true),           // headings -> bookmarks
      new Excel2PDFSettingData(false, false, null));   // one PDF, no hidden sheets, all sheets
  Office2PDF.ConvertFromWordWithPath('report.docx', '', 'report.pdf', toPdf);
  Office2PDF.ConvertFromExcelWithPath('table.xlsx', '', 'table.pdf', toPdf);
  Office2PDF.ConvertFromPowerPointWithPath('deck.pptx', '', 'deck.pdf', toPdf);

  // --- PDF -> Markdown (images go to a folder beside the .md) ---
  const toMd = new PDF2MdSettingData(
      TableFormat.e_TableFormatMarkdown,
      false,   // include headers and footers
      true,    // keep italics
      false,   // keep bold
      true);   // skip scanned pages instead of throwing
  PDF2Md.ConvertToMarkdown('report.pdf', '', 'report.md', 'images', toMd);

  // --- Markdown -> PDF (sizes in points) ---
  const fromMd = new Md2PDFSettingData(
      595, 842,            // A4
      72, 72, 72, 72,      // margins: top, bottom, left, right
      11,                  // body font size
      '', '',              // custom font path, style JSON path
      false);              // embed fonts
  Md2PDF.ConvertFromMarkdownWithPath('report.md', '', 'report.pdf', fromMd);
} catch (e) {
  console.log(e);          // bad password, scanned PDF, module not licensed, ...
}
Library.Release();
package main

import (
	"fmt"

	sdk "foxit.com/fpdfconversionsdk"
)

func main() {
	if sdk.LibraryInitialize(sn, key) != sdk.E_ErrSuccess {
		return
	}
	defer sdk.LibraryRelease()
	defer func() { // keep an SDK error from crashing the program
		if r := recover(); r != nil {
			fmt.Println("conversion failed:", r)
		}
	}()

	// --- PDF -> Word / Excel / PowerPoint (progressive) ---
	toOffice := sdk.NewPDF2OfficeSettingData()
	defer sdk.DeletePDF2OfficeSettingData(toOffice)
	toOffice.SetMetrics_data_folder_path("res/metrics_data") // ships with the SDK
	toOffice.SetEnable_ml_recognition(true)                  // borderless tables
	pages := sdk.NewRange(0, 1)                              // pages 1-2 (0-based)
	defer sdk.DeleteRange(pages)
	toOffice.SetPage_range(pages)
	word := sdk.NewPDF2WordSettingData()
	defer sdk.DeletePDF2WordSettingData(word)
	word.SetEnable_generate_headers_and_footers(true)
	toOffice.SetWord_setting_data(word)
	excel := sdk.NewPDF2ExcelSettingData()
	defer sdk.DeletePDF2ExcelSettingData(excel)
	excel.SetWorkbook_settings(sdk.PDF2ExcelSettingDataE_WorkbookSettingsEachTable)
	toOffice.SetExcel_setting_data(excel)

	progressive := sdk.PDF2OfficeStartConvertToWord("report.pdf", "", "./report.docx", toOffice)
	// PDF2OfficeStartConvertToExcel / ...ToPowerPoint take the same arguments.
	if progressive.GetRateOfProgress() != 100 {
		for progressive.Continue() == sdk.ProgressiveE_ToBeContinued {
		}
	}

	// --- Word / Excel / PowerPoint -> PDF ---
	toPdf := sdk.NewOffice2PDFSettingData()
	defer sdk.DeleteOffice2PDFSettingData(toPdf)
	toPdf.SetResource_folder_path("res/office2pdf") // ships with the SDK
	toPdf.SetIs_embed_font(true)
	fromWord := sdk.NewWord2PDFSettingData()
	defer sdk.DeleteWord2PDFSettingData(fromWord)
	fromWord.SetIs_generate_bookmark(true) // headings -> bookmarks
	toPdf.SetWord_setting_data(fromWord)
	sdk.Office2PDFConvertFromWord("report.docx", "", "report.pdf", toPdf)
	sdk.Office2PDFConvertFromExcel("table.xlsx", "", "table.pdf", toPdf)
	sdk.Office2PDFConvertFromPowerPoint("deck.pptx", "", "deck.pdf", toPdf)

	// --- PDF -> Markdown (images go to a folder beside the .md) ---
	toMd := sdk.NewPDF2MdSettingData()
	defer sdk.DeletePDF2MdSettingData(toMd)
	toMd.SetTable_format(sdk.PDF2MdSettingDataE_TableFormatMarkdown)
	toMd.SetSkip_ocr_pages(true) // skip scanned pages instead of failing
	sdk.PDF2MdConvertToMarkdown("report.pdf", "", "report.md", "images", toMd)

	// --- Markdown -> PDF (sizes in points) ---
	fromMd := sdk.NewMd2PDFSettingData()
	defer sdk.DeleteMd2PDFSettingData(fromMd)
	fromMd.SetPage_width(595) // A4
	fromMd.SetPage_height(842)
	fromMd.SetBase_font_size(11)
	sdk.Md2PDFConvertFromMarkdown("report.md", "", "report.pdf", fromMd)
}

Condensed for clarity; production code should check every return value. The C++ tab is condensed from the program this demo runs, and the Python and Go samples have been run end to end on Linux. The others follow the examples in each language’s SDK package and have not been run here. sn and key are your licence strings. The Go package is Linux only. When converting a PDF to Word, Excel or PowerPoint, give the output a folder part (./report.docx): the SDK rejects a bare file name that does not exist yet.