8

When I am using a html document ('SimplePage.html') with the following content

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

Libreoffice (LibreOffice_5.1.2 on Windows 7) produces an pdf having the first page blank and then writing not the full text - instead only "a simple Hello World" is shown

I am using the following command line

soffice.exe --headless --convert-to pdf SimplePage.html

When I do the conversion not in headless mode (opening Libreoffice writer and the using "Export" the generated pdf is correct. Therefore I think it's not a problem of the used HTML. Does anyone know the reason and a solution to this problem?

2
  • Where the text is shown? If it starts right at the left edge of the page then it might be that the start of the sentence is "off page", ie the start coordinate of the text is for some reason negative (when we consider the left edge as zero coordinate). Also you could look inside the pdf to see is the text actually there (easier if the content stream of the page is not filtered). Commented Apr 25, 2016 at 19:24
  • yes, the test is shown on the second page at the upper left corner. It does not look like the text is inside the file, because several pdf readers cannot find any parts of the string. I also tried to look inside via notepad++ without any success. The strange thing is that via the graphical interface of libre office the pdf is created correctly Commented Apr 26, 2016 at 16:14

2 Answers 2

10

You should try writhing this:

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

it worked for me, the point was to add --writer option

Sign up to request clarification or add additional context in comments.

1 Comment

To expand on this answer, by default Open/LibreOffice converts an HTML to PDF using the writer_web_pdf_Export filter. Using the --writer option or the *writer.exe binary changes the default to writer_pdf_Export, which seems to work better for many documents. Another option is to specify the exact filter you wish to use: --convert-to pdf:writer_pdf_Export along with any filter-specific options.
2

i ran into this issue recently, even with writer_pdf_Export, and discovered that adding a Content-Security-Policy meta tag seemed to resolve it. i used...

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

and this seems to resolve the hello-world case above as well...

<!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>

(checked using the current LibreOffice 7.0.4.2)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.