Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Header/Footer for PDF Export #493

Open
sirup opened this issue Aug 31, 2017 · 21 comments
Open

[FEATURE] Header/Footer for PDF Export #493

sirup opened this issue Aug 31, 2017 · 21 comments

Comments

@sirup
Copy link

sirup commented Aug 31, 2017

For Feature Requests

For PDF etc. Export it would be nice to set a global Header/Footer to identify where the file is from etc. Maybe also wih Dynamic Fields like Version / Date / Creator.

@Chris-ZA
Copy link

I would support this request. I was thinking about this the other day when I exported a book.

Our current Microsoft Word document template have this and it helps a lot to have this information on a PDF or printed document.

@aljawaid
Copy link

aljawaid commented Oct 6, 2017

This would be ideal. Shame we can't currently add the logo or other bits and have the option to remove the 'last edited by' information. Page numbers and a possible optional front cover page would be good too.

@p0lp0
Copy link

p0lp0 commented Nov 10, 2017

Agree, good request.

@PWA-GouldA
Copy link

I also support this feature.

The feature should have items such as:

  • page numbers
  • chapter title/number
  • book title
  • draft (when not finalised)
  • logo
  • date/time
  • author/editors/etc

@badsmoke
Copy link

is there any news on this topic?

@injektion
Copy link

Hey @ssddanbrown - I've pushed a branch ( https://github.com/injektion/BookStack/tree/exportheaders ) which might help with this... For exports, it'll display a page number in the footer and allow users to create a page to include as a header on every page.

Most of the juice is in partials/export-header-footer.blade.php which is now included in all the /views/[books|chapters|pages]/export.blade.php and checks for a couple .env variables

EXPORT_HEADER_PAGE_SLUG=header
EXPORT_SHOW_PAGE_NUMBERS=true

There's some extra CSS added to partials/export-styles.blade.php which sets up a counter for pages, and if the .env is true will drop it into a footer div

        .pagenum:before {
            content: counter(page);
        }

As for the header, I'm currently letting the user define a page as their header, and then in partials/export-header-footer.blade.php using the slug of that page to import a header....

@if(env("EXPORT_HEADER_PAGE_SLUG"))
<div class="header">
    @php
        $PAGE = new \BookStack\Entities\Page();
        $page = $PAGE::where("slug", "=", env("EXPORT_HEADER_PAGE_SLUG"))->first();
        $page->html = (new \BookStack\Entities\Managers\PageContent($page))->render();
    @endphp
    {!! $page->html !!}
</div>
@endif

It's working fine to allow the user to create their own headers, add some page numbering, and export, but I think there's probably a better flow to how to get the user to define the page to use as their header... Do you have any recommendations on where you'd like to see the header get defined, or do you think this will work for those who want it?

@lenusch
Copy link

lenusch commented Sep 11, 2020

Hey @ssddanbrown - I've pushed a branch ( https://github.com/injektion/BookStack/tree/exportheaders ) which might help with this... For exports, it'll display a page number in the footer and allow users to create a page to include as a header on every page.

can i with this disable Footer informations in PDF? I don't want author etc. inside of Footer.

@joaovitorteixeira
Copy link

Hey @ssddanbrown, is there any new about this feature?

@emilbasv3
Copy link

Any news on this? It would be much appreciated!

@cervantesl
Copy link

Any news on this?

I also support this feature.

Thx.

@ssddanbrown
Copy link
Member

There is no news on this upon any additional context within #2311. If there was you'd likely see something here.

The only difference since that PR is that we're now probably more DOMPDF focused rather than WKHTMLtoPDF.
Like mentioned in that PR, the visual theme system could likely be used to achieve this, although it may be worth us making template changes to better accommodate this specific feature.

@ssddanbrown
Copy link
Member

If it helps, I just published a video on using the visual theme system to achieve a footer on PDF exports with the default DomPDF renderer:
https://youtu.be/5bZ7zlNEphc

@ADMDW
Copy link

ADMDW commented Mar 25, 2023

Your video is very helpful - thank you.
How can the book title, chapter, and page name be added in addition to the page number?
Thanks.

@ADMDW
Copy link

ADMDW commented Mar 26, 2023

I have found the following after some experimentation:

<div style="float: right; text-align:right; max-width: 530px; font-size:11px;">
	@if(isset($page))
		{{ $page->book->name }}
		<br>
		<i>{{ $page->name }}</i>
	@else
		{{ $book->name }}
	@endif
</div>

When I export only one page, both the book title and the page title are displayed, and when I export the entire book, only the book title is displayed. This works for my needs.

@ADMDW
Copy link

ADMDW commented Mar 26, 2023

This is the whole content of my /var/www/bookstack/themes/myTemplate/layouts/parts/export-body-start.blade.php file:

{{-- This is a placeholder template file provided as a --}}
{{-- convenience to users of the visual theme system. --}}

@if ($format === 'pdf')
  <style media="print">
    .print-header-footer {
      position: fixed;
      width: 100%;
    }
    .print-footer {
      position: fixed;
      width: 100%;
      bottom: -40px;
    }
    .print-header-footer-inner {
      max-width: 840px;
      margin: 0px;
      color: #666;
    }
    .print-page-number:after {
      content: "Seite " counter(page);
    }
    @page {
      margin-top: 110px;
      margin-bottom: 60px;
    }
</style>

<!-- Header -->
<div class="print-header-footer" style="top: -90px;">
	<div class="print-header-footer-inner">
		<div style="float: left; margin:-5px;">
			<img height="48px" src="data:image/png;base64,{{ base64_encode(file_get_contents(theme_path('DWLogo.png'))) }}">
		</div>
		<div style="float: right; text-align:right; max-width: 530px; font-size:11px;">
			@if(isset($page))
    		{{ $page->book->name }}
			<br>
			{{ $page->name }}
			@else
 			{{ $book->name }}
			@endif
		</div>
	</div>
	<div style="clear:both;"></div>
<hr>
</div>
<!-- /Header -->
<!-- Footer -->
<div class="print-header-footer" style="bottom: -40px;">
<hr>
	<div class="print-header-footer-inner">
		<div style="float: left;">
			<!-- ggf. Text unten links -->
		</div>
		<div style="float: right;">
			<div class="print-page-number"></div>
		</div>
	</div>
	<div style="clear:both;"></div>
</div>
<!-- /Footer -->
@endif

To make the function work, add the own template in the /var/www/bookstack/.env file:

APP_THEME=myTemplate

@SuperPat45
Copy link

I know a JavaScript library named paged.js https://pagedjs.org/documentation/ which allow complex headers, footers with page numbers, table of content with page number...
I use it to generate a full PDF book (1500 pages) in one of my project with node.js + puppeteer module + chromium

@SLongus
Copy link

SLongus commented Sep 22, 2023

This Request is opened since 2017. We try BookStack for as our Documentacion system, but without this function it's not functional for us. The Work Around in the youtube video is very nice, but what are the problems when updating to a new version? That looks like it could be problematic...

@mitchell-accipio
Copy link

We are also using Bookstack as our Documentation system and we use WKHTMLtoPDF for PDF exports thanks to the superior exporting aesthetics; I have seen This Issue That could potentially solve some of the layout issues on DomPDF for us, but branding would be incredibly useful since we want to be able to export policies to provide to customers as part of tender, for example.

In my opinion Export Branding would provide a great enhancement of features that would make Bookstack more usable as a business solution.

I will take solutions in this issue and other relevant issues into consideration but would love to highlight this feature as something my organisation could really use.

@Koruyo
Copy link

Koruyo commented Nov 17, 2023

For our uses, PDF export would need an index with page numbers, and page headers and or footers with current page/numberofpages e.g. Page 5/200

Sadly i cant find any solution to make bookstack work for us.

While one can hack in simple page numbers in a header or footer (following the youtube video of bookstack about this), it remains sub-optimal for printed documentations not having an index with page numbers and the maximum number of pages to make sure the document is complete/stays/stayed complete.
I really like bookstack, i hope some day i can finally make it work for us... (every few years i check sadly it still remains open)

@SLongus
Copy link

SLongus commented Feb 9, 2024

Any news on this feature? This would be so important =(

@lxwulf
Copy link

lxwulf commented Nov 3, 2024

I would also like to know how it's going with this issue or better say feature request…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests