Changing format of the file

187 Views Asked by At

Can I change the format of the file by using Native File System API? For example, when I read the every .pdf files of the one directory and changed them to the .jpeg files?

1

There are 1 best solutions below

0
On

You can use a library like PDF.js to run the conversion as outlined in this gist. For the actual folder iteration, try this:

const dirHandle = await window.showDirectoryPicker();
for await (const entry of dirHandle.values()) {
  if (entry.kind === 'file' && entry.name.endsWith('.pdf')) {
    const file = await entry.getFile();
    // Convert to image as outlined in gist.
  }
}