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 .NET.

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

using Nexdevit.NexPdf;

using var doc = NexPdfDocument.Open("report.pdf");
File.WriteAllBytes("report.docx", doc.ToDocx());
File.WriteAllBytes("report.xlsx", doc.ToXlsx());   // one sheet per page, tables rebuilt
File.WriteAllBytes("report.pptx", doc.ToPptx());   // one slide per page

PDF to text formats

MethodOutput
ToHtml()HTML
ToReflowHtml(optionsJson)Responsive HTML for small screens
ToJson()The document content as JSON
ToXml()The document content as XML
ToCsv()The tables as CSV
ToRtf()RTF
ExtractMarkdown() / ToMarkdown()Markdown (no module needed)
var html = doc.ToReflowHtml("""{"images":true,"title":"Report"}""");

Office, HTML and e-books to PDF

using (var pdf = NexPdfDocument.OpenOffice(File.ReadAllBytes("proposal.docx")))   // Word, Excel or PowerPoint, format detected
    pdf.Save("proposal.pdf");

using (var invoice = NexPdfDocument.FromHtml("<h1>Invoice 1042</h1><p>Total: 120 EUR</p>"))
    invoice.Save("invoice.pdf");

using (var book = NexPdfDocument.OpenEbook(File.ReadAllBytes("book.epub")))       // EPUB, FictionBook, XPS/OpenXPS, CBZ
    book.Save("book.pdf");

NexPdfDocument.Open and OpenBytes also convert Word, Excel and PowerPoint files directly. The same converters exist as static methods of NexPdfSdk.

Word options

NexPdfSdk.OpenDocxWithOptionsJson(data, optionsJson) converts a Word document with options:

using var doc = NexPdfSdk.OpenDocxWithOptionsJson(File.ReadAllBytes("draft.docx"),
    """{"show_comments":true,"show_revisions":true}""");
doc.Save("draft-markup.pdf");
OptionDefaultEffect
show_commentsfalseDraws comments in balloons in a markup area at the right of each page, the page content scaled down, as Word prints with markup
show_revisionsfalseShows tracked changes as markup (coloured underlined insertions, struck deletions, change bars) instead of the final document

Comments are always exported as PDF text annotations anchored at the commented text, with their replies and resolved state. Word conversion also lays out section columns (equal and unequal widths, separators, column breaks and continuous section breaks), conditional table styles with banding, tight and through wrapping along wrap polygons, floating objects in table cells and text boxes, and tables in text boxes.

Excel formulas

Formulas without a cached value are calculated (cached values still win): references across sheets, defined names, shared and array formulas, dynamic arrays that spill (#SPILL!), Excel error values and about 280 functions, XLOOKUP, FILTER, SORT, UNIQUE, LET, LAMBDA (named and recursive), MAP, REDUCE, SCAN, MAKEARRAY, BYROW and BYCOL among them. Circular references show 0, as Excel does, or iterate as the workbook's iterative-calculation settings say. Conditional formatting draws every built-in and x14 icon set and x14 data bars.

For reproducible output, NexPdfSdk.OpenXlsxWithClock(data, clockUnixSeconds) makes NOW() and TODAY() return a fixed time (no time zone is applied):

var clock = new DateTimeOffset(2026, 11, 29, 9, 0, 0, TimeSpan.Zero).ToUnixTimeSeconds();
using var sheet = NexPdfSdk.OpenXlsxWithClock(File.ReadAllBytes("report.xlsx"), clock);

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

using var scans = NexPdfDocument.OpenImage(File.ReadAllBytes("scan.tiff"));    // one page per picture (multi-page TIFF too)
scans.InsertImagePages(scans.PageCount, File.ReadAllBytes("photo.jpg"));        // append more pictures
scans.Save("scans.pdf");

Page images

To export pages as PNG, see Rendering.

On this page