Menu

How to change the cover image

2016-06-05
2016-09-07
  • Martin Köditz

    Martin Köditz - 2016-06-05

    Hi all,

    how can I change the image of my book's front cover? Currently I can see the chameleon tail (dotted version). I would like to set my own front cover picure per book. Since I'm writing on book sets it would be great to have an own image per book. But that is not necessary. In the first step the main cover will be enough.

    Please give me some advises.

    Regards
    Martin

     
  • Martin Köditz

    Martin Köditz - 2016-06-05

    Forgot to mention that I'm using the PDF output.

    Regards
    Martin

     
  • Stefan Knorr

    Stefan Knorr - 2016-06-06

    Hello Martin,

    making the Geeko tail on the cover interchangeable has been an idea on the backburner for a while now -- so far though without an implementation.

    DocBook has the <cover/> element for such purposes and you could write some XSLT to add your own images to the cover page. Just to remove the Geeko tail, disable the template secondary-branding (book.titlepage.templates.xsl, 47).

    I will also add a parameter now, so you can remove this more easily in the future.

     
  • Stefan Knorr

    Stefan Knorr - 2016-06-06

    Done that now -- if you are using the stylesheets from the repo, there is now a parameter enable.secondary.branding which you can set to 0 and which will disable the Geeko tail.

     
  • Martin Köditz

    Martin Köditz - 2016-06-06

    Hello Stefan,

    thank you. I will try to create my own XSLT. Unfortunately, I have only a rudimentary knowledge here. But I will try.

     
    • Thomas Schraitle

      Hi Martin,

      if you need some help about writing customizing layers, maybe this link is useful for you:
      http://doccookbook.sourceforge.net/html/en/dbc.common.dbcustomize.html

      Hope it helps,
      Tom

       
  • Martin Köditz

    Martin Köditz - 2016-06-11

    Well, I've read some tutorials and examples. But there are always set constant image paths in XSL. I just want to use the images set in my cover section.

    For example I have the following DocBook sources:

    <book xml:lang="de" xml:id="candidatemanagement-de" version="0.0.6" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook">
        <title>Bewerberverwaltung</title>
        <titleabbrev>Bewerberverwaltung</titleabbrev>
        <subtitle>Anwenderhandbuch</subtitle>
        <info>
            <author>
                <personname>
                  <firstname>Martin</firstname>
                  <surname>Köditz</surname>
                </personname>
            </author>
            <cover>
                <mediaobject>
                    <imageobject xml:id="candidate-management-cover">
                        <imagedata fileref="candidatemanagement-cover.jpg">
                        </imagedata>
                    </imageobject>
                </mediaobject>
            </cover>
    
            <releaseinfo>0.0.6</releaseinfo>
            <releaseinfo>Revision: 0</releaseinfo>
            <releaseinfo>Build Date: <?dbtimestamp format="B d, Y"?></releaseinfo>
        </info>
        [...]
    

    In book.titlepage.template.xsl I have modified the cover section:

     <!-- Cover -->
      <fo:block-container top="{(2 - &goldenratio;) * $height}{$unit}" left="0" absolute-position="fixed">
        <fo:block>
            <fo:external-graphic>
            <!-- That doesn't work -->
             <xsl:attribute name="fileref">url(<xsl:value-of select="ancestor-or-self::d:book/d:info/d:cover/d:mediaobject/d:imageobject"/>)</xsl:attribute>
            </fo:external-graphic>
            <!-- 
                This is OK!
                <fo:external-graphic src="url('/srv/www/htdocs/docbook/images/src/jpg/candidatemanagement-cover.jpg')" width="100%" content-width="scale-to-fit"/>
            --> 
        </fo:block>
      </fo:block-container>
    

    My problem is that I don't know how to get the value of the fileref attribute of imagedata. Would be great if someone can show me the correct direction.

    Regards
    Martin

     
  • Stefan Knorr

    Stefan Knorr - 2016-06-14

    Hi Martin,

    from DAPS, you should get a parameter called img.src.path. So you should be able to use concat($img.src.path,ancestor-or-self::d:book/...snip.../d:imageobject) in your value-of.

    Also see, in the DAPS repo, make/pdf.mk, lines 70 + 74.

     

    Last edit: Stefan Knorr 2016-06-14
  • Martin Köditz

    Martin Köditz - 2016-06-17

    Thank you Stefan.

     
  • Stefan Quandt

    Stefan Quandt - 2016-09-07

    I was struggling with the correct syntax a lot, hence here's a simple and working example (without positioning by a <block-container> and hard coded image file name):

    <fo:block>
        <fo:external-graphic
            src="{concat($img.src.path, 'my-company-logo.png')}"
            width="100%" content-width="scale-to-fit"/>
    </fo:block>
    
     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.