---
Product: Aspose.PDF
Platform: java
Page Type: docs
Canonical URL: https://docs.aspose.org/pdf/java/developer-guide/conversion
---

# Convert PDF to Excel and Markdown

Convert between PDF and Office/Excel (.xlsx) or Markdown (.md) documents with Aspose.PDF FOSS for Java, including live, recalculating XLSX forms.

## Overview

This guide shows how to convert a PDF to an Excel (`.xlsx`) workbook or to Markdown, and
how to load a PDF back from either format. `Document` performs the conversion in both
directions; `ExcelSaveOptions` and `MarkdownSaveOptions` tune the export, and
`ExcelLoadOptions` and `MarkdownLoadOptions` tune the import. Since 26.9.0.

---

### PDF to XLSX

Tables detected in the PDF become worksheet grids with typed cells — numbers, dates,
booleans, currency and percentages are written as real Excel values rather than text —
and source styling (font family/size, text colour, cell fill, borders, row heights,
column widths, alignment, merged cells) is carried over. Images inside table cells are
embedded as drawings.

```java
import org.aspose.pdf.Document;
import org.aspose.pdf.ExcelSaveOptions;

try (Document doc = new Document("report.pdf")) {
    ExcelSaveOptions options = new ExcelSaveOptions();
    options.setFormat(ExcelSaveOptions.ExcelFormat.XLSX); // default
    options.setMinimizeTheNumberOfWorksheets(true);        // merge pages onto fewer sheets
    options.setInsertBlankColumnAtFirst(false);            // no leading spacer column
    options.setUniformWorksheets(false);                   // allow per-sheet column widths
    options.setStructuralHeuristics(true);                 // recover tables on untagged PDFs
    options.setSuppressRunningHeadersFooters(true);         // drop repeated page furniture
    doc.save("report.xlsx", options);
}
```

`SaveFormat.Xlsx` (an alias, `SaveFormat.Excel`, is also accepted) gives the same result
with default options: `doc.save("report.xlsx", SaveFormat.Xlsx)`. `ExcelSaveOptions`'s own
`ExcelFormat` enum also accepts `XmlSpreadSheet2003`, `CSV` and `ODS` for Aspose.PDF API
compatibility, but this library always writes an `.xlsx` package regardless of which value
is set. You can also write to a stream with `doc.save(OutputStream, ExcelSaveOptions)`.

---

### XLSX to PDF, including live forms

Load an `.xlsx` workbook through a `Document` constructor that takes `ExcelLoadOptions`.
Each sheet becomes a PDF table with the same cell typing and styling support as the export
direction.

```java
import org.aspose.pdf.Document;
import org.aspose.pdf.ExcelLoadOptions;

try (Document doc = new Document("book.xlsx", new ExcelLoadOptions())) {
    doc.save("book.pdf");
}
```

Setting `ExcelLoadOptions.setInteractiveForms(true)` turns numeric and label cells into a
"live" PDF form instead of static text: numeric cells become editable text fields, formula
cells become read-only fields that recalculate from their inputs, and label or constant
cells stay static text unless another formula references them. `ExcelFormulaTranslator`
translates each formula into Acrobat JavaScript; a formula whose function it does not
support falls back to its last computed static value, so the field still shows the correct
number. Recalculation itself only runs in a viewer with a forms/JavaScript engine — Adobe
Acrobat or Foxit; a viewer without that engine shows only the baked-in values, with no
live recalculation.

```java
import org.aspose.pdf.Document;
import org.aspose.pdf.ExcelLoadOptions;

ExcelLoadOptions options = new ExcelLoadOptions();
options.setInteractiveForms(true); // cells → fields, formulas → calculate actions

try (Document doc = new Document("invoice.xlsx", options)) {
    doc.save("invoice-live.pdf");
}
```

---

### PDF to Markdown

`Document` projects a PDF to CommonMark / GitHub-Flavored Markdown: headings, paragraphs,
lists, tables, emphasis (bold/italic/strikethrough), inline and fenced code, links,
images, and footnotes.

```java
import org.aspose.pdf.Document;
import org.aspose.pdf.MarkdownSaveOptions;

try (Document doc = new Document("article.pdf")) {
    MarkdownSaveOptions options = new MarkdownSaveOptions();
    options.setStructuralHeuristics(true);          // recover headings/lists/tables
    options.setSuppressRunningHeadersFooters(true);  // drop repeated page furniture
    options.setRasterizeVectorGraphics(true);        // charts/shapes -> referenced images
    doc.save("article.md", options);
}
```

`SaveFormat.Markdown` gives the same result with default options:
`doc.save("article.md", SaveFormat.Markdown)`. `Document.markdownText(MarkdownSaveOptions)`
returns the Markdown as a `String` instead of writing a file (there is no separate
"Markdown text" accessor — this method is the one to call for an in-memory result).

---

### Markdown to PDF

Load a Markdown file through a `Document` constructor that takes `MarkdownLoadOptions`. A
hand-written CommonMark/GFM subset parser reads the source: headings, paragraphs, lists,
tables, emphasis, code, links, images, blockquotes and footnotes. Exotic HTML embedded in
the Markdown is not fully reproduced.

```java
import org.aspose.pdf.Document;
import org.aspose.pdf.MarkdownLoadOptions;

try (Document doc = new Document("README.md", new MarkdownLoadOptions())) {
    doc.save("README.pdf");
}
```

---

### Tips and Best Practices

- Fidelity is structural, not pixel-exact for either format: conversions preserve
  content, structure, images and page geometry, not the exact rendered appearance.
- `ExcelSaveOptions.ExcelFormat` and the `MarkdownSaveOptions` structural flags only
  change the *output* package format or heuristics — the actual values your PDF was
  tagged with still drive what gets detected as a table, a heading or a list.
- For live XLSX forms, treat the baked-in cell values as the correct fallback: only a
  forms-capable viewer recalculates formulas on open.

---

### Common Issues

| Issue | Cause | Fix |
|---|---|---|
| XLSX output always has an `.xlsx` extension even after setting `ExcelFormat.CSV` or `ODS` | The FOSS writer always serializes an OOXML `.xlsx` package; the other `ExcelFormat` values exist only for Aspose.PDF API compatibility | Treat the output as `.xlsx` regardless of the `ExcelFormat` value you set |
| A recalculating XLSX form shows static numbers instead of live formulas | The PDF viewer has no forms/JavaScript engine | Open the file in Adobe Acrobat or Foxit to see live recalculation |
| A formula cell shows a stale-looking value | `ExcelFormulaTranslator` does not support that formula's function | This is the documented fallback: the field keeps its last computed static value |

---

### FAQ

#### Can I get Markdown as a `String` instead of a file?

Yes — call `Document.markdownText(MarkdownSaveOptions)`; it returns the Markdown text
directly instead of writing it to a file.

#### Does the XLSX importer support real Excel formulas?

Only when `ExcelLoadOptions.setInteractiveForms(true)` is set, and only the subset of
functions `ExcelFormulaTranslator` can translate to Acrobat JavaScript. Everything else
falls back to the formula's last computed static value in the source workbook.

---

### API Reference Summary

| Class/Method | Description |
|---|---|
| [`ExcelSaveOptions`](https://reference.aspose.org/pdf/java/excelsaveoptions/) | Tunes the PDF to XLSX export |
| [`ExcelLoadOptions`](https://reference.aspose.org/pdf/java/excelloadoptions/) | Tunes the XLSX to PDF import, including live forms |
| [`ExcelFormat`](https://reference.aspose.org/pdf/java/excelformat/) | Target spreadsheet flavour accepted by `ExcelSaveOptions` |
| [`ExcelFormulaTranslator`](https://reference.aspose.org/pdf/java/excelformulatranslator/) | Translates Excel formulas into Acrobat JavaScript for live forms |
| [`MarkdownSaveOptions`](https://reference.aspose.org/pdf/java/markdownsaveoptions/) | Tunes the PDF to Markdown export |
| [`MarkdownLoadOptions`](https://reference.aspose.org/pdf/java/markdownloadoptions/) | Tunes the Markdown to PDF import |
| `Document.save(String, SaveFormat)` / `Document.save(String, ExcelSaveOptions \| MarkdownSaveOptions)` | Export entry points |
| `Document.markdownText(MarkdownSaveOptions)` | Returns the Markdown as a `String` |

## See Also

- [Aspose.PDF for Java — Enterprise Documentation](https://docs.aspose.com/pdf/java/)