I'm trying to create a custom version of the File Preview Modal that appears in Lex when using this approach: Using Navigation Mixin with a page name of 'filePreview'. That approach doesn't work in communities, and while I know I could do it the Aura way, I'm also looking to add some customization to add previews for additional file types. In order to do that, I'm looking to get the generated SVGs of the PDFs that that file preview modal relies on.
In my search of how I could do this, it brought me to ConnectApi.ContentHub.getFilePreview. This would be perfect, HOWEVER it only works for Files Connect files, instead of internal ContentDocuments. Is there an equivalent way to retrieve preview information for internal ContentDocuments?
Alternatively, my last approach would just be copying the URL format of the existing File Preview modal. Something like this: sfc/servlet.shepherd/version/renditionDownload?rendition=SVGZ&versionId={versionId}&operationContext=CHATTER&contentId={contentId}&page=0
but there are two major downsides to this:
- I'm not sure of how I can easily tell how many pages are in a PDF
- It feels fragile and like it could break in a future release