Skip to Content
NexPDF

Conversion

Convert PDFs to Word, Excel, PowerPoint, HTML, JSON, XML, CSV and RTF, and create PDFs from Office files, HTML, e-books and images with NexPDF for C++.

English

License module

Conversion to and from Office, HTML, e-book and data formats needs the conversion module (Startup tier and above). Images to PDF and Markdown export need no module.

PDF to Office

auto doc = nexpdf::Document::open("report.pdf");
write_file("report.docx", doc.to_docx());
write_file("report.xlsx", doc.to_xlsx());   // one sheet per page, tables rebuilt
write_file("report.pptx", doc.to_pptx());   // one slide per page

PDF to text formats

MethodOutput
to_html()HTML
to_reflow_html(options_json)Responsive HTML for small screens
to_json()The document content as JSON
to_xml()The document content as XML
to_csv()The tables as CSV
to_rtf()RTF
extract_markdown()Markdown (no module needed)
std::string html = doc.to_reflow_html(R"({"images":true,"title":"Report"})");

Office, HTML and e-books to PDF

auto pdf = nexpdf::open_office(read_file("proposal.docx"));   // Word, Excel or PowerPoint, format detected
pdf.save("proposal.pdf");

auto invoice = nexpdf::from_html("<h1>Invoice 1042</h1><p>Total: 120 EUR</p>");
invoice.save("invoice.pdf");

auto book = nexpdf::open_ebook(read_file("book.epub"));       // EPUB, FictionBook, XPS/OpenXPS, CBZ

Document::open and Document::open_bytes also convert Word, Excel and PowerPoint files directly.

Word options

nexpdf::open_docx_with_options_json(data, options_json) opens a Word file with {"show_comments":false,"show_revisions":false} (std::nullopt = defaults):

auto pdf = nexpdf::open_docx_with_options_json(read_file("review.docx"),
                                               R"({"show_comments":true,"show_revisions":true})");
pdf.save("review-markup.pdf");

Comments are always exported as PDF text annotations anchored at the commented text, with their replies and resolved state. show_comments also draws them in balloons in a markup area at the right of each page (the page content scaled down, as Word prints with markup). show_revisions shows tracked changes as markup (coloured underlined insertions, struck deletions, change bars) instead of the final document, which is the default.

Word conversion also lays out section columns (equal or unequal, separators, column and continuous breaks), conditional table styles (tblStylePr with tblLook and banding), tight and through wrapping along wrap polygons, floats in table cells and text boxes, and tables in text boxes.

Excel formulas

Formulas without a cached value are calculated; cached values still win. The calculation covers references across sheets, defined names, shared and array formulas, dynamic arrays that spill (#SPILL!), Excel error values and about 280 functions (maths, statistics including the *IFS family, lookup including XLOOKUP, INDEX, OFFSET and INDIRECT, text including TEXT format codes, dates and times, logic, finance, information, FILTER, SORT, UNIQUE, SEQUENCE), LET and LAMBDA (named and recursive), MAP, REDUCE, SCAN, MAKEARRAY, BYROW, BYCOL and ISOMITTED. Circular references show 0 as Excel does, or iterate as the workbook's iterative-calculation settings say (calcPr iterate, count and delta). Conditional formatting draws every built-in and x14 icon set and x14 data bars (negative colours, axis, direction, gradient, border).

nexpdf::open_xlsx_with_clock(data, clock_unix_seconds) makes NOW() and TODAY() return a fixed time (no time zone applied), for reproducible output:

auto pdf = nexpdf::open_xlsx_with_clock(read_file("report.xlsx"), 1798502400);   // 2026-12-29 00:00:00

Right-to-left and complex scripts

Word, Excel, PowerPoint and HTML conversion shape text with OpenType (Arabic joining, Indic reordering, marks, ligatures) and order it with the full Unicode bidi algorithm: w:bidi and w:rtl in Word, right-to-left sheets and readingOrder in Excel, right-to-left paragraphs in PowerPoint, and dir and direction in HTML.

Images to PDF

auto pdf = nexpdf::open_image(read_file("scan.tiff"));        // one page per picture (multi-page TIFF too)
pdf.insert_image_pages(pdf.page_count(), read_file("photo.jpg"));   // append more pictures
pdf.save("scans.pdf");

Page images

To export pages as PNG, see Rendering.

On this page