mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-05 00:29:48 +03:00
Export all books to pdf #1606
Closed
opened 2026-02-05 01:24:26 +03:00 by OVERLORD
·
17 comments
No Branch/Tag Specified
development
l10n_development
further_theme_development
release
llm_only
vectors
v25-11
docker_env
drawio_rendering
user_permissions
ldap_host_failover
svg_image
prosemirror
captcha_example
fix/video-export
v25.12.3
v25.12.2
v25.12.1
v25.12
v25.11.6
v25.11.5
v25.11.4
v24.11.4
v25.11.3
v25.11.2
v25.11.1
v25.11
v25.07.3
v25.07.2
v25.07.1
v25.07
v25.05.2
v25.05.1
v25.05
v25.02.5
v25.02.4
v25.02.3
v25.02.2
v25.02.1
v25.02
v24.12.1
v24.12
v24.10.3
v24.10.2
v24.10.1
v24.10
v24.05.4
v24.05.3
v24.05.2
v24.05.1
v24.05
v24.02.3
v24.02.2
v24.02.1
v24.02
v23.12.3
v23.12.2
v23.12.1
v23.12
v23.10.4
v23.10.3
v23.10.2
v23.10.1
v23.10
v23.08.3
v23.08.2
v23.08.1
v23.08
v23.06.2
v23.06.1
v23.06
v23.05.2
v23.05.1
v23.05
v23.02.3
v23.02.2
v23.02.1
v23.02
v23.01.1
v23.01
v22.11.1
v22.11
v22.10.2
v22.10.1
v22.10
v22.09.1
v22.09
v22.07.3
v22.07.2
v22.07.1
v22.07
v22.06.2
v22.06.1
v22.06
v22.04.2
v22.04.1
v22.04
v22.03.1
v22.03
v22.02.3
v22.02.2
v22.02.1
v22.02
v21.12.5
v21.12.4
v21.12.3
v21.12.2
v21.12.1
v21.12
v21.11.3
v21.11.2
v21.11.1
v21.11
v21.10.3
v21.10.2
v21.10.1
v21.10
v21.08.6
v21.08.5
v21.08.4
v21.08.3
v21.08.2
v21.08.1
v21.08
v21.05.4
v21.05.3
v21.05.2
v21.05.1
v21.05
v21.04.6
v21.04.5
v21.04.4
v21.04.3
v21.04.2
v21.04.1
v21.04
v0.31.8
v0.31.7
v0.31.6
v0.31.5
v0.31.4
v0.31.3
v0.31.2
v0.31.1
v0.31.0
v0.30.7
v0.30.6
v0.30.5
v0.30.4
v0.30.3
v0.30.2
v0.30.1
v0.30.0
v0.29.3
v0.29.2
v0.29.1
v0.29.0
v0.28.3
v0.28.2
v0.28.1
v0.28.0
v0.27.5
v0.27.4
v0.27.3
v0.27.2
v0.27.1
v0.27
v0.26.4
v0.26.3
v0.26.2
v0.26.1
v0.26.0
v0.25.5
v0.25.4
v0.25.3
v0.25.2
v0.25.1
v0.25.0
v0.24.3
v0.24.2
v0.24.1
v0.24.0
v0.23.2
v0.23.1
v0.23.0
v0.22.0
v0.21.0
v0.20.3
v0.20.2
v0.20.1
v0.20.0
v0.19.0
v0.18.5
v0.18.4
v0.18.3
v0.18.2
v0.18.1
v0.18.0
v0.17.4
v0.17.3
v0.17.2
v0.17.1
v0.17.0
v0.16.3
v0.16.2
v0.16.1
v0.16.0
v0.15.3
v0.15.2
v0.15.1
v0.15.0
v0.14.3
v0.14.2
v0.14.1
v0.14.0
v0.13.1
v0.13.0
v0.12.2
v0.12.1
v0.12.0
v0.11.2
v0.11.1
v0.11.0
v0.10.0
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.2
v0.8.1
v0.8.0
v0.7.6
v0.7.5
v0.7.4
v0.7.3
0.7.2
v.0.7.1
v0.7.0
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
Labels
Clear labels
🎨 Design
📖 Docs Update
🐛 Bug
🐛 Bug
:cat2:🐈 Possible duplicate
💿 Database
☕ Open to discussion
💻 Front-End
🐕 Support
🚪 Authentication
🌍 Translations
🔌 API Task
🏭 Back-End
⛲ Upstream
🔨 Feature Request
🛠️ Enhancement
🛠️ Enhancement
🛠️ Enhancement
❤️ Happy feedback
🔒 Security
🔍 Pending Validation
💆 UX
📝 WYSIWYG Editor
🌔 Out of scope
🔩 API Request
:octocat: Admin/Meta
🖌️ View Customization
❓ Question
🚀 Priority
🛡️ Blocked
🚚 Export System
♿ A11y
🔧 Maintenance
> Markdown Editor
No Label
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/BookStack#1606
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Buliwif on GitHub (Mar 24, 2020).
Hi,
Maybe this is an existant feature but I didn't found it.
Is there a way to export all books to pdf format ?
It should be great after a long work of documentation integration .
Thank you :) Bookstack is amazing
@Dayflare commented on GitHub (Mar 25, 2020):
there is a python script which can do this
https://www.reddit.com/r/selfhosted/comments/b50154/bookstack_auto_export_all/
@ssddanbrown commented on GitHub (Apr 1, 2020):
Hi @Buliwif,
Thanks for the request and your compliments!
Could you confirm what exact feature you desire out of these two, just to ensure I understand:
@Borbosch commented on GitHub (Apr 9, 2020):
Unfortunately that tool won't work anymore and the maintainer won't respond to any issues.
The intended function of the python-tool would be great as a native function of bookstack.
Export all books in my instance to individual PDF, html or plaintext files, in a single action. Best way would be via the rest-api so that i could trigger it on my own terms (like cronjob).
The main idea behind this:
All my documentation on my infrastructure and ways to rebuild parts of it are in bookstack. Bookstack in itself works in a Dockercontainer on this infrastructure and is not accessible during maintenance or power failure.
With this feature i could generate a offline-capebable Version of the Documentation in recuring interval without the need of a working boostack-installation. This way it could be stored on an usb-stick, SD-Card or similiar which would always work in a phone oder tablet for itself.
@nmehlei commented on GitHub (Apr 13, 2020):
Also, since bookstack doesn't really have a simple "Just backup everything" functionality (yet) this export-all functionality would be kind of a nice alternative to that. True, it would not be restorable, but at least all the content "would be there and readable" if something should happen to the Bookstack instance.
@Borbosch commented on GitHub (Apr 15, 2020):
Wow! In the newest beta there is an API-Endpoint for exporting books as PDF, html and plaintext!
Thank you so much!
The only thing missing for my usecase is the "export all books via API". But i can do a workaround by first getting all book-ids by /api/books and then exporting them one by one.
@ssddanbrown commented on GitHub (Apr 15, 2020):
@Borbosch No problem, I thought I'd sneak in that feature after seeing the messages on this thread. Just shout if you want me to put together a script for going through all books and fetching the export content.
@Borbosch commented on GitHub (Apr 16, 2020):
@ssddanbrown
Shout! I would be grateful if you could do that!
@Dayflare commented on GitHub (Apr 16, 2020):
@ssddanbrown i would appreciate that too!
@ssddanbrown commented on GitHub (Apr 16, 2020):
@Dayflare @Borbosch Have put together an example script here:
https://gist.github.com/ssddanbrown/45acb913a7b873240b2d89781e74a7a4
Seems to work on my dev machine. Lemme know if you have any issues or are unsure about the steps required to run it.
@Borbosch commented on GitHub (Apr 19, 2020):
Thank you very much. Works great in my dev-enviroment.
Since i already use node-red for most of my automation, i build a flow that does mostly the same. Nonetheless i'm very thankfull!
@Dayflare commented on GitHub (May 8, 2020):
@ssddanbrown thank you very much, works wonderful. I configured a cron to export all books every week, works nice and it's a good worst case security strategy.
@ssddanbrown commented on GitHub (May 12, 2020):
Awesome, glad the script helped.
I think I'll close this off with the above, and since the OP never responded to the original question put forward. Exporting all books via the UI either way is going to be technically problematic as scaling issues would quickly become realised, It's best left for API cases such as the above.
@Buliwif commented on GitHub (May 19, 2020):
Hi,
I'm sorry to reopen and to be so late on my answers.
Thank you very much to make this script.
I have no knowledge of php so it don't work for me. What I do :
Generate a token on my admin profile.
Modify the begining of the script like this :
$apiUrl = getenv('BS_URL') ?: 'https://bookstack.domain.tld';
$clientId = getenv('BS_TOKEN_ID') ?: 'My tokenID';
$clientSecret = getenv('BS_TOKEN_SECRET') ?: 'My TokenSecret';
I have this result :
PHP Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/MYUSER/exportpdf/export-books.php on line 72
PHP Warning: file_get_contents(https://bookstack.domain.tld/api/books?count=100&offset=0): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/MYUSER/exportpdf/export-books.php on line 72
PHP Fatal error: Uncaught TypeError: Return value of apiGetJson() must be of the type array, null returned in /home/MYUSER/exportpdf/export-books.php:81
Stack trace:
#0 /home/MYUSER/exportpdf/export-books.php(48): apiGetJson('api/books?count...')
#1 /home/MYUSER/exportpdf/export-books.php(20): getAllBooks()
#2 {main}
thrown in /home/MYUSER/exportpdf/export-books.php on line 81
What I'm doing wrong please ?
@Dayflare commented on GitHub (May 19, 2020):
@Buliwif seems like your Bookstack URL is wrong. If you run the script from the same server where bookstack is installed try http://localhost
@Buliwif commented on GitHub (May 19, 2020):
I try this and it change effectively the return but I still have error :
PHP Warning: file_get_contents(http://localhost/api/books/43/export/pdf): failed to open stream: HTTP request failed! HTTP/1.0 429 Too Many Requests
in /home/myuser/exportpdf/export-books.php on line 72
But for most of my books it seems work, but files are unreadable .
thank you very much for helping me :)
@Dayflare commented on GitHub (May 19, 2020):
@Buliwif this is not an error from the script anymore.
Your bookstack server is blocking the connection because of too many requests while parsing the books. Try to set the rate limit higher on your server or modify the script to pause after some books and then resume.
@Buliwif commented on GitHub (May 25, 2020):
Thank you so much.