Multiple dinbriefs in one PDF

Issue #3 new
nomeata created an issue

This might be more a platypus than a dinbrief question, but you invited me to ask questions :-).

Assume I have several dinbrief.Document objects and content for each of them. How can I create one PDF file that is the concatenation of all of these letters?

Thanks, Joachim

Comments (4)

  1. Michael P. Jung

    Right now the simplest way to do this is by creating separate PDF files and concatenating them using pyPdf.

    I quite like the idea of having a BriefTemplate that is capable of rendering multiple Documents into one large PDF file. It is in fact a platypus thing and one would need to switch between the "First" and "Later" page template while making sure the code keeps track of the currentDocument to use different addresses and headers when rendering the "First" page template.

    I quite like the Idea and think that it could be integrated into the revamped dinbrief API:

    template = BriefTemplate();
    template.render([document1, document2], fh=fh)
    
  2. nomeata reporter

    I managed to implement this using pyPDF, but the resulting files are unreasonably large; presumably because the logo on each letter is duplicated. Generating the whole document in one run might include the image only once in the PDF, I hope...

    If you get around to implement this, also consider adding a two-sided mode, where following each letter with an odd number of pages, a blank page is inserted, so that the whole document can be printed correctly two-sided.

  3. Michael P. Jung

    I have now prepared the BriefTemplate (see #4) so it is possible to subclass it. Now it should be rather simple to implement a way to render more than one document into one PDF file.

    The only problem I'm having right now is the meta information. I'm filling the title, subject, author, keywords and creator document properties using the Document class. When passing multiple Documents this is no longer possible. I was thinking of either adding another argument to the render method or using the meta data of the first document. Since rendering multiple documents into one PDF is probably only used to create one large printable PDF this might not even be a problem after all?

  4. Log in to comment