Closed satramcs closed 3 months ago
@satramcs, I appreciate your report once more 👏 . I'll investigate further since I rely on a third-party package file-type, to detect binary-based file formats by examining the buffer's magic number, and apparently the package does not support text-based formats. I'll update you once the issue has been resolved.
@satramcs, by the way, version 3.0.0
includes some breaking changes. Specifically, I've separated LibreOffice
from PDFEngines
. From now on, instead of using PDFEngine.convert()
, you should use LibreOffice.convert()
. This update was essential to align with Gotenberg's routes, formerly known as modules.
@satramcs I just released a new version with a fix for the issue you mentioned. I also went ahead and dropped the file-type
dependency and used your suggestion. You can see the code changes here, and as I mentioned previously, you would need to use LibreOffice
instead of PDFEngine
.
For reference, here's what the code with your suggestion looked like:
const bufferData = fs.readFileSync(path.join(__dirname, "/resources/1.doc"));
async function main() {
const { LibreOffice } = await import("chromiumly");
const buffer = await LibreOffice.convert({
files: [{data: bufferData, ext: 'doc'}],
});
fs.writeFileSync(path.join(__dirname, "/resources/1.pdf"), buffer);
}
Getting
cfb is not supported
error while trying to convert .doc (buffer) data to .pdf file format.Also below formats are not supported
doc, pot, pps, ppt, vsd, vsdx, xls
doc, pot, pps, ppt, xls, vsd
- through cfb is not supported errorvsdx
- through zip is not supported errorNote: doc and all formats are working fine when provide the direct file path, only issue with buffer data
Sample code
When hardcoded and put the doc and other formats directly in below line then it's working fine. src/libre-office/utils/libre-office.utils.ts![image](https://github.com/cherfia/chromiumly/assets/62286308/364e78da-6652-440a-8ff6-77e3e4ff8b91)
So kindly fix the buffer data issue. Suggestion: May be you can provide the option to get the extension from user when it was a buffer data and get that extension in libre-office.utils.ts