was implemented that in service-now platform. No need to use other library - makepdf have all you need!
that my html part (include preloder gif):
<div class="pdf-preview" ng-init="generatePDF(true)">
<object data="{{c.content}}" type="application/pdf" style="width:58vh;height:88vh;" ng-if="c.content" ></object>
<div ng-if="!c.content">
<img src="https://support.lenovo.com/esv4/images/loading.gif" width="50" height="50">
</div>
</div>
this is client script (js part)
$scope.generatePDF = function (preview) {
docDefinition = {} //you rootine to generate pdf content
//...
if (preview) {
pdfMake.createPdf(docDefinition).getDataUrl(function(dataURL) {
c.content = dataURL;
});
}
}
So on page load I fire init function that generate pdf content and if required preview (set as true) result will be assigned to c.content variable. On html side object will be not shown until c.content will got a value, so that will show loading gif.