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 in the browser with NexPDF for the web.

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

const download = (bytes: Uint8Array, name: string) => {
  const a = Object.assign(document.createElement('a'), { href: URL.createObjectURL(new Blob([bytes])), download: name });
  a.click();
  URL.revokeObjectURL(a.href);
};

download(doc.toDocx(), 'report.docx');
download(doc.toXlsx(), 'report.xlsx');   // one sheet per page, tables rebuilt
download(doc.toPptx(), 'report.pptx');   // one slide per page

PDF to text formats

MethodOutput
doc.raw.toHtml()HTML
toReflowHtml(options)Responsive HTML for small screens
doc.raw.toJson()The document content as JSON
doc.raw.toXml()The document content as XML
doc.raw.toCsv()The tables as CSV
doc.raw.toRtf()RTF
markdown()Markdown (no module needed)
const html = doc.toReflowHtml({ images: true, title: 'Report' });

toReflowHtml takes pages, images, full_page and title.

Office, HTML and e-books to PDF

PdfDocument.fromBytes, fromFile and fromUrl convert Word, Excel and PowerPoint files, EPUB and FictionBook books, XPS and OpenXPS files and CBZ comics directly (the format is detected):

const proposal = await nex.PdfDocument.fromFile(docxFile);
const pdf = proposal.toBlob();

const invoice = nex.PdfDocument.fromHtml('<h1>Invoice 1042</h1><p>Total: 120 EUR</p>');

const book = nex.PdfDocument.fromEbook(new Uint8Array(await epubFile.arrayBuffer()));   // or fromOffice

Word comments and tracked changes

nex.WasmDocument.openDocxWithOptionsJson(bytes, optionsJson) converts a .docx with options and returns a WasmDocument; wrap it with new nex.PdfDocument(raw) for the camelCase methods:

const raw = nex.WasmDocument.openDocxWithOptionsJson(
  new Uint8Array(await docxFile.arrayBuffer()),
  JSON.stringify({ show_comments: true, show_revisions: true }),
);
const reviewed = new nex.PdfDocument(raw);
OptionDefaultMeaning
show_commentsfalseDraws the comments in balloons in a markup area at the right of each page, with 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. The Word converter also lays out section columns (equal or unequal, with separators, column breaks and continuous section breaks), conditional table styles (with tblLook and 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, among them the *IFS statistics, XLOOKUP, INDEX, OFFSET, INDIRECT, TEXT format codes, dates and times, finance, FILTER, SORT, UNIQUE, SEQUENCE, LET and LAMBDA (named and recursive) with 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. Conditional formatting draws every built-in and x14 icon set and x14 data bars (negative colours, axis, direction, gradient, border).

For output that does not change from one run to the next, fix the time that NOW() and TODAY() return (Unix seconds, no time zone applied):

const raw = nex.WasmDocument.openXlsxWithClock(new Uint8Array(await xlsxFile.arrayBuffer()), Date.UTC(2026, 10, 29) / 1000);
const sheet = new nex.PdfDocument(raw);

Right-to-left and complex scripts

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

To fill a template with JSON data, see Templates.

Images to PDF

JPEG, PNG and TIFF pictures open as a PDF with one page per picture (multi-page TIFF too):

const scans = await nex.PdfDocument.fromFile(tiffFile);
scans.raw.insertImagePages(scans.pageCount, new Uint8Array(await photo.arrayBuffer()));   // append more pictures
const pdf = scans.toBlob();

Page images

To export pages as PNG, see Rendering.

On this page