# OFD documents

SumatraPDF opens [OFD](https://fileformats.dev/ofd) (`.ofd`), the Chinese fixed-layout document format (GB/T 33190) used for e-invoices and government documents, and checks its signatures. This page lists what works and how it compares with other OFD software.

**Available in [pre-release 3.7](https://www.sumatrapdfreader.org/prerelease).**

**Open an `.ofd` file like a PDF**: double-click it, drag it onto the window or use **File → Open**. At a glance:

- **Pages:** text, paths, images, templates, annotations, patterns, gradients (including mesh gradients) and signature seals are drawn natively, with no conversion to PDF.
- **Packages:** an OFD with several documents shows all of them in order, with a bookmark for each.
- **Encrypted OFD:** a password-encrypted package (GM/T 0099) asks for the password, as an encrypted PDF does.
- **Text:** select, copy and [find text](Finding-text.md); embedded fonts keep their original characters.
- **Links and attachments:** click links to other pages or to web sites; attachments are listed under the bookmarks and open like [PDF attachments](Save-PDF-attachments.md).
- **Signatures:** the signature bar and the **Signatures** view show whether each signature is valid, as for [signed PDFs](Verify-PDF-signature.md).
- **Convert:** **Convert to PDF** keeps text and vector graphics; **Convert PDF to Images** renders OFD pages too.
- **Printing:** [print](Printing.md) any pages.
- **File Explorer:** the installer registers `.ofd` for Open With and adds previews and thumbnails.

## Open an OFD file

- Double-click an `.ofd` file once SumatraPDF is registered for it, or right-click → **Open with → SumatraPDF**.
- An OFD renamed to `.zip`, or attached to a PDF as `.zip`, still opens as OFD.
- For a password-encrypted OFD, type the password when asked, or pass it with `-pwd`. A package encrypted for a certificate (it needs the recipient's private key) can't be opened.
- The bookmarks sidebar shows the document's outline. For a package of several documents it shows one entry per document, with that document's outline under it.

Note: missing fonts are replaced, and a broken image or template is skipped without losing the rest of the page.

## Check OFD signatures

Opening a signed OFD checks its signatures in the background. The bar above the document says whether they are valid. Click **Signature Panel** for the list, and open a signature for its details.

SumatraPDF checks electronic seals (SES, GM/T 0031 v1 and v4, GB/T 38540) and GB/T 35275 digital signatures that use SM2 and SM3:

- the files the signature protects still have the digests it recorded
- `Signature.xml` matches the hash inside the signature
- the signature matches the signer's certificate, and the certificate was valid at the signature time
- the signer's certificate chains to a trusted root

A package with integrity protection (GM/T 0099, `OFDEntries.xml`) shows it as one more entry. It is invalid when a file was added to the package or removed from it after it was protected.

Results:

- **Valid:** the document is unchanged and the signer's certificate chains to a trusted root.
- **Invalid:** a signed file was changed or removed, a file was added to a protected package, or the signature doesn't match the certificate.
- **Validity unknown:** the document is unchanged, but the certificate doesn't chain to a trusted root. A signature without a certificate, or with an unsupported algorithm, can't be checked either.

## Trust OFD signers

Windows doesn't check SM2 certificates, so SumatraPDF does: a signer is trusted when its certificate chains, through certificates in the Windows **Intermediate Certification Authorities** store, to a certificate in the Windows **Trusted Root Certification Authorities** store or in the `OfdTrustedCertificates` advanced setting.

To trust a CA without adding it to Windows:

1. Open **Settings → Advanced Settings...**
2. Set `OfdTrustedCertificates` to the path of the CA's certificate file, DER or PEM. Separate several paths with spaces and quote paths that contain spaces: `OfdTrustedCertificates = "C:/certs/my ca.pem" C:/certs/other.cer`
3. Reopen the document.

Note: a seal drawn on the page proves nothing by itself. Check the status in the bar or the Signatures view.

## Compare with other OFD software

|                                          | SumatraPDF              | [ofdrw](https://github.com/ofdrw/ofdrw) | [ofdrw-viewer](https://github.com/ofdrw/ofdrw-viewer) | [ofd.js](https://github.com/DLTech21/ofd.js) |
| ---------------------------------------- | ----------------------- | --------------------------------------- | ----------------------------------------------------- | -------------------------------------------- |
| What it is                               | Windows document viewer | Java library                            | HTML5 reader, rendering engine, command-line tool     | JavaScript rendering library                 |
| License                                  | GPLv3                   | MIT                                     | MIT                                                   | Apache-2.0                                   |
| View and print                           | ✓                       | via conversion to PDF or images         | ✓                                                     | renders in a web page                        |
| Viewer with bookmarks and text search    | ✓                       |                                         | ✓                                                     |                                              |
| Encrypted OFD (GM/T 0099)                | ✓ decrypt (password)    | ✓ encrypt                               | ✓ decrypt                                             |                                              |
| Verify SM2 / SM3 signatures              | ✓                       | ✓                                       | ✓                                                     |                                              |
| Certificate chain and trusted roots      | ✓                       |                                         | ✓                                                     |                                              |
| Detect files added after signing         | ✓                       |                                         | ✓                                                     |                                              |
| Create, edit, sign, merge                |                         | ✓                                       |                                                       |                                              |
| Convert PDF to OFD, OFD to PDF or images | OFD to PDF or images    | ✓                                       | OFD to images                                         |                                              |

An empty cell means the project doesn't document the feature.

Popular desktop readers in China, all closed source and free to use:

- **数科OFD阅读器** (Suwell, [ofd.cn](https://www.ofd.cn/)): Windows and Linux; views, prints and verifies electronic seals, saves as PDF or images.
- **福昕OFD阅读器** (Foxit OFD Reader): desktop and mobile; views, annotates, shows the outline and prints.
- **WPS Office**: opens OFD on Windows (2021 update and later), Android and iOS; views, annotates and saves as PDF.

## Tips

- Use SumatraPDF to read and print OFD invoices without installing a dedicated OFD reader.
- Open a signature's details to see which file was changed when a signature is invalid.
- Add your CA's certificate to `OfdTrustedCertificates` so its signatures show as valid.
- Use ofdrw to create, sign or edit OFD files.
- If a page doesn't look right, [report it](How-to-submit-bug-reports.md) with the `.ofd` file.

## What SumatraPDF doesn't do

- edit, create or sign OFD files, or convert PDF to OFD
- open packages encrypted for a certificate
- check signature timestamps
- annotate OFD files

## See also

- [Supported document formats](Supported-document-formats.md): every format SumatraPDF opens.
- [Verify a PDF signature](Verify-PDF-signature.md): the signature bar and Signatures view, for PDFs.
- [Advanced settings](Advanced-options-settings.md): `OfdTrustedCertificates` and the other settings.
- [Printing](Printing.md): print options.
