How to show <othermeta> in PDF transformations?

Having trouble installing Oxygen? Got a bug to report? Post it all here.
dbutch
Posts: 41
Joined: Wed Aug 14, 2019 9:16 am

How to show <othermeta> in PDF transformations?

Post by dbutch »

Hi,
We record information about our documents in <bookmeta>. I would like to use this data, including <othermeta>, in the PDF both as metadata and (for some tags) in the headers/footers.
I've had some success getting some of the values through to the PDF, however the <othermeta> does not carry through to the PDF in any form.
The <bookmeta> includes:

Code: Select all

<bookmeta class="- map/topicmeta bookmap/bookmeta ">
        <author>D. Duck</author>
        <keywords>
            <keyword>My department</keyword>
        </keywords>
        <othermeta name="Document ID" content="DB03-COUNTDOWN" class="- topic/othermeta "/>
        <othermeta name="Current revision" content="2.1"/>
Our PDF Chemistry CSS contains the following, which is supposed to dump all meta tags as custom meta fields in the PDF:

Code: Select all

meta {
    -oxy-pdf-meta-custom: attr(name) attr(content);
}

This passes some of the meta tags through to the PDF custom metadata(e.g. Author), however the names do not match the <othermeta> tag names. The tag names showing are matching those in the merged.html file Author view but not what is showing in the Text view.

PDF custom properties.png
PDF custom properties.png (6.45 KiB) Viewed 2967 times
merged_html.png
merged_html.png (4.89 KiB) Viewed 2967 times

Any ideas why the <othermeta> tag names are not mapping through?

I am very keen to use the Document ID in the document footer - what is the correct Chemistry CSS to pull specific <othermeta> tags like the Document ID through into the PDF document?

Thanks!
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: How to show <othermeta> in PDF transformations?

Post by Dan »

We will try to find a way to pass the meta information from the merged map to the merged HTML, so you can use it further in the CSS customization.

As a workaround, you can use the oxy_xpath function run over the original map file. You can extract any element value or attribute from the original processed DITA map file. For this use the xtrf attribute that is set on the root element of the merged map. This attribute contains the URL of the input map. For example:

Code: Select all

:root{
     -oxy-pdf-meta-custom: "Document ID" oxy_xpath("document(@xtrf)//othermeta[@name='Document ID']/@content");
}
Many regards,
Dan
dbutch
Posts: 41
Joined: Wed Aug 14, 2019 9:16 am

Re: How to show <othermeta> in PDF transformations?

Post by dbutch »

Thanks for looking into this Dan.

Please bear with my relative lack of experience, but with your workaround example, what should the outcome be?
I have tried implementing it as-is, however there has been no effect at present. Please let me know if it should it be used alongside other CSS and if it is possible to use the outcome and present the text in the footer?

Thanks,
Duncan
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: How to show <othermeta> in PDF transformations?

Post by Dan »

Hello Duncan,

I corrected the quotes in the example above, it should work now...

The XPath is a powerful way to extract content from an XML document. You can use it in CSS to collect metadata, do calculus, etc..
In the example above, the document function parses the original DITA Map (referred by the @xtrf attribute), then searches all the 'othertmeta' elements that have the attribute name set to the 'Document ID' text, and uses the value of the @content attribute.

Many regards,
Dan
dbutch
Posts: 41
Joined: Wed Aug 14, 2019 9:16 am

Re: How to show <othermeta> in PDF transformations?

Post by dbutch »

Hi Dan,

Thanks for the update.
Implementing your CSS, should I be seeing the Document ID othermeta in the document properties? Currently it is not showing in the PDF custom properties or elsewhere.
I also tried to present the text in the footer using the following CSS, to no avail:

Code: Select all

@page :left:right, chapter:first:left:right  {
    @bottom-center {
        content: "Document ID" oxy_xpath("document(@xtrf)//othermeta[@name='Document ID']/@content")
Appreciate your support.

Duncan
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: How to show <othermeta> in PDF transformations?

Post by Dan »

Hello Duncan,

I run a test and I changed the XPath expression. You are using the HTML5 based transformation and in this case the othermeta is changed to a div having the topic/othermeta - the example above works for the direct transformation. Here is the updated version:

Code: Select all

@page :left:right, chapter:first:left:right  {
    @bottom-center {
        content: "Document ID" oxy_xpath("(//*[contains(@class, 'topic/othermeta')][@name='Document ID'])[1]/@content");
    }
}
For more information regarding using XPath expressions, see our userguide:
https://www.oxygenxml.com/doc/versions/ ... index.html
https://www.oxygenxml.com/doc/versions/ ... aid-title3

Let us know if you need more help,
Many regards,
Dan
dbutch
Posts: 41
Joined: Wed Aug 14, 2019 9:16 am

Re: How to show <othermeta> in PDF transformations?

Post by dbutch »

Hi Dan,

Thank you very much - that works now and is showing in the footer.

Please let me know if you find a method of passing the othermeta information through into the PDF properties (and merged HTML).

Kind regards,
Duncan
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: How to show <othermeta> in PDF transformations?

Post by Dan »

To forward all the othermeta elements information to the document properties, you can use a this CSS rule:

Code: Select all

*[class ~= "topic/othermeta"][name] {
 		-oxy-pdf-meta-custom: attr(name) attr(content);
}
Many regards,
Dan
dbutch
Posts: 41
Joined: Wed Aug 14, 2019 9:16 am

Re: How to show <othermeta> in PDF transformations?

Post by dbutch »

Thanks very much Dan, that works - all othermeta is now showing with the correct name and content in the PDF custom properties window.

Thanks for your support.
Post Reply