Page 1 of 1

Controlling size of SVG logo in header

Posted: Wed Aug 22, 2018 4:09 am
by mdslup
The code for my page attribute is below. Basically, it puts a gray bar across the top, with a logo in the top left and document name in the top right, with a page counter on the bottom.

I'm trying to use an SVG for the logo. However, the height attribute does not seem to be applying; the logo comes out huge in the resulting PDF. According to the document page on Graphics: Mixing text and images in the content property disables the width and height specification. Is that what is happening here? I'm not using any text in the @top-left, but I am using a background color. Is that enough to disable the width and height features? If so, how else can I control the width and height of my svg?

@top-left {
content: url('logo.svg') !important;
background-color: #DCDCDC !important;
height: 40px !important;
}

@top-right {
font-family: 'Noto Serif', serif !important;
font-size: smaller !important;
content: string(publication_title) !important;
background-color: #DCDCDC !important;
}

@bottom-right {
font-family: 'Noto Serif', serif !important;
font-size: smaller !important;
content: counter(page) " of " counter(pages) !important;

}

@top-left-corner {
content: "" !important;
background-color: #DCDCDC !important;
}

@top-right-corner {
content: "" !important;
background-color: #DCDCDC !important;
}

Re: Controlling size of SVG logo in header

Posted: Wed Aug 22, 2018 5:02 pm
by Costin
The size of the page margin boxes are computed from the page margin. They must fit in the page margins, so to change the height of the top-left box one has to change the top margin of the page.
In addition, the @top-left, @top-right have dynamic widths. I expect to have problems positioning the content in them.

The best approach for the graphics is to have a SVG with hard-coded dimensions that match the page size and put it as background image on the page.
The technique consists in creating an image (SVG is the best) as wide as the page, that would contain the logo and other decorations placed at the right position. This offers the best results and the position of the artwork does not depend on the page margins.
You can do this for :left and :right pages.

More information on how to use a background image for the cover page is available in the DITA-OT CSS Publishing to PDF Plugin User-Guide and in the Chemistry User-Guide.

Also, make sure your SVG has a size specified, like mm or in and they match the top margin size.

Regards,
Costin

Re: Controlling size of SVG logo in header

Posted: Thu Aug 23, 2018 11:35 pm
by mdslup
Got it, thanks.