function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dev perdev per 

Does salesforce generate a PDF copy of content DOCX file in order to display in preview?

I am trying to understand how salesforce generates the PDF preview on a contnet file that is of .docx? When we click on preview for a docx file in content, it initially says preview not available but after sometime that preview is enabled. Does this mean Salesforce converts the docx to pdf and saves it somewhere on the server? If Yes is there a way to access this pdf copy directly? Apperciate any help! 
Best Answer chosen by dev per
dev perdev per
Answering my question. 

We can use connect/Files api for getting the pdf version of a Docx files stored in content document as shown below:
 
HttpRequest req=new HttpRequest();
        req.setMethod('GET');
        req.setHeader('Authorization', 'OAuth '+UserInfo.getSessionId());
        req.setEndpoint(System.URL.getSalesforceBaseUrl().toExternalForm()+'/services/data/v45.0/connect/files/'+link.ContentDocumentId+'/rendition?type=PDF');
    HttpResponse response=new Http().send(req);
    
    ContentVersion conVer = new ContentVersion();
            conVer.ContentLocation = 'S'; 
            conVer.PathOnClient = 'AgreementDocument_'+num+'.pdf'; 
            conVer.Title = 'AgreementDocument_'+num;
            conVer.VersionData = response.getBodyAsBlob(); 
    insert conVer;