Coder Social home page Coder Social logo

Comments (13)

ssddanbrown avatar ssddanbrown commented on September 6, 2024 1

Just to be clear, my linked comment above was just providing support to someone that was knowingly performing config changes outside of what BookStack supports. None of the /config files are intended to be altered by end-users, and custom changes to these are not supported by BookStack itself.

from docker-bookstack.

thelamer avatar thelamer commented on September 6, 2024

This bin is mainlined in Alpine:

https://pkgs.alpinelinux.org/packages?name=wkhtmltopdf&branch=edge&repo=community

you can just install this and set it in your env:

https://www.bookstackapp.com/docs/admin/pdf-rendering/

Add this script to your /config/custom-cont-init.d/install-wkhtmltopdf.sh

#! /bin/bash

# install wkhtmltopdf if it is not installed
if [ ! -f /usr/bin/wkhtmltopdf ]; then
  apk add \
  --no-cache \
  -X http://dl-cdn.alpinelinux.org/alpine/edge/community \
  wkhtmltopdf
fi

from docker-bookstack.

Nebucatnetzer avatar Nebucatnetzer commented on September 6, 2024

It works partially, wkhtmltopdf gets installed but I'm getting this error now.

[2019-06-02 22:24:57] production.ERROR: The process has been signaled with signal "6". {"exception":"[object] (Symfony\\Component\\Process\\Exception\\RuntimeException(code: 0): The process has been signaled with signal \"6\". at /var/www/html/vendor/symfony/process/Process.php:431)

I can provide the full laravel.log if needed.
During the debugging process I found out that it would be useful if the /var/www/html/config directory would be linked to the outside of the container.
In ordner to customize the PDF output one has to edit the snappy.php file in that directory.
That's btw the file which reads the WKHTMLTOPDF variable from the .env file.

A huge thank you by the way for the quick reaction!

from docker-bookstack.

CHBMB avatar CHBMB commented on September 6, 2024

@Nebucatnetzer Have you got any links to the Bookstack upstream stuff about wkhtmltopdf I can understand moving .env files out but moving the core php files out into /config will break future updates potentially.

from docker-bookstack.

CHBMB avatar CHBMB commented on September 6, 2024

OK, reading the docs.

https://www.bookstackapp.com/docs/admin/pdf-rendering/

You need to manually edit /config/www/.env to include the line.

WKHTMLTOPDF=/usr/bin/wkhtmltopdf

from docker-bookstack.

Nebucatnetzer avatar Nebucatnetzer commented on September 6, 2024

@Nebucatnetzer Have you got any links to the Bookstack upstream stuff about wkhtmltopdf I can understand moving .env files out but moving the core php files out into /config will break future updates potentially.

The part that I mean can be found here:
BookStackApp/BookStack#992 (comment)
I know that's not ideal, I'll check with the developer if it's possible to move those variables out of the snapp.php file.
I'm customizing page width, etc. in that file.

I'm aware that you define the binary path in the .env file.
While this does get picked up by Bookstack it gives me the above error when I try to use wkhtmltopdf.

from docker-bookstack.

thelamer avatar thelamer commented on September 6, 2024

I will put this on a todo list, I cannot promise a time frame

from docker-bookstack.

Nebucatnetzer avatar Nebucatnetzer commented on September 6, 2024

@ssddanbrown makes sense and wasn't really understood as such :).
Do you have any plans for the PDF export? Supported options, better defaults, other things?
Does it make sense to have this issue here or do we need an additional one on the bookstack repo?

To me it could be two issues, one here to get the wkthmltopdf binary working and another one over @BookStack for the config options in the .env file.

from docker-bookstack.

CHBMB avatar CHBMB commented on September 6, 2024

Well if it's not supported upstream then we shouldn't be supporting it either.

I can think of ways around it that I'm happy to explain, but it would be with the understanding that it forfeits any support from us and may cause issues when Bookstack gets updates.

from docker-bookstack.

Nebucatnetzer avatar Nebucatnetzer commented on September 6, 2024

wkhtmltopdf is supported by Bookstack. What isn't supported is customisation of it's output.
At least that's my understanding of it being mentioned in the documentation and having a variable in the .env file for the binary path.

from docker-bookstack.

ssddanbrown avatar ssddanbrown commented on September 6, 2024

@Nebucatnetzer Just been playing about with this. Took a while of trial and error but have had luck with the below set as the contents of the install-wkhtmltopdf.sh file (Ensure existing containers with the previous script version are removed before trying):

#!/bin/bash

# wkhtmltopdf installation process taken from:
# https://github.com/LoicMahieu/alpine-wkhtmltopdf/blob/master/Dockerfile

# install wkhtmltopdf if it is not installed
if [ ! -f /usr/bin/wkhtmltopdf ]; then
  apk add \
  --no-cache \
  -X http://dl-cdn.alpinelinux.org/alpine/edge/community \
  wkhtmltopdf \
  xvfb \
  ttf-freefont \
  fontconfig \
  dbus

  apk add \
  --no-cache \
  -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \
  qt5-qtbase-dev

  # Wrapper for xvfb
  mv /usr/bin/wkhtmltopdf /usr/bin/wkhtmltopdf-origin && \
  echo $'#!/usr/bin/env sh\n\
  Xvfb :0 -screen 0 1024x768x24 -ac +extension GLX +render -noreset & \n\
  DISPLAY=:0.0 wkhtmltopdf-origin $@ \n\
  killall Xvfb\
  ' > /usr/bin/wkhtmltopdf && \
  chmod +x /usr/bin/wkhtmltopdf
fi

That seems to work for me. Not sure about long term reliability but it did export. Installing and running WKHTML can be a pain hence why the BookStack default is the less accurate (But still great project) DomPDF.

Other PDF export options have been requested before in BookStack, Some will be view based, some will be renderer based. It's a bit tricky since I don't just want to expose all existing options as BookStack .env options since I don't like implementation-specific options since it'll make things more fragile. I'll have a think, maybe simply an option for developers to override /config values, knowing such changes are risky and unsupported. If you want to talk further about options, feel free to find an existing issue or open a new one on the BookStack repo, since I don't want to distract the ls.io team on here if the discussion is not directly about their awesome containers.

from docker-bookstack.

CHBMB avatar CHBMB commented on September 6, 2024

I've been playing around with this tonight as well. Unfortunately I don't know enough about this kind of thing.

I can offer some modifications to the script above to gain access to snappy.php if that is helpful. But it wouldn't be updated if it were to be modified upstream.

from docker-bookstack.

Nebucatnetzer avatar Nebucatnetzer commented on September 6, 2024

@ssddanbrown your script works for me as well, thank you!
I will continue the discussion about the configuration on the Bookstack repo.

@CHBMB with the current script I think we can close the issue for the moment until a proper solution gets integrated in the upstream project. If I really need to I can hack together a working solution for my self and for other users it's most likely better if they have a proper solution which is supported :).
Shall I create a pull request to extend the README to show how to get wkhtmltopdf working or do we leave it here in the issues?

from docker-bookstack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.