Open arthurattwell opened 7 years ago
Here is another example from an A6 booklet with full-page and DPS adverts. The styling is in Sass.
Markdown for single, full-page adverts:
> ![Advertiser](images/advert-fullpage.jpg)
{:.advert .fullpage}
Markdown for DPS adverts:
> ![Advertiser](images/advert-dps.jpg)
{:.advert .dps-left}
> ![Advertiser](images/advert-dps.jpg)
{:.advert .dps-right}
Print Sass:
@page {
size: 105mm 148mm;
prince-bleed: 2.5mm;
prince-trim: 2.5mm;
}
// Adverts
@page advert {
margin: -5mm;
background-color: pink; // helps spot missing image files easily
}
.advert {
page: advert;
}
.fullpage {
margin-top: -5mm;
margin-left: -4mm; // Inexplicably, 1mm off. Don't yet know why that's necessary.
height: 148mm + 10mm;
width: 105mm + 10mm;
}
.fullpage p img {
height: 100%;
width: 100%;
}
.dps-left {
page-break-before: left;
float: top;
margin-top: -5mm;
margin-left: -4mm;
height: 148mm + 10mm; // Exact height of the image plus bleed on both sides
width: 105mm + 5mm; // Page width plus one side's bleed
text-align: left;
}
.dps-right {
float: top next;
margin-top: -5mm;
margin-left: -4mm;
height: 148mm + 10mm; // Exact height of the image plus bleed on both sides
width: 105mm + 5mm; // Page width plus one side's bleed
text-align: right;
}
.dps-left p img {
width: 105mm + 105mm + 10mm;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.dps-right p img {
width: 105mm + 105mm + 10mm;
height: 100%;
position: absolute;
top: 0;
right: 0;
}
Epub and web Sass must include:
// Hide second instance of images intended for DPS in print
.dps-right {
display: none;
}
We have a way to do this, albeit clumsy, described in this thread. I'm leaving it open though in the hope that we'll find a better way. For instance, it may be possible to create an html snippet include that takes a file name as a parameter, e.g.
{% include dps-image.html src="pic.jpg" title="My picture" %}
Documented in 1ca8668fcd9a5adaba651fd94420f6861af655b1.
I'm working on a JS-assisted way to do this. The idea is that by adding a dps
class to a figure or image, we can have JS duplicate the image and apply classes that let us position the images with CSS.
Work in progress in this branch.
From @arthurattwell on January 6, 2017 12:12
From @arthurattwell on October 7, 2016 11:38
From @arthurattwell on August 27, 2015 12:35
Images over a DPS are difficult to do in this framework, but it is possible. It's a bit of a hack, but once we've used it a few times and we feel the method is reliable, we may built it into the framework natively.
Of course, images across a DPS are not an ebook or web issue (if an ereader or browser shows 'pages' as a DPS, we have no control over it anyway). They are only a print issue. The problem is that PrinceXML does not provide a mechanism for placing images (or any element) across a spread.
In short, what we do is place the image twice, each in a blockquote element. Using PrinceXML's
next
modifier for floats, we float the blockquote elements on the first and second pages of the DPS respectively. Inside each blockquote, we position the image so that, on the left, only the left half of the image shows; and on the right, only the right half of the image shows.This all depends on placing your image reference in a way that the first blockquote–image falls on a left-hand page.
Here's how to do it:
In the markdown text file, place the image twice, each inside a blockquote, and tag the first instance
{:.dps-left}
and the second{:.dps-right}
.Hide the second instance of the image in any screen or epub CSS:
In print CSS, use this. Follow the comments to modify sizes to suit your page size and layout:
That's all based on these page settings. Yours may differ, affecting your margins, heights and widths accordingly:
We've done very little testing with this so far.
Copied from original issue: electricbookworks/electric-book-workflow#3
Copied from original issue: electricbookworks/electric-book#20
Copied from original issue: electricbookworks/electric-book-workflow#37