Skip to main content
Question

Box API Thumbnail Image for Documents

  • May 21, 2025
  • 2 replies
  • 35 views

Forum|alt.badge.img

The Box View API provided an image of the first page of a document as it's thumbnail - while investigating the preview.js functionality, I was attempting the same call for thumbnail using box-java-sdk and noticed it was the generic PDF file image instead of a first page preview. Is there any way to simulate the view version of thumbnail in the new API?

2 replies

Forum|alt.badge.img

Any news on this? same goes with box-node-sdk, in Crocodoc you used to have a thumbnail for documents, in this api you don't seem to have one?

 


Forum|alt.badge.img

See this https://codepen.io/box-platform/pen/WEwXQy

 

What they do instead is generate representations for files, you can get them here

https://developer.box.com/v2.0/reference#representations

 

Then based on the available type (png or jpg) and available resolution (1024x1024) you can do a request to the info.url to trigger boxview to generate that image, you can then proceed to call representations again but with the X-Rep-Hints header specifying the type and resolution that you want, it will give you a content object with a url_template variable, where you replace the {+asset_path} part of the string with the page number that you want, for example for a png at 1024x1024 and page 1 you would replace it with 1.png

 

you need to call it while passing the auth header like so, adding the token as a parameter in the url will make it all not work.

Authorization: Bearer ACCESS_TOKEN

 

convoluted, but I got it to work in php 🙂