Preview without the editor
One container with the SumDoc and SumSheet cores: a thumbnail, pages for reading, and PDF from DOCX and XLSX—what it gives you, the limits, and the requests for a developer.
Not every place in a product needs an editor. A file list needs a thumbnail, a card needs pages for reading, a “download” button needs a PDF. For that there is a separate preview container: it turns DOCX and XLSX into an image, pages, or PDF and stores nothing.
For the business this means: you can show a document in your product without the editor and without sending files outside.
What it does
Section titled “What it does”- A thumbnail of the first page of a document or the first sheet of a workbook.
- All pages of a document or all sheets of a workbook in a form ready for reading in the browser.
- A PDF of the document. PDF from a workbook is not produced yet: the spreadsheet core does not print to PDF, and such a request gets a refusal with a reason.
Inside are the SumDoc and SumSheet cores and fonts with Office metrics, so pages break the same way as in the editor. The response reports whether everything was rendered: how many pages out of how many, whether there are scripts missing from the built-in font, and how many formulas are shown empty because the workbook holds no values for them.
Limits
Section titled “Limits”- Presentations are not accepted—until the third editor appears; ODS is not supported yet. An unknown format gets a refusal with a clear message.
- The service does not accept files larger than 50 MB; the limit can be changed.
- The request directory is wiped right after the response; the service makes no outbound calls, and no network is needed after the image is downloaded.
- Viewing is free; production use is under the license for the embedding application—commercial packaging.
For developers
Section titled “For developers”Start:
docker run -d -p 8099:8099 hissih/sumoffice-previewOne container, about 224 MB. Allow roughly 250 MB of RAM for each document processed concurrently. The file size limit is set by the PREVIEW_MAX_MB environment variable.
| Request | What it returns |
|---|---|
POST /thumb?w=320 |
A PNG of the first page of a document or the first sheet of a workbook as a grid of values. The width w is from 64 to 2000 pixels; a value outside the range is clamped to the nearest bound. |
POST /pages |
Self-contained HTML: all pages of a document or all sheets of a workbook as tables. |
POST /pdf |
A PDF of the document. For a workbook—a 415 refusal with a reason. |
GET /health |
A check that the service is alive. |
The file is passed as the file field of a multipart form or as the raw request body—then the file name is given by the ?name=report.docx parameter or the X-File-Name header. An unknown format gets a 415 refusal.
curl -F file=@report.docx http://localhost:8099/thumb?w=320 > thumb.pngcurl -F file=@report.docx http://localhost:8099/pages > report.htmlcurl -F file=@report.docx http://localhost:8099/pdf > report.pdfcurl -F file=@book.xlsx http://localhost:8099/pages > book.htmlResponse headers—they are used to decide whether to show the result as complete:
| Header | What it means |
|---|---|
X-Preview-Pages |
How many pages the document has according to the PDF. |
X-Preview-Coverage, X-Preview-Partial |
How many pages were rendered out of how many; Partial: true if fewer than in the PDF. |
X-Preview-Scripts-Outside-Font |
Scripts missing from the built-in font—they may have rendered incorrectly. |
X-Preview-Sheets, X-Preview-Cells |
How many sheets and cells the workbook has. |
X-Preview-Uncomputed-Formulas |
How many formula cells are shown empty: the workbook holds no values for them. |
- The other embedding modes—Embedding modes.
- The same container path, but with the editor—the SumDoc editor in the browser and the SumSheet processor on the server.