How to convert word streams read by gridfs-stream to pdf

problem description

word files accessed by mongodb need to be displayed in the browser, but the browser is not good at displaying office files, so the current solution is to read word, through gridfs-stream in the background and then convert it to pdf

.

the environmental background of the problems and what methods you have tried

node.js

related codes

const downloadFile = function (isPicture, req, res, next) {
    req.checkParams("id", "id").isMongoId();
    let id = req.params.id;
    let errors = req.validationErrors();
    if (errors) {
        return res.error(errors[0].msg);
    }
    Services.Gridfs.getOne(id).then(function (file) {
        if (file) {
            res.header("Content-Type", file.contentType);
            if (!isPicture) {
                setContentDispositionHeader(req, res, file.filename);
            }
            let gfs = utils.Gridfs.getGridfs();
            var readstream = gfs.createReadStream({
                _id: id
            });
            readstream.on("error", function (error) {
                next(error);
            });
            readstream.pipe(res);
        } else {
            return res.error("", 404);
        }
    }).catch(err=>next(err));
};

what result do you expect? What is the error message actually seen?

Mar.28,2021

No database will help you convert word to PDF. Read it on your own, there are many third-party tools, such as: Office to PDF
is suitable for you to use, please verify for yourself.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31b06-2b600.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31b06-2b600.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?