Skip to content
SumOfficeSumOfficeSumOffice

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.

  • 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.

  • 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.

Start:

Terminal window
docker run -d -p 8099:8099 hissih/sumoffice-preview

One 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.

Terminal window
curl -F file=@report.docx http://localhost:8099/thumb?w=320 > thumb.png
curl -F file=@report.docx http://localhost:8099/pages > report.html
curl -F file=@report.docx http://localhost:8099/pdf > report.pdf
curl -F file=@book.xlsx http://localhost:8099/pages > book.html

Response 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.

Documentation assistant

Answers are assembled from the documentation and may be inaccurate — check the sources.