0

I have an org document which I export to several different formats:

  • Markdown
  • PDF
  • HTML
  • ODT

I need to include an image (the logo of the company) in the cover front page, before OR after the title of the document in all the exported formats, especially in the ODT since the readers could be people with MS Word.

My directory tree is something like this:

├── Document.org
├── Document.odt
├── Document.md
├── Document.pdf
├── Document.html
├── images
│   ├── logo.png
│   ├── image1.png
│   ├── image2.png

The current command I include (which is not working) is:

#+title: @@odt:<draw:image xlink:href="./images/logo.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>@@ [Projec Name] A title here

Te title is shown, but not the image.

I need the solution for ODT exported files, not only PDF or md.

Extra question: Is there a way to include a small header image to all pages, or a water mark image in all pages?

6
  • I think this is more a question of how to do these things in the exported format. Org mode allows you to specify style files for each exporter (e.g. with #+LATEX_HEADER: for the LaTeX/PDF exporter, with #+ODT_STYLES_FILE: for the ODT exporter and with #+HTML_HEAD: and/or #+HTML_HEAD_EXTRA: for HTML export). But the contents of those style files are specific to the export format and thus outside the purview of this site.
    – NickD
    Nov 13, 2020 at 15:38
  • But what is the syntax of those files or values? I've not found any example with #+ODT_STYLES_FILE Nov 16, 2020 at 18:09
  • It's in the manual.
    – NickD
    Nov 16, 2020 at 18:18
  • @NickD no, it's not there, which parameter is supposed to be used in the style? Or where is going to be the image included? In the first page? In all pages? In second page? I came for an answer because in the manual I didn't find the info. Dec 14, 2020 at 9:25
  • As I said in my first comment, this is a question about ODF. The link shows you how to generate a style file, but modifying it to do what you want is NOT an Org mode matter or Emacs matter: it is an Open Office matter, and you need to ask your question on a forum that addresses that. In particular, I don't know how to do what you want (or else I would have answered the question) and the fact that nobody has come along to answer it shows you, I think, that you are asking the question in the wrong forum.
    – NickD
    Dec 14, 2020 at 13:25

2 Answers 2

1

Is there a way to include a small header image to all pages,

Yes.

How to create a ODT document with a Logo and/or Custom Text in all pages

You need to use the the enhanced ODT exporter ox-odt-9.5.3.456.tar or later (or simply, any version whose date is later than this comment's date).

The enhanced ODT backend is not available with standard Emacs or Org mode, and you need to install it separately. See Getting Started with ODT export (OpenDocument Text Exporter for Emacs’ Org Mode for instructions.

The snippet is fairly sophisticated set of ox-odt and Org Babel features as highlighted in the image below ... So, even if one of the highlighted features aren't enabled, you wouldn't get an output as show below.

Summary of ox-odt features used

See List of features that are exclusive to The Enhanced OpenDocument Exporter for Org mode for more information.

If you need this

content.odt with custom page header and footer

Same content.odt but with LibreOffice decorations like Field Shadings

do this

Create a header.odt like so

Overview of header.odt

#+begin_src emacs-lisp :exports results :results silent
(add-to-list 'org-odt-experimental-features 'transclude-sole-footnote-references-in-a-table)
#+end_src

#+ATTR_ODT: :col-cookies "| m1 | rm10 |"
| [fn:1] |     {{{ODTTitle}}} |

----------------

[fn:1]

#+ATTR_ODT: :height 1.5
[[./org-mode-unicorn.png]]

Create a content.odt like so .... note that header.odt gets transcluded in to content.odt using a LibreOffice Basic macro

#+TITLE: Generate ODT docs with a Page Header and Footer

# #+odt_preferred_output_format: pdf

#+begin_src emacs-lisp :exports results :results silent
(add-to-list 'org-odt-experimental-features 'transclude-sole-footnote-references-in-a-table)
#+end_src

#+begin_src emacs-lisp :exports results :results silent
(custom-set-variables
  '(org-odt-transform-processes
   '(("Update All and Break Links" "soffice" "--norestore" "--invisible" "--headless" "macro:///OrgMode.Utilities.UpdateAll(%I, 1)"))))
#+end_src

#+name: headertext/org
#+begin_src org :noweb yes :exports none
,#+ATTR_ODT: :transclude t
[[./header.odt]]
#+end_src

#+name: headertext/org/nxml
#+begin_src emacs-lisp :exports none :var name="headertext/org"
(org-odt-export-string-as-odt-string
 (org-babel-expand-noweb-references
  (org-babel-goto-named-src-block name)))
#+end_src

#+name: footertext/org
#+begin_src org :noweb yes :exports none
,#+ATTR_ODT: :style "Footer"
{{{ODTTab}}}{{{ODTPageNumber}}} of {{{ODTPageCount}}}
#+end_src

#+name: footertext/org/nxml
#+begin_src emacs-lisp :exports none :var name="footertext/org"
(org-odt-export-string-as-odt-string
 (org-babel-expand-noweb-references
  (org-babel-goto-named-src-block name)))
#+end_src

#+ATTR_ODT: :target "master_styles"
#+begin_src nxml :noweb yes
<style:master-page style:name="Standard"
                   style:page-layout-name="Mpm1">
  <style:header>
    <<headertext/org/nxml()>>
  </style:header>
  <style:footer>
    <<footertext/org/nxml()>>
  </style:footer>
</style:master-page>
#+end_src

* First Chapter

Anim ullamco enim cillum ea sint sunt qui id nostrud cupidatat
cupidatat irure sed velit veniam, ex.  Reprehenderit dolor ut ea
laborum aliquip in enim elit, irure quis eu nulla.  Proident, velit id
proident, consectetur adipiscing minim aliqua fugiat incididunt quis
ut dolor minim officia.  Deserunt exercitation magna voluptate ea quis
amet, est laboris reprehenderit laborum pariatur est velit ullamco
tempor id commodo sit culpa tempor.  Sint culpa cupidatat ut qui elit,
ea veniam, adipiscing nostrud exercitation non pariatur aliquip
eiusmod incididunt cupidatat tempor pariatur tempor.

* Second Chapter
:PROPERTIES:
:ATTR_ODT: :page-break t
:END:

Non exercitation qui esse occaecat ex excepteur duis officia
adipiscing do.  Cupidatat aute qui incididunt cillum elit, magna
laborum ex minim ut consequat culpa deserunt ipsum eu aute eu.  Eu ex
pariatur nisi duis sit adipiscing lorem ex laborum irure sit laboris
amet, consectetur tempor eiusmod exercitation ex nulla aute commodo
dolor nostrud mollit.

* Third Chapter
:PROPERTIES:
:ATTR_ODT: :page-break t
:END:

Minim est tempor nulla dolore magna anim amet, nostrud.  Sed tempor ad
sunt ad fugiat voluptate qui nisi ea ullamco.  Nulla incididunt enim
excepteur reprehenderit consequat duis excepteur voluptate enim fugiat
irure.  Cupidatat pariatur ut tempor commodo non sit ex adipiscing
anim qui magna incididunt mollit ea ut ut eu laboris commodo do sint.
In magna quis veniam, sunt magna dolor esse do eu ad velit est mollit
anim eiusmod fugiat.  Labore non anim nisi cupidatat officia eiusmod
enim qui ad do laborum dolor cupidatat laborum nostrud minim.

0

I need to include an image (the logo of the company) in the cover front page, before OR after the title of the document in ODT

How to create a ODT document with a Cover/Title page

Before proceeding ahead with the suggestions here, ensure that your set up is using the enhanced ODT exporter. See https://emacs.stackexchange.com/a/71798/31220 for the details.

To get this

LibreOffice document with a coverpage

do this

coverpage.org as seen within Emacs

#+options: title:nil toc:nil author:nil date:nil

#+title: How to create LibreOffice Documents with a Title Page

# #+odt_preferred_output_format: docx

#+ATTR_ODT: :target "extra_styles"
#+begin_src nxml
<style:style style:name="CompanyLogo"
             style:parent-style-name="Standard"
             style:family="paragraph"
             style:class="text"
             style:master-page-name="OrgTitlePage">
  <style:paragraph-properties fo:margin-bottom="0.212cm"
                              fo:margin-top="5.001cm"
                              fo:text-align="center"
                              style:contextual-spacing="false"
                              style:justify-single-word="false"
                              style:page-number="auto" />
</style:style>
#+end_src

#+ATTR_ODT: :height 10 :image "images/org-mode-unicorn.png"
#+ATTR_ODT: :p-style "CompanyLogo"
#+begin_customshape
# Nothing here
#+end_customshape

#+ATTR_ODT: :style "OrgTitle"
#+begin_title
[[https://Orgmode.org][Emacs Org Mode]]

/Your life in plain text/
#+end_title

#+ATTR_ODT: :page-style "OrgFirstPage" :page-number 1
Aliqua fugiat nulla do officia lorem veniam, qui laboris sint sed
fugiat labore dolor duis amet, in id enim fugiat tempor ea excepteur
minim exercitation.  Eiusmod minim ad quis et exercitation aliqua
veniam, officia aliqua veniam, sed tempor et nulla magna sit magna
consectetur ad occaecat eu.

* First Chapter
:PROPERTIES:
:ATTR_ODT: :page-style "OrgFirstPage" :page-number 1
:END:

Aliqua amet, irure consectetur ut magna non enim proident, ut labore
ipsum et cupidatat reprehenderit culpa elit, magna deserunt nulla
commodo culpa.  Sit culpa mollit dolore laboris deserunt ut labore
minim fugiat aliquip nulla cillum consequat nostrud lorem deserunt
elit, sed voluptate.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.