serverless-libreoffice icon indicating copy to clipboard operation
serverless-libreoffice copied to clipboard

Error: Please verify input parameters... on conversion from docx with Table of Contents

Open LLDmitry opened this issue 4 years ago • 9 comments

I use nodejs10 aws lambda + lambda layer created from the latest lo.tar.zip. It works well, but conversion Word docs in which "Table of Contents" exists, raises an error: "Please verify input parameters... (SfxBaseModel::impl_store file:///tmp/file.pdf failed: 0xc10(Error Area:Io Class:Write Code:16))" With previous version - lo.tar.gz the same document is converted successfully

LLDmitry avatar Jan 29 '20 12:01 LLDmitry

Same, having problems with converting docx files containing table of contents.

tadasauciunas avatar Feb 07 '20 14:02 tadasauciunas

Managed to fix the problem by unzipping/decompressing the https://github.com/shelfio/libreoffice-lambda-layer/blob/master/layer.tar.br.zip file, adding directories from share/config directory in normal libreoffice installation to the unzipped libre installation, compressing and zipping it again, and using the result file as a lambda layer. I pushed the result and added some more details to a separate repository, you can download it from it or do the steps yourself: https://github.com/tadasauciunas/libreoffice-lambda-layer-brotli

@vladgolubev I would provide a pull request with this updated libre archive, but it added 35mb to the unzipped/decompressed libreoffice installation, and I'm not sure if that's good enough to release publicly

tadasauciunas avatar Feb 11 '20 09:02 tadasauciunas

Thank you, it solved the problem

LLDmitry avatar Feb 11 '20 14:02 LLDmitry

@vladgolubev this is a major issue, any comments?

jpike88 avatar Jul 30 '20 15:07 jpike88

Hi @tadasauciunas,

Thanks for the solution. However, when creating the layer in AWS, I encounter this issue: "Failed to create layer version: Could not unzip uploaded file. Please check your file, then try to upload again." Any idea where that could come from ? Thanks!

evrardts avatar Jan 05 '21 16:01 evrardts

@tadasauciunas I installed libreoffice 6.4.0.1 on my mac but I can't find share/config directory. Could you provide more information on how to find that directory?

@evrardts Do you know where to find the share/config` directory?

Jun711 avatar Nov 20 '21 01:11 Jun711

@Jun711 I did that long time ago, but here is my code: `app.post('/converttopdf', async function(req, res) {

console.log(execSync('ls -alh /opt').toString('utf8'));

// const inputPath = '/opt/lo.tar.br'; const inputPath = '/opt/lo.tar.br'; // const outputPath = '/tmp/instdir/program/soffice.bin'; const outputPath = '/tmp/instdir/program/soffice.bin';

await unpack({inputPath, outputPath});

wait(1000)

var s3 = new S3({ accessKeyId: process.env.ACCESS_ID, secretAccessKey: process.env.SECRET_KEY, region: process.env.REGION, signatureVersion: 'v4', });

var key = req.apiGateway.event.requestContext.authorizer.claims['custom:companyId'] + req.body.key

var objectData = await getFile(process.env.AWS_COMPANYFILESTORAGE_BUCKET, key, s3)

wait(2000)

// console.log(execSync('ls -alh /tmp').toString('utf8'));

if (! await canBeConvertedToPDF(req.body.fileName)) { res.json({success: 'post call failed!', url: req.url, body: req.body, output: false}) }

writeFileSync(/tmp/${req.body.fileName}, objectData); const outputFilename = await ${parse(req.body.fileName).name}.pdf; const convertCommand = /tmp/instdir/program/soffice.bin --headless --norestore --invisible --nodefault --nofirststartwizard --nolockcheck --nologo --convert-to pdf --outdir /tmp;

let test try { test = await execSync(${convertCommand} /tmp/${req.body.fileName}).toString('utf8') } catch (e) { test = await execSync(${convertCommand} /tmp/${req.body.fileName}).toString('utf8') } console.log(test) // console.log(execSync('ls -alh /tmp').toString('utf8'));

wait(3000)

const outputFileBuffer = await readFileSync(/tmp/${outputFilename});

var slicedKey = key.slice(0, -4) var newKey = slicedKey.concat("pdf")

var responseSlicedKey = req.body.key.slice(0, -4) var responseNewKey = responseSlicedKey.concat("pdf")

var resp = await putFile(process.env.AWS_COMPANYFILESTORAGE_BUCKET, newKey, outputFileBuffer, s3)

fs.unlinkSync(/tmp/${req.body.fileName}) fs.unlinkSync(/tmp/${outputFilename})

// console.log(execSync('ls -alh /tmp').toString('utf8'));

res.json({success: 'post call succeed!', url: req.url, body: req.body, output: true, newKey: responseNewKey})

}); `

evrardts avatar Nov 21 '21 13:11 evrardts

@Jun711 should be where all installed apps are stored, perhaps /Applications/LibreOffice.app/ or something similar. Try which libreoffice in the command line, perhaps it'll give you a clue. In linux it's /usr/lib/libreoffice/share

tadasauciunas avatar Nov 22 '21 06:11 tadasauciunas

@evrardts @tadasauciunas Thanks. I found the share/config folder amer1993 shared the config file in this https://github.com/shelfio/libreoffice-lambda-layer/issues/33

Jun711 avatar Nov 22 '21 19:11 Jun711