Asciidoctor-pdf: Setting size of title page background image possible?

Created on 9 Mar 2017  路  4Comments  路  Source: asciidoctor/asciidoctor-pdf

I am unable to set the size of the title page background image, both via the theme file or the in-document specifier :title-page-background-image: image:title-bg.jpg[]

If I add [width=20%] or similar, it gets ignored.

Is this even supported? If not, it would be nice to have support for this.

Thanks!

Most helpful comment

Support has been added. (Addressed by #1124 and #765). You can control the size and position using the following attributes:

  • pdfwidth (just like any other image)
  • fit (none, cover, contain, scale-down) (like object-fit in CSS)
  • position (accepting all keyword combinations as in background-position in CSS)

So, for example:

:title-page-background-image: image:bg.png[pdfwidth=50%,position=bottom right]

or

:title-page-background-image: image.bg.png[fit=contain,position=top]

All 4 comments

That's correct. It is currently not possible to set the size of the background image. The background image is scaled down to fit the bounds of the page. The best way to size it would be to create a canvas in a graphics editor that matches the size of the page, then place the image where you want it in that canvas and save the image. That way, you can not only control the size, but the position as well.

I've added a note about this in the theming guide.

In the future, we may add control over the size and position, esp now that we've introduced the fit attribute, which is available for images in running content.

Support has been added. (Addressed by #1124 and #765). You can control the size and position using the following attributes:

  • pdfwidth (just like any other image)
  • fit (none, cover, contain, scale-down) (like object-fit in CSS)
  • position (accepting all keyword combinations as in background-position in CSS)

So, for example:

:title-page-background-image: image:bg.png[pdfwidth=50%,position=bottom right]

or

:title-page-background-image: image.bg.png[fit=contain,position=top]
Was this page helpful?
0 / 5 - 0 ratings