cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Generate single PDF of image collection stored in a Folder

AyushJSuMo
Discoverer
0 Likes
266

Hi Everyone,

I have folder on my system which has n number of images. What I want is to generate a single pdf which contains these images. I have made a service in SAP BAS but what I want is that I will pass my folder path using which the service will generate a single pdf of these images stored in this folder path.

How do i do it using UI5 and CAPM or any other method present in it.

Regards,

Ayush

Accepted Solutions (0)

Answers (1)

Answers (1)

MattBrightman
Explorer
0 Likes

Not exactly answering your question but some inspiration: 

1. Assuming you have a defined an action such as generatePDF with a parameter for a server side directory

2. In the action implementation you need to be able to read on a the files in the server side directory. Something like: 

const testFolder = './tests/';
const fs = require('fs');

fs.readdir(testFolder, (err, files) => {
  files.forEach(file => {
    console.log(file);
  });
});

Please note that this was stolen from: https://stackoverflow.com/questions/2727167/how-do-you-get-a-list-of-the-names-of-all-files-present-...

2. You need to take each of these files and generate a PDF. Looks like PDFKIT will do the job. See the accepted answer here: https://stackoverflow.com/questions/51054745/how-to-convert-multiple-images-into-single-pdf-using-no...

3. Now you need to return the PDF. Maybe have a look here to see if this helps: https://community.sap.com/t5/technology-blogs-by-members/returning-a-buffer-file-from-cap/ba-p/13495...