Skip to content

Instantly share code, notes, and snippets.

@SalesforceBobLightning
Created April 17, 2019 10:51
Show Gist options
  • Save SalesforceBobLightning/757ea31e06ace3e2538580beeb7337ad to your computer and use it in GitHub Desktop.
Save SalesforceBobLightning/757ea31e06ace3e2538580beeb7337ad to your computer and use it in GitHub Desktop.
Create PDF using Docomotion and host publicly
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