- Removed different PDF template used on pages.
- Updated export view files to have the intended format passed.
- Shared the export CSS amoung the export templates.
Should hopefully address #1886
public function pageToContainedHtml(Page $page)
{
$page->html = (new PageContent($page))->render();
- $pageHtml = view('pages/export', [
- 'page' => $page
+ $pageHtml = view('pages.export', [
+ 'page' => $page,
+ 'format' => 'html',
])->render();
return $this->containHtml($pageHtml);
}
$pages->each(function ($page) {
$page->html = (new PageContent($page))->render();
});
- $html = view('chapters/export', [
+ $html = view('chapters.export', [
'chapter' => $chapter,
- 'pages' => $pages
+ 'pages' => $pages,
+ 'format' => 'html',
])->render();
return $this->containHtml($html);
}
public function bookToContainedHtml(Book $book)
{
$bookTree = (new BookContents($book))->getTree(false, true);
- $html = view('books/export', [
+ $html = view('books.export', [
'book' => $book,
- 'bookChildren' => $bookTree
+ 'bookChildren' => $bookTree,
+ 'format' => 'html',
])->render();
return $this->containHtml($html);
}
public function pageToPdf(Page $page)
{
$page->html = (new PageContent($page))->render();
- $html = view('pages/pdf', [
- 'page' => $page
+ $html = view('pages.export', [
+ 'page' => $page,
+ 'format' => 'pdf',
])->render();
return $this->htmlToPdf($html);
}
$page->html = (new PageContent($page))->render();
});
- $html = view('chapters/export', [
+ $html = view('chapters.export', [
'chapter' => $chapter,
- 'pages' => $pages
+ 'pages' => $pages,
+ 'format' => 'pdf',
])->render();
return $this->htmlToPdf($html);
public function bookToPdf(Book $book)
{
$bookTree = (new BookContents($book))->getTree(false, true);
- $html = view('books/export', [
+ $html = view('books.export', [
'book' => $book,
- 'bookChildren' => $bookTree
+ 'bookChildren' => $bookTree,
+ 'format' => 'pdf',
])->render();
return $this->htmlToPdf($html);
}
@import "text";
@import "layout";
@import "blocks";
-@import "forms";
@import "tables";
@import "header";
@import "lists";
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{{ $book->name }}</title>
+ @include('partials.export-styles', ['format' => $format])
+
<style>
- @if (!app()->environment('testing'))
- {!! file_get_contents(public_path('/dist/export-styles.css')) !!}
- @endif
.page-break {
page-break-after: always;
}
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{{ $chapter->name }}</title>
+ @include('partials.export-styles', ['format' => $format])
+
<style>
- @if (!app()->environment('testing'))
- {!! file_get_contents(public_path('/dist/export-styles.css')) !!}
- @endif
.page-break {
page-break-after: always;
}
}
}
</style>
- @yield('head')
@include('partials.custom-head')
</head>
<body>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{{ $page->name }}</title>
- <style>
- @if (!app()->environment('testing'))
- {!! file_get_contents(public_path('/dist/export-styles.css')) !!}
- @endif
- </style>
- @yield('head')
+ @include('partials.export-styles', ['format' => $format])
+
+ @if($format === 'pdf')
+ <style>
+ body {
+ font-size: 14px;
+ line-height: 1.2;
+ }
+
+ h1, h2, h3, h4, h5, h6 {
+ line-height: 1.2;
+ }
+
+ table {
+ max-width: 800px !important;
+ font-size: 0.8em;
+ width: 100% !important;
+ }
+
+ table td {
+ width: auto !important;
+ }
+ </style>
+ @endif
+
@include('partials.custom-head')
</head>
<body>
+++ /dev/null
-@extends('pages/export')
-
-@section('head')
- <style>
- body {
- font-size: 14px;
- line-height: 1.2;
- }
-
- h1, h2, h3, h4, h5, h6 {
- line-height: 1.2;
- }
-
- table {
- max-width: 800px !important;
- font-size: 0.8em;
- width: 100% !important;
- }
-
- table td {
- width: auto !important;
- }
-
- .page-content .float {
- float: none !important;
- }
-
- .page-content img.align-left, .page-content img.align-right {
- float: none !important;
- clear: both;
- display: block;
- }
- </style>
-@stop
\ No newline at end of file
--- /dev/null
+<style>
+ @if (!app()->environment('testing'))
+ {!! file_get_contents(public_path('/dist/export-styles.css')) !!}
+ @endif
+</style>
+
+@if ($format === 'pdf')
+ <style>
+ /* Patches for CSS variable colors */
+ a {
+ color: {{ setting('app-color') }};
+ }
+
+ blockquote {
+ border-left-color: {{ setting('app-color') }};
+ }
+
+ /* Patches for content layout */
+ .page-content .float {
+ float: none !important;
+ }
+
+ .page-content img.align-left, .page-content img.align-right {
+ float: none !important;
+ clear: both;
+ display: block;
+ }
+ </style>
+@endif
\ No newline at end of file