Adding Document Control to title page

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

Adding Document Control to title page

DaveE
Hi All,

I need to add a document control section to the front page of a mass of asciidoctor files:

Document Title:
Document Owner:
Version:
Approved by:
Date Approved
Next Review:
Classification:

I've read around about modifying the ruby to do something similar but is it possible via another route?

The end result will always be pdf, I've considered running shell script to generate this table after processing of the adoc file and then inserting it into the resulting pdf, however I would need to scrape the names from the adoc and get the values from the environment which seems like a lot of work.

Is there a better way so I don't reinvent another wheel?

Thanks
DaveE

Reply | Threaded
Open this post in threaded view
|

Re: Adding Document Control to title page

metro
I use the following process:

* put information like this in a separate adoc variables file
* include variable file in the master document
* generate docbook5
* generate .fo file using modified stylesheet and passing the adoc variables on the command line to xslt processor
* generate .pdf from .fo

MT
--

memo_variables.adoc:
:memoTo: John Doe

Part of modified docbook.xsl:
  <xsl:param name="memoTo"/>
...
         <fo:table-cell xsl:use-attribute-sets="titlepageTable">
            <fo:block xsl:use-attribute-sets="article.titlepage.recto.style">
              <xsl:value-of select="$memoTo"/>
            </fo:block>
          </fo:table-cell>
Reply | Threaded
Open this post in threaded view
|

Re: Adding Document Control to title page

DaveE
Ok that's an idea, similar to patching in a new front page using a script and ps etc
I tried to doing away with the title page and then using attributes in to a table, that didn't work.

I think it would a useful extension so I'm looking to modify or extend the converter, I'm not into ruby so it's a learning experience.

Reply | Threaded
Open this post in threaded view
|

Re: Adding Document Control to title page

rockyallen
Metro's route assumes you are using Docbook, but it sounds like you want to do it through asciidoctor-pdf.

For docbook all you need is the docinfo.xml file and a bit of xsl:

1. Create a docinfo.xml file. Asciidoctor automatically replaces attribute references like {author} in the docinfo file from your .adoc file.
2. Create a stylesheet with a modified title-page template that displays the data from the docinfo. This becomes a standard template that you can use for all documents.
3. Create a customisation layer that imports the docbook fo stylesheet, then imports your custom title page template, then has xsl:params for any metadata that you can't pack into the docinfo element (manager, approver etc).
4. Generate your document from your customisation layer.

This has the disadvantage that your metadata is spread over 2 files (attributes in master.adoc and xsl:param in the customisation layer), but you only type it once, and you don't need any programming.

For asciidoctor-pdf I don't know an easy way. One thing I haven't tried but might work is to create an SVG that contains the table data, then tell asciidoctor to use that file as a background image for the title page. You might need to play with the yml to move the title up the page enough to clear space for your table. For a one off you could handcraft the SVG (the SVG file format is trivial), or for many documents you could make a template for it.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Document Control to title page

DaveE
I didn't really want to deviate from asciidoctor as I'm invested, Ideally I want to pull some of the attributes out of the header of adoc file and others would be passed in.

Using an svg or I guess any supported image format, seems on the face of it is a simpler(quicker) way of resolving my issue quickly.

So in principle knock up an image using SVG for using imagemagick with the attributes scraped from the adoc file and the others as a part of a pre-process, then use the it the as title page background rinse and repeat....

I'd already started working my way through the Ruby so I think extending the title page capabilities is doable, but I'm going to park that for now as time is of the essence and the background image method I'm more confident I can do sooner in a workable way.

Many thanks to you both, if I get anywhere useful I'll post the how so others can use it or not.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Document Control to title page

lorrden
In reply to this post by DaveE
I did something similar with an asciidoctor pdf extension (there is some more info at see https://github.com/asciidoctor/asciidoctor-pdf/issues/337).

Then I overrode the layout_title_page method:

def layout_title_page doc
    super
    canvas do
        bounding_box [50,bounds.top-20], :width => bounds.width - 100, :height => 100 do
            theme_font :header do
                move_cursor_to bounds.top
                layout_prose "Document number: " + (doc.attr 'document-number') +
                             "Document owner: " + (doc.attr 'document-owner'), {margin_bottom: 0, margin_top: 0, normalize: false}
            end
        end
    end
end

The use of canvas enables the placement of stuff in the header and footer area of the title page (margins defined in the theme file), otherwise you end up inside the main body of the title page. If you want it in the main body, you can omit the canvas and just place it in a bounding box directly and it will be relative to the main body of the title page.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Document Control to title page

DaveE
In reply to this post by DaveE
what I ended up doing as speed and flexibility was required.

created an svg with place holders for the fields I wanted tagged by name.

used a script to turn a logo in to base64, and then insert into the svg.

Run sed over a temp copy of the svg replacing the tagged fields with the values extracted from the asciidoc file.

the result is a front page with version/document controls and the company logo. its flexible that the svg can be tweaked with ease without changing the scripts.

my next step is to be able to insert from version control and not from what is fixed in the file.