Libreoffice在命令行上将HTML转换为PDF会产生空白页面

时间:2016-04-25 15:53:20

标签: pdf libreoffice headless

当我使用包含以下内容的html文档(' SimplePage.html ')时

    AdvertiseData advertiseData = new AdvertiseData.Builder()
            .setIncludeDeviceName( true )
            .addServiceUuid( uuid )
            .build();

Libreoffice(Windows 7上的LibreOffice_5.1.2)生成一个pdf,第一页空白,然后写入不是全文 - 而只显示“一个简单的Hello World

我正在使用以下命令行

<!DOCTYPE html> 
<html>
  <title>Page Title</title>
  <body>
    This is just a simple Hello World
  </body>
</html>

当我不进行无头模式转换时(打开Libreoffice编写器和使用“导出”)生成的pdf是正确的。因此我认为这不是使用HTML的问题。 有谁知道这个问题的原因和解决方案?

2 个答案:

答案 0 :(得分:4)

你应该试着扭动这个:

soffice.exe --headless --norestore --writer --convert-to pdf YOURFILE

它对我有用,重点是添加--writer option

答案 1 :(得分:0)

我最近遇到了这个问题,即使是使用 writer_pdf_Export,我发现添加一个 Content-Security-Policy 元标记似乎可以解决它。我用过...

<meta http-equiv="Content-Security-Policy" content="sandbox">

这似乎也解决了上面的 hello-world 情况...

<!DOCTYPE html> 
<html>
  <head>
      <meta http-equiv="Content-Security-Policy" content="sandbox">
      <title>Page Title</title>
  </head>
  <body>
      This is just a simple Hello World
  </body>
</html>

(使用当前的 LibreOffice 7.0.4.2 检查)

相关问题