Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6889989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:13:31+00:00 2026-05-27T06:13:31+00:00

What would be a solid tool to use for generating PDF reports? Particularly, we

  • 0

What would be a solid tool to use for generating PDF reports? Particularly, we are interested in creating interactive PDFs that have video, like the example found here.

Right now we are using Python and reportlab to generate PDFs, but have not explored the library completely (mostly because the license pricing is a little prohibitive)

We have been looking at the Adobe’s SDK and iText libraries but it’s hard to say what the capabilities of either are.

The ability to generate a document from a template PDF would be a plus.

Any pointers or comments will be appreciated.

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:13:32+00:00Added an answer on May 27, 2026 at 6:13 am

    Recently, I needed to create PDF reports for a Django application; a ReportLab license was available, but I ended up choosing LaTeX. The benefit of this approach is that we could use Django templates to generate the LaTeX source, and not get over encumbered writing lots of code for the many reports we needed to create. Plus, we could take advantage of the relatively much more concise LaTeX syntax (which does have it’s many quirks and is not suitable for every purpose).

    This snippet provides a general overview of the approach. I found it necessary to make some changes, which I have provided at the end of this question. The main addition is detection for Rerun LaTeX messages, which indicates an additional pass is required. Usage is as simple as:

    def my_view(request):
        pdf_stream = process_latex(
            'latex_template.tex',
            context=RequestContext(request, {'context_obj': context_obj})
        )
        return HttpResponse(pdf_stream, content_type='application/pdf')
    

    It is possible to embed videos in LaTeX generated PDFs, however I do not have any experience with it. Here is a top Google result.

    This solution does require spawning a new process (pdflatex), so if you want a pure Python solution keep looking.

    import os
    from subprocess import Popen, PIPE
    from tempfile import NamedTemporaryFile
    
    from django.template import loader, Context
    
    
    class LaTeXException(Exception):
        pass
    
    
    def process_latex(template, context={}, type='pdf', outfile=None):
        """
        Processes a template as a LaTeX source file.
        Output is either being returned or stored in outfile.
        At the moment only pdf output is supported.
        """
        t = loader.get_template(template)
        c = Context(context)
        r = t.render(c)
    
        tex = NamedTemporaryFile()
        tex.write(r)
        tex.flush()
        base = tex.name
        names = dict((x, '%s.%s' % (base, x)) for x in (
            'log', 'aux', 'pdf', 'dvi', 'png'))
        output = names[type]
    
        stdout = None
        if type == 'pdf' or type == 'dvi':
            stdout = pdflatex(base, type)
        elif type == 'png':
            stdout = pdflatex(base, 'dvi')
            out, err = Popen(
                ['dvipng', '-bg', '-transparent', names['dvi'], '-o', names['png']],
                cwd=os.path.dirname(base), stdout=PIPE, stderr=PIPE
            ).communicate()
    
        os.remove(names['log'])
        os.remove(names['aux'])
    
        # pdflatex appears to ALWAYS return 1, never returning 0 on success, at
        # least on the version installed from the Ubuntu apt repository.
        # so instead of relying on the return code to determine if it failed,
        # check if it successfully created the pdf on disk.
        if not os.path.exists(output):
            details = '*** pdflatex output: ***\n%s\n*** LaTeX source: ***\n%s' % (
                stdout, r)
            raise LaTeXException(details)
    
        if not outfile:
            o = file(output).read()
            os.remove(output)
            return o
        else:
            os.rename(output, outfile)
    
    
    def pdflatex(file, type='pdf'):
        out, err = Popen(
            ['pdflatex', '-interaction=nonstopmode', '-output-format', type, file],
            cwd=os.path.dirname(file), stdout=PIPE, stderr=PIPE
        ).communicate()
    
        # If the output tells us to rerun, do it by recursing over ourself.
        if 'Rerun LaTeX.' in out:
            return pdflatex(file, type)
        else:
            return out
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a little triangle underneath the the text that points
I would like to have a robust CSS that would have all forms I
I currently have an element that has a solid border along one side of
I would like to have an ordered list that has the text on the
I would like to have a hover box over my list so that they
Would the following SQL remove also the index - or does it have to
Would having a nice little feature that makes it quicker to write code like
Would it be possible to write a class that is virtually indistinguishable from an
I would like to set up some solid testing on my project and the
i would like to add an image that acts like a border after every

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.