Created
April 17, 2019 10:51
-
-
Save SalesforceBobLightning/757ea31e06ace3e2538580beeb7337ad to your computer and use it in GitHub Desktop.
Create PDF using Docomotion and host publicly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class createPublicPDF { | |
private static String getMediaUrl(Id distributionId) { | |
ContentDistribution distribution = [SELECT DistributionPublicUrl FROM ContentDistribution WHERE Id = :distributionId LIMIT 1]; | |
return distribution.DistributionPublicUrl; | |
} | |
public static Id createFaxPDF(Id recordId, Integer formId) { | |
ContentVersion content = new ContentVersion(); | |
content.versionData = doco.RenderAPI.renderBlob(formId, recordId, doco.RenderAPI.Format.PDF); | |
content.title = 'PDF'; | |
content.pathOnClient = '/PDF-file.pdf'; | |
content.FirstPublishLocationId = recordId; | |
insert content; | |
ContentDistribution distribution = new ContentDistribution(ContentVersionId = content.Id, Name = 'PublicShare'); | |
insert distribution; | |
return distribution.Id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment