Bookstack: PDF Export Unknown Error Occurred (font missing?)

Created on 8 Nov 2018  路  6Comments  路  Source: BookStackApp/BookStack

Describe the bug
When I try to export a page as a PDF, it shows "Unknown error occurred"
ErrorException (E_WARNING) fopen(/home/[redacted]/BookStack/app/vendor/dompdf/dompdf/lib/fonts//73a648e04197eba26eb65837ab386447.ufm): failed to open stream: No such file or directory

Steps To Reproduce
Steps to reproduce the behavior:

  1. Create a page (can be blank)
  2. Click Export > PDF
  3. See error

Expected behavior
Export a PDF file of the current page

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): BookStack v0.24.1
  • PHP Version: 7.0
  • Hosting Method (Nginx/Apache/Docker): LiteSpeed

Additional context
The content of this install was migrated from another testing server to this production one (same version) following the guides here: https://www.bookstackapp.com/docs/admin/backup-restore/
Only the URL has changed (I updated it in the database and .env where needed), but remains in the same format, This was otherwise a clean fresh install from Git.

From browsing my folder structure, the location reported in the error message is the wrong location. My folder structure does not seem to include the /app/ section at the beginning. The fonts (not one by the referenced name though) exist in: BookStack/vendor/dompdf/dompdf/lib/fonts
Where should I update this path?

Bug

All 6 comments

Apologies I had missed #1097 when I posted this. Appears to be the same problem. Hopefully my additional info here about the paths will help both of us

I just noticed a comment from "Derek" that I want to reply to, but I think he's deleted it?

He mentions using custom fonts with his issue which is the same as mine. It may be worth noting that I also use Google Fonts on my installation, however this has never been a problem in our test environment, only since moving to production. For what it's worth, the PDF export didn't seem to use the Google font, but something generic like Arial. My Google Font presumably is only applied to the front end using the following code so I don't think it would be related to this issue, but I'll post anyway:

<link href="https://fonts.googleapis.com/css?family=Roboto:300" rel="stylesheet">
<style>
body, button, input, select, label, textarea {
  font-family: 'Roboto', sans-serif;
}
.Codemirror, pre, #markdown-editor-input, .editor-toolbar, .code-base {
  font-family: monospace;
}
</style>

1097 #1107

@boxcomrob I did delete my post because I worked through the error I had posted about (regarding the PDF export failing because it couldn't locate the font resource).

I was calling on my custom fonts as follows;

<style>
  @font-face {
    font-family: 'FontName';
    src: url('../../../uploads/images/fonts/FontName.woff2') format('woff2'),
         url('../../../uploads/images/fonts/FontName.woff') format('woff'),
         url('../../../uploads/images/fonts/FontName.ttf') format('truetype');
    font-weight: bold;
    font-style: italic, oblique;
  }
</style>

To resolve, I changed the url entries as follows;

<style>
  @font-face {
    font-family: 'FontName';
    src: url('https://docs.domain.local/uploads/images/fonts/FontName.woff2') format('woff2'),
         url('https://docs.domain.local/uploads/images/fonts/FontName.woff') format('woff'),
         url('https://docs.domain.local/uploads/images/fonts/FontName.ttf') format('truetype');
    font-weight: bold;
    font-style: italic, oblique;
  }
</style>

However, as you stated, I am noticing that my custom (self-hosted) font is not embedded/exported properly during the PDF export. My issue differs from yours a bit, as custom fonts that I import from googleapi are exported just fine.

Try removing the link href to the stylesheet and import it within the <style></style> section, example;

<style>
  @import url(https://fonts.googleapis.com/css?family=Roboto);

  body, button, input, select, label, textarea {
    font-family: 'Roboto', sans-serif;
  }
  .Codemirror, pre, #markdown-editor-input, .editor-toolbar, .code-base {
    font-family: monospace;
  }
</style>

@boxcomrob did you give my suggestion a shot? I'm curious if it works for you.

@derek-shnosh Your suggestion re @import worked for me, when I was faced with this exact issue.

Was this page helpful?
0 / 5 - 0 ratings