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 on the device with NexPDF for React Native.

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

The results are base64, ready to write with your file-system library or to share:

const doc = await NexPdf.open(reportBase64);
const docx = await doc.toDocx();
const xlsx = await doc.toXlsx();   // one sheet per page, tables rebuilt
const pptx = await doc.toPptx();   // one slide per page

PDF to text formats

MethodOutput
toHtml()HTML
reflowHtml(options)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()Markdown (no module needed)
const html = await doc.reflowHtml({ images: true, title: 'Report' });

reflowHtml takes pages, images, full_page and title. Show the result in a WebView for a reading view that fits the phone screen.

Office, HTML and e-books to PDF

NexPdf.open converts Word, Excel and PowerPoint files directly:

const proposal = await NexPdf.open(docxBase64);
const pdf = await proposal.saveBytes();

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

const book = await NexPdf.api.openEbook(epubBase64);   // EPUB, FictionBook, XPS/OpenXPS, CBZ

Word options

NexPdf.api.openDocxWithOptionsJson(base64, optionsJson) converts a Word file with options:

const reviewed = await NexPdf.api.openDocxWithOptionsJson(docxBase64,
  JSON.stringify({ show_comments: true, show_revisions: true }));
const pdf = await reviewed.saveBytes();
OptionDefaultMeaning
show_commentsfalseDraw the comments in balloons in a markup area at the right of each page (the page content is scaled down, as Word prints with markup)
show_revisionsfalseShow 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 replies and the resolved state kept. Without show_revisions the document is converted as it reads after accepting every change.

Word conversion also lays out section columns (equal or unequal, with separators, column breaks and continuous section breaks), conditional table styles (first and last rows and columns, banding), tight and through wrapping along the wrap polygon, floating objects in table cells and text boxes, and tables in text boxes.

Excel formulas and a fixed clock

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

NOW() and TODAY() use the current time. For output that does not change from run to run, fix the clock in Unix seconds (no time zone is applied):

const sheet = await NexPdf.api.openXlsxWithClock(xlsxBase64, 1796000000);

Right-to-left and complex scripts

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

Images to PDF

const scans = await NexPdf.api.openImage(tiffBase64);      // one page per picture (multi-page TIFF too)
await scans.insertImagePages(await scans.pageCount(), jpegBase64);   // append more pictures
const pdf = await scans.saveBytes();

Page images

To export pages as PNG, see Rendering.

On this page