Running Header for PDF

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Running Header for PDF

karfunkel
Hi everyone,

I am a bit confused as I am trying to create a running header and footer.
I am using asciidoctorj with a gradle build.

This is the gradle build file:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.2'
        classpath 'com.github.jruby-gradle:jruby-gradle-plugin:0.1.5'
        classpath 'org.ysb33r.gradle:vfs-gradle-plugin:1.0-beta1'
        classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.8'
        classpath 'com.github.ben-manes:gradle-versions-plugin:0.8'
        classpath 'com.bluepapa32:gradle-watch-plugin:0.1.5'
    }
}

apply plugin: 'com.github.jruby-gradle.base'
apply plugin: 'org.ysb33r.vfs'
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'com.bluepapa32.watch'

group = 'de.huk.jenkins.handbook'
version = '1.0.0-SNAPSHOT'

repositories {
    jcenter()
}

dependencies {
    gems 'rubygems:asciidoctor-diagram:1.3.0.preview.4'
    gems 'rubygems:slim:2.1.0'
    gems 'rubygems:thread_safe:0.3.4'
}

asciidoctor {
    options doctype: 'book'

    backends = ['html5', 'pdf']

    dependsOn jrubyPrepareGems
    gemPath = jrubyPrepareGems.outputDir
    requires = ['asciidoctor-diagram']

    attributes 'source-highlighter': 'coderay',
            'coderay-linenums-mode': 'table',
            'imagesdir': './images',
            toc: 'left',
            icon: 'font',
            linkattrs: true,
            encoding: 'utf-8',
            now: new Date().format('dd.MM.yyyy'),
            'pdf-stylesdir': './theme',
            'pdf-fontsdir': './fonts',
            'pdf-style': 'huk'

    sources {
        include 'Betriebshandbuch.adoc'
        include 'Nutzerhandbuch.adoc'
        include 'Folder.adoc'
        include 'Plugins.adoc'
        include 'Tools.adoc'
    }

    resources {
        from(sourceDir) {
            include 'images/**'
        }
    }
}

watch {
    asciidoc {
        files fileTree(dir: 'src/docs/asciidoc', include: '**/*.adoc')
        tasks 'asciidoctor'
    }
}

The used theme file is the default one modified for the header and footer areas like this:

footer:
  font_size: $base_font_size_small
  font_color: $base_font_color
  border_color: dddddd
  border_width: 0.25
  height: $base_line_height_length * 2.5
  padding: [$base_line_height_length / 2, 1, 0, 1]
  valign: top
  recto_content:
    right: '{page-number}'
  verso_content:
    left: '{page-number}'
header:
  font_size: $base_font_size_small
  font_color: $base_font_color
  border_color: dddddd
  border_width: 0.25
  border_style: solid
  height: $base_line_height_length * 2.5 * 4
  padding: [$base_line_height_length / 2, 1, 0, 1]
  valign: top
  recto_content:
    right: 'Seite {page-number} | Stand {now} | | {document-title}'
  verso_content:
    right: 'Seite {page-number} | Stand {now} | | {document-title}'

But when I create the document I neither see a header nor a footer - even with the default I should have a footer with page numbers as far as I understood.

What am I doing wrong?

Thanks in advance,
Sascha
Reply | Threaded
Open this post in threaded view
|

Re: Running Header for PDF

mojavelinux
Administrator
At the moment, you need to set the pagenums attribute on the document for the running header/footer to be added. This is related to https://github.com/asciidoctor/asciidoctor-pdf/issues/205

Cheers,

-Dan

On Thu, Jul 16, 2015 at 9:03 AM, karfunkel [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi everyone,

I am a bit confused as I am trying to create a running header and footer.
I am using asciidoctorj with a gradle build.

This is the gradle build file:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.2'
        classpath 'com.github.jruby-gradle:jruby-gradle-plugin:0.1.5'
        classpath 'org.ysb33r.gradle:vfs-gradle-plugin:1.0-beta1'
        classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.8'
        classpath 'com.github.ben-manes:gradle-versions-plugin:0.8'
        classpath 'com.bluepapa32:gradle-watch-plugin:0.1.5'
    }
}

apply plugin: 'com.github.jruby-gradle.base'
apply plugin: 'org.ysb33r.vfs'
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'com.bluepapa32.watch'

group = 'de.huk.jenkins.handbook'
version = '1.0.0-SNAPSHOT'

repositories {
    jcenter()
}

dependencies {
    gems 'rubygems:asciidoctor-diagram:1.3.0.preview.4'
    gems 'rubygems:slim:2.1.0'
    gems 'rubygems:thread_safe:0.3.4'
}

asciidoctor {
    options doctype: 'book'

    backends = ['html5', 'pdf']

    dependsOn jrubyPrepareGems
    gemPath = jrubyPrepareGems.outputDir
    requires = ['asciidoctor-diagram']

    attributes 'source-highlighter': 'coderay',
            'coderay-linenums-mode': 'table',
            'imagesdir': './images',
            toc: 'left',
            icon: 'font',
            linkattrs: true,
            encoding: 'utf-8',
            now: new Date().format('dd.MM.yyyy'),
            'pdf-stylesdir': './theme',
            'pdf-fontsdir': './fonts',
            'pdf-style': 'huk'

    sources {
        include 'Betriebshandbuch.adoc'
        include 'Nutzerhandbuch.adoc'
        include 'Folder.adoc'
        include 'Plugins.adoc'
        include 'Tools.adoc'
    }

    resources {
        from(sourceDir) {
            include 'images/**'
        }
    }
}

watch {
    asciidoc {
        files fileTree(dir: 'src/docs/asciidoc', include: '**/*.adoc')
        tasks 'asciidoctor'
    }
}

The used theme file is the default one modified for the header and footer areas like this:

footer:
  font_size: $base_font_size_small
  font_color: $base_font_color
  border_color: dddddd
  border_width: 0.25
  height: $base_line_height_length * 2.5
  padding: [$base_line_height_length / 2, 1, 0, 1]
  valign: top
  recto_content:
    right: '{page-number}'
  verso_content:
    left: '{page-number}'
header:
  font_size: $base_font_size_small
  font_color: $base_font_color
  border_color: dddddd
  border_width: 0.25
  border_style: solid
  height: $base_line_height_length * 2.5 * 4
  padding: [$base_line_height_length / 2, 1, 0, 1]
  valign: top
  recto_content:
    right: 'Seite {page-number} | Stand {now} | | {document-title}'
  verso_content:
    right: 'Seite {page-number} | Stand {now} | | {document-title}'

But when I create the document I neither see a header nor a footer - even with the default I should have a footer with page numbers as far as I understood.

What am I doing wrong?

Thanks in advance,
Sascha


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Running-Header-for-PDF-tp3505.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Running Header for PDF

karfunkel
Thanks, this seems to start the processing, but now I get the following Exception:

Caused by: org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `each' for nil:NilClass
        at RUBY.layout_running_content(/home/aklein/.gradle/caches/modules-2/files-2.1/org.asciidoctor/asciidoctorj-pdf/1.5.0-alpha.8/11e67dcf97c8071a5cc5df34ac10e0978adc25e/asciidoctorj-pdf-1.5.0-alpha.8.jar!/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:1703)
        at RUBY.convert_document(/home/aklein/.gradle/caches/modules-2/files-2.1/org.asciidoctor/asciidoctorj-pdf/1.5.0-alpha.8/11e67dcf97c8071a5cc5df34ac10e0978adc25e/asciidoctorj-pdf-1.5.0-alpha.8.jar!/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:159)
        at RUBY.convert(/home/aklein/.gradle/caches/modules-2/files-2.1/org.asciidoctor/asciidoctorj-pdf/1.5.0-alpha.8/11e67dcf97c8071a5cc5df34ac10e0978adc25e/asciidoctorj-pdf-1.5.0-alpha.8.jar!/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:88)
        at RUBY.convert(/home/aklein/IdeaProjects/HUK/huk-jenkins-handbook/build/vendor/gems/asciidoctor-1.5.2/lib/asciidoctor/document.rb:1028)
        at RUBY.convert(/home/aklein/IdeaProjects/HUK/huk-jenkins-handbook/build/vendor/gems/asciidoctor-1.5.2/lib/asciidoctor.rb:1499)
        at RUBY.convert_file(/home/aklein/IdeaProjects/HUK/huk-jenkins-handbook/build/vendor/gems/asciidoctor-1.5.2/lib/asciidoctor.rb:1562)
        at RUBY.convertFile(<script>:68)
        at org.jruby.gen.InterfaceImpl1294899968.convertFile(org/jruby/gen/InterfaceImpl1294899968.gen:13)
        at org.asciidoctor.gradle.AsciidoctorProxyImpl.renderFile(AsciidoctorProxyImpl.groovy:26)
        at org.asciidoctor.gradle.AsciidoctorTask.processSingleFile(AsciidoctorTask.groovy:672)
        at org.asciidoctor.gradle.AsciidoctorTask$_processDocumentsAndResources_closure7.doCall(AsciidoctorTask.groovy:652)
        at org.asciidoctor.gradle.AsciidoctorTask.processDocumentsAndResources(AsciidoctorTask.groovy:647)
        at org.asciidoctor.gradle.AsciidoctorTask.processAsciidocSources(AsciidoctorTask.groovy:592)

Any ideas?
Thanks

Sascha
 
Reply | Threaded
Open this post in threaded view
|

Re: Running Header for PDF

mojavelinux
Administrator

Can you post the header: and/or footer: keys from your theme. You may either be missing a required setting or have an illegal value. The theme file is not yet validated (we first need to complete the validation rules).

-Dan

Le 21 juil. 2015 12:48 AM, "karfunkel [via Asciidoctor :: Discussion]" <[hidden email]> a écrit :
Thanks, this seems to start the processing, but now I get the following Exception:

Caused by: org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `each' for nil:NilClass
        at RUBY.layout_running_content(/home/aklein/.gradle/caches/modules-2/files-2.1/org.asciidoctor/asciidoctorj-pdf/1.5.0-alpha.8/11e67dcf97c8071a5cc5df34ac10e0978adc25e/asciidoctorj-pdf-1.5.0-alpha.8.jar!/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:1703)
        at RUBY.convert_document(/home/aklein/.gradle/caches/modules-2/files-2.1/org.asciidoctor/asciidoctorj-pdf/1.5.0-alpha.8/11e67dcf97c8071a5cc5df34ac10e0978adc25e/asciidoctorj-pdf-1.5.0-alpha.8.jar!/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:159)
        at RUBY.convert(/home/aklein/.gradle/caches/modules-2/files-2.1/org.asciidoctor/asciidoctorj-pdf/1.5.0-alpha.8/11e67dcf97c8071a5cc5df34ac10e0978adc25e/asciidoctorj-pdf-1.5.0-alpha.8.jar!/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:88)
        at RUBY.convert(/home/aklein/IdeaProjects/HUK/huk-jenkins-handbook/build/vendor/gems/asciidoctor-1.5.2/lib/asciidoctor/document.rb:1028)
        at RUBY.convert(/home/aklein/IdeaProjects/HUK/huk-jenkins-handbook/build/vendor/gems/asciidoctor-1.5.2/lib/asciidoctor.rb:1499)
        at RUBY.convert_file(/home/aklein/IdeaProjects/HUK/huk-jenkins-handbook/build/vendor/gems/asciidoctor-1.5.2/lib/asciidoctor.rb:1562)
        at RUBY.convertFile(<script>:68)
        at org.jruby.gen.InterfaceImpl1294899968.convertFile(org/jruby/gen/InterfaceImpl1294899968.gen:13)
        at org.asciidoctor.gradle.AsciidoctorProxyImpl.renderFile(AsciidoctorProxyImpl.groovy:26)
        at org.asciidoctor.gradle.AsciidoctorTask.processSingleFile(AsciidoctorTask.groovy:672)
        at org.asciidoctor.gradle.AsciidoctorTask$_processDocumentsAndResources_closure7.doCall(AsciidoctorTask.groovy:652)
        at org.asciidoctor.gradle.AsciidoctorTask.processDocumentsAndResources(AsciidoctorTask.groovy:647)
        at org.asciidoctor.gradle.AsciidoctorTask.processAsciidocSources(AsciidoctorTask.groovy:592)

Any ideas?
Thanks

Sascha
 


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Running-Header-for-PDF-tp3505p3530.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Running Header for PDF

karfunkel
Here it is:

footer:
  font_size: $base_font_size_small
  font_color: $base_font_color
  # NOTE if background_color is set, background and border will span width of page
  border_color: dddddd
  border_width: 0.25
  height: $base_line_height_length * 2.5
  padding: [$base_line_height_length / 2, 1, 0, 1]
  valign: top
  #image_valign: <alignment> or <number>
  # additional attributes for content:
  # * {page-count}
  # * {page-number}
  # * {document-title}
  # * {document-subtitle}
  # * {chapter-title}
  # * {section-title}
  # * {section-or-chapter-title}
  recto_content:
    #right: '{section-or-chapter-title} | {page-number}'
    #right: '{document-title} | {page-number}'
    right: '{page-number}'
    #center: '{page-number}'
  verso_content:
    #left: '{page-number} | {chapter-title}'
    left: '{page-number}'
    #center: '{page-number}'
header:
  font_size: $base_font_size_small
  font_color: $base_font_color
  # NOTE if background_color is set, background and border will span width of page
  border_color: dddddd
  border_width: 0.25
  border_style: solid
  height: $base_line_height_length * 2.5 * 4
  padding: [$base_line_height_length / 2, 1, 0, 1]
  valign: top
  recto_content:
    right: 'Seite {page-number} | {document-title}'
    #right: 'Seite {page-number} | Stand {now} | {document-title}'
  verso_content:
    right: 'Seite {page-number} | {document-title}'
    #right: 'Seite {page-number} | Stand {now} | {document-title}'

Sascha
Reply | Threaded
Open this post in threaded view
|

Re: Running Header for PDF

mojavelinux
Administrator
Aha! You are hitting the following issue.


This is fixed in the upcoming 1.5.0 alpha 9 release. The quick fix is to add at least one section to your document.

Cheers,

-Dan

On Tue, Jul 21, 2015 at 12:51 AM, karfunkel [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Here it is:

footer:
  font_size: $base_font_size_small
  font_color: $base_font_color
  # NOTE if background_color is set, background and border will span width of page
  border_color: dddddd
  border_width: 0.25
  height: $base_line_height_length * 2.5
  padding: [$base_line_height_length / 2, 1, 0, 1]
  valign: top
  #image_valign: <alignment> or <number>
  # additional attributes for content:
  # * {page-count}
  # * {page-number}
  # * {document-title}
  # * {document-subtitle}
  # * {chapter-title}
  # * {section-title}
  # * {section-or-chapter-title}
  recto_content:
    #right: '{section-or-chapter-title} | {page-number}'
    #right: '{document-title} | {page-number}'
    right: '{page-number}'
    #center: '{page-number}'
  verso_content:
    #left: '{page-number} | {chapter-title}'
    left: '{page-number}'
    #center: '{page-number}'
header:
  font_size: $base_font_size_small
  font_color: $base_font_color
  # NOTE if background_color is set, background and border will span width of page
  border_color: dddddd
  border_width: 0.25
  border_style: solid
  height: $base_line_height_length * 2.5 * 4
  padding: [$base_line_height_length / 2, 1, 0, 1]
  valign: top
  recto_content:
    right: 'Seite {page-number} | {document-title}'
    #right: 'Seite {page-number} | Stand {now} | {document-title}'
  verso_content:
    right: 'Seite {page-number} | {document-title}'
    #right: 'Seite {page-number} | Stand {now} | {document-title}'

Sascha


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Running-Header-for-PDF-tp3505p3532.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Running Header for PDF

karfunkel
Thanks  a lot, now it works.

Just one question: How to put line breaks into a header or footer?
I'l like to have something like
recto_content_right: 'Seite {page-number} | Stand {now} | {document-title}'
and need to have linebreaks instead of pipes.

Thanks
Sascha
Reply | Threaded
Open this post in threaded view
|

Re: Running Header for PDF

mojavelinux
Administrator
See the explanation in this section:


However, that behavior depends on the upcoming 1.5.0.alpha.9 release.

-Dan

On Tue, Jul 21, 2015 at 5:35 AM, karfunkel [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Thanks  a lot, now it works.

Just one question: How to put line breaks into a header or footer?
I'l like to have something like
recto_content_right: 'Seite {page-number} | Stand {now} | {document-title}'
and need to have linebreaks instead of pipes.

Thanks
Sascha


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Running-Header-for-PDF-tp3505p3534.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Running Header for PDF

karfunkel
Thanks a lot.

When do you expect alpha 9 to be released?

Cheers,
Sascha
Reply | Threaded
Open this post in threaded view
|

Re: Running Header for PDF

mojavelinux
Administrator
Sascha,

I'm trying to get it out later this week. I've identified the issues remaining to get the release out. Now, I just need to crank away at them.


Cheers,

-Dan

On Wed, Jul 22, 2015 at 1:08 AM, karfunkel [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Thanks a lot.

When do you expect alpha 9 to be released?

Cheers,
Sascha


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Running-Header-for-PDF-tp3505p3540.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Running Header for PDF

wolandscat
In reply to this post by karfunkel
+1 for that feature.