Issue with automatically generating PDF properties/meta-data
Post here questions and problems related to editing and publishing DITA content.
Issue with automatically generating PDF properties/meta-data
Post by Anonymous1 »
Hi,
when creating PDF, we want to automatically add meta-data to the PDF properties.
I used the xsl:template "createMedadata" in the root-processing_fop.xsl for this. Some things work fine, some don't.
What works so far:
So this works:
Does anybody have an idea how to make the rest work too?
For example, where does the transformation expect the keyword elements to be in the ditamap? I tried them at several locations, for example as topicmeta > metadata > keywords > keyword in the main ditamap.
The authors are located in the topicmeta > author element in the main ditamap.
We are using Oxygen 18.1, custom framework, DITA 2.x, Apache FOP
when creating PDF, we want to automatically add meta-data to the PDF properties.
I used the xsl:template "createMedadata" in the root-processing_fop.xsl for this. Some things work fine, some don't.
What works so far:
- Title of main ditamap is added as the title in the PDF properties
- Language is set according to the xml:lang attribute of the main ditamap
- Creator is the name of my company + the current year
- Keywords are not added to the properties
- The copyright icon (©) makes the build fail, no matter how I insert it (© or © or © or ©, impended in xsl:text or just pasted into the dc:creator element)
- The authors are not added to the properties
Code: Select all
<xsl:template name="createMetadata">
<fo:declarations>
<x:xmpmeta>
<rdf:RDF>
<rdf:Description rdf:about="">
<xsl:variable name="title" as="xs:string?">
<xsl:apply-templates select="." mode="dita-ot:title-metadata"/>
</xsl:variable>
<xsl:if test="exists($title)">
<dc:title>
<xsl:value-of select="$title"/>
</dc:title>
</xsl:if>
<xsl:variable name="author" as="xs:string?">
<xsl:apply-templates select="." mode="dita-ot:author-metadata"/>
</xsl:variable>
<xsl:if test="exists($author)">
<dc:creator>
<xsl:value-of select="$author"/>
</dc:creator>
</xsl:if>
<xsl:variable name="keywords" as="xs:string*">
<xsl:apply-templates select="." mode="dita-ot:keywords-metadata"/>
</xsl:variable>
<xsl:if test="exists($keywords)">
<pdf:Keywords>
<xsl:value-of select="$keywords" separator=", "/>
</pdf:Keywords>
</xsl:if>
<xsl:variable name="subject" as="xs:string?">
<xsl:apply-templates select="." mode="dita-ot:subject-metadata"/>
</xsl:variable>
<xsl:if test="exists($subject)">
<dc:description>
<rdf:Alt>
<rdf:li xml:lang="x-default">
<xsl:value-of select="$subject"/>
</rdf:li>
</rdf:Alt>
</dc:description>
</xsl:if>
<dc:creator>Name of my company <xsl:value-of select="year-from-date(current-date())"/></dc:creator>
<dc:language><xsl:value-of select="/map/@xml:lang"/></dc:language>
<pdf:Keywords></pdf:Keywords>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
</fo:declarations>
</xsl:template>
Code: Select all
<xsl:if test="exists($title)">
<dc:title>
<xsl:value-of select="$title"/>
</dc:title>
</xsl:if>
<dc:creator>Name of my company <xsl:value-of select="year-from-date(current-date())"/></dc:creator>
<dc:language><xsl:value-of select="/map/@xml:lang"/></dc:language>
For example, where does the transformation expect the keyword elements to be in the ditamap? I tried them at several locations, for example as topicmeta > metadata > keywords > keyword in the main ditamap.
The authors are located in the topicmeta > author element in the main ditamap.
We are using Oxygen 18.1, custom framework, DITA 2.x, Apache FOP
-
- Posts: 9515
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Issue with automatically generating PDF properties/meta-data
Hi Ben,
I'm not sure how your DITA Map looks like (how it defines that metadata and so on).
This XSLT stylesheet:
OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT2.x/plugins/org.dita.pdf2/xsl/fo/root-processing.xsl
defines modes both for "dita-ot:keywords-metadata" and for "dita-ot:author-metadata". If you look at their xpaths, they seem to be targeted towards bookmeta so they seem to work only for DITA Bookmaps and not for regular DITA Maps.
Regards,
Radu
I'm not sure how your DITA Map looks like (how it defines that metadata and so on).
This XSLT stylesheet:
OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT2.x/plugins/org.dita.pdf2/xsl/fo/root-processing.xsl
defines modes both for "dita-ot:keywords-metadata" and for "dita-ot:author-metadata". If you look at their xpaths, they seem to be targeted towards bookmeta so they seem to work only for DITA Bookmaps and not for regular DITA Maps.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: Issue with automatically generating PDF properties/meta-data
Post by Anonymous1 »
Thank you for pointing this out. Too bad we are not using bookmaps. I will play around with the code a little bit to see if there are some workaround. At least some of the properties work already.
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service