PDF export: add date modified

I need the last modified date of a page to be put into the footer of every page when exporting to PDF. How can I achieve this?

Thanks in advance!

Joachim

2 answers

Hi Joachim, currently that is not a feature within the application export, nevertheless some customers did report being able to add so using a bit of CSS styling - posted below, please review the comment from Gerhardt Müller for more info.

We have solved this by creating a simple jsp 'dateimage.jsp' in the confluence root dir, which creates the current date as image, and included a reference in the footer like this:

Print date: <img src="/dateimage.jsp" width="85" height="10" />

This is the jsp (for german dates, adapt as necessary):

&lt;%@

page import="java.awt.geom.Rectangle2D"%&gt;&lt;%@

page import="java.awt.AlphaComposite"%&gt;&lt;%@

page session="false"%&gt;&lt;%@

page import="java.util.Date"%&gt;&lt;%@

page import="javax.imageio.ImageIO"%&gt;&lt;%@

page import="java.awt.Font"%&gt;&lt;%@

page import="java.awt.Color"%&gt;&lt;%@

page import="java.awt.Graphics2D"%&gt;&lt;%@

page import="java.awt.image.BufferedImage"%&gt;&lt;%@

page import="java.util.Locale"%&gt;&lt;%@

page import="java.text.DateFormat"%&gt;&lt;%@

page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%&gt;&lt;%

 

    // size of the image

    final int height = 100;

    final int width = 850; 

     

    // create string in correct date format

    DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM,

            Locale.GERMAN);

    String dateString = df.format(new Date());

     

    // create white default image

    BufferedImage bufferedImage = new BufferedImage(width, height,

            BufferedImage.TYPE_INT_ARGB);

     

    // create graphic

    Graphics2D dateGraphics2D = null;

    try {

        dateGraphics2D = bufferedImage.createGraphics();

     

        // write string to in Black graphics

        dateGraphics2D.setColor(Color.BLACK);

        dateGraphics2D.setFont(new Font("Helvetica", Font.PLAIN, height));

        dateGraphics2D.drawString(dateString, 0, height-2);

     

    } finally {

        // dispose graphics always

        if (dateGraphics2D != null) {

            dateGraphics2D.dispose();

        }

    }

     

    // write output

    response.setContentType("image/png");

    ImageIO.write(bufferedImage, "png", response.getOutputStream());

 

%&gt;

Thanks for your reply! But it seems it is not exactly what we need... We do NOT need the current date in our PDF-exports, but the date, the Confluence page was LAST MODIFIED - ideally together with the author of that most recent edit. It is there - on top of every page, but in does not apear in any export-type (PDF / Word).

Another idea: Perhaps does anyone know some kind of makro, that puts this kind of information into the "printable" / exportable region of a page?

best regards, Joachim

Surely the last modified date can be piped through to the pdf exporter. Its already on the page being exported. Is this really not possible?

Joachim Plener - did you end up figuring out how to add the 'last modified' date to the footer?

Is there no easier way to include the current date into the footer for each PDF export ? 
Creating an image for a date just to put it on the footer seems to me making this problem extreme complicated.

I only know RasterEdge PDF control can modify PDF pages, but I don't know whether it's what you wanted.

If you still need it, you can google it.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

385 views 21 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you