vladholubiev / serverless-libreoffice

Run LibreOffice in AWS Lambda to create PDFs & convert documents
https://vladholubiev.com/serverless-libreoffice
513 stars 75 forks source link

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

Open LLDmitry opened 4 years ago

LLDmitry commented 4 years ago

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

tadasauciunas commented 4 years ago

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

tadasauciunas commented 4 years ago

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

LLDmitry commented 4 years ago

Thank you, it solved the problem

jpike88 commented 4 years ago

@vladgolubev this is a major issue, any comments?

evrardts commented 3 years ago

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!

Jun711 commented 2 years ago

@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?

evrardts commented 2 years ago

@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})

}); `

tadasauciunas commented 2 years ago

@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

Jun711 commented 2 years ago

@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