cancel
Showing results for 
Search instead for 
Did you mean: 

Generate dynamic pdf from template file in sapui5 using JavaScript

0 Kudos

Hello Experts,

I want to generate a PDF file in SAPUI, but template which I need to refer is stored in a Word document. In that template I need to dynamically provide few values and than want to generate a PDF. Is is possible to achive in SAPUI5.

Looking for any help or new suggestions.

Thanks for your time!

Mahak

Accepted Solutions (0)

Answers (1)

Answers (1)

thalesvb
Active Contributor

Hi, this is not direclty possible in SAPUI5. But being a JavaScript code (communicating with a backend) you can do anything in code (even by yourself if no one done yet).

Barely searching on NPM registry I already found a library to fill a Word Template with values that is compatible to use in browsers. I also found others to convert Word to PDF, but on my narrow search it didn't listed one that explicitly tells it is browser-compatible (but there are more than a million packages out there, probably there is one for it. You just have to glue those two parts with code and you have your problem solved.

But the main concern here is: should you be really doing this on Interface Layer (UI5, browser)? Any code residing in that layer can be easily manipulated to generate a counterfeit document. If that document is something that could have any liability (like a invoice, contract, and many other business documents) you shouldn't be generating it on Interface layer, but on backend itself. You have a plethora of options to implement it (JavaScript/Node being one of them, but you'll find some sketches about how to do it documented, as a question, on StackOverflow).

Hope that gives you a broad view about how you can accomplish it some concerns you must have when implementing it.

Best regards