How to use the xhtml2pdf.pisa.startViewer function in xhtml2pdf

To help you get started, we’ve selected a few xhtml2pdf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xhtml2pdf / xhtml2pdf / test / simple.py View on Github external
"""
    Simple test showing how to create a PDF file from
    PML Source String. Also shows errors and tries to start
    the resulting PDF
    """

    pdf = pisa.CreatePDF(
        cStringIO.StringIO(data),
        file(dest, "wb")
        )

    if pdf.err:
        dumpErrors(pdf)
    else:
        pisa.startViewer(dest)
github xhtml2pdf / xhtml2pdf / test / simple.py View on Github external
we also pass the url as 'path' for relative path calculations.
    """
    import urllib

    pdf = pisa.CreatePDF(
        urllib.urlopen(url),
        file(dest, "wb"),
        log_warn = 1,
        log_err = 1,
        path = url,
        link_callback = pisa.pisaLinkLoader(url).getFileName
        )

    dumpErrors(pdf)
    if not pdf.err:
        pisa.startViewer(dest)
github xhtml2pdf / xhtml2pdf / test / cookbook.py View on Github external
def HTML2PDF(data, filename, open=False):

    """
    Simple test showing how to create a PDF file from
    PML Source String. Also shows errors and tries to start
    the resulting PDF
    """

    pdf = pisa.CreatePDF(
        io.StringIO(data),
        file(filename, "wb"))

    if open and (not pdf.err):
        pisa.startViewer(filename)

    return not pdf.err
github xhtml2pdf / xhtml2pdf / test / simple.py View on Github external
Simple test showing how to create a PDF file from
    PML Source String. Also shows errors and tries to start
    the resulting PDF
    """

    pdf = pisa.CreatePDF(
        file(src, "r"),
        file(dest, "wb"),
        log_warn = 1,
        log_err = 1,
        path = os.path.join(os.getcwd(), src)
        )

    dumpErrors(pdf)
    if not pdf.err:
        pisa.startViewer(dest)
github SasView / sasview / src / sas / sasgui / guiframe / gui_manager.py View on Github external
path = config.TUTORIAL_PATH
            if IS_WIN:
                try:
                    from sas.sasgui.guiframe.pdfview import PDFFrame
                    dialog = PDFFrame(None, -1, "Tutorial", path)
                    # put icon
                    self.put_icon(dialog)
                    dialog.Show(True)
                except:
                    logger.error("Error in _onTutorial: %s" % sys.exc_value)
                    try:
                        # Try an alternate method
                        logger.error(
                            "Could not open the tutorial pdf, trying xhtml2pdf")
                        from xhtml2pdf import pisa
                        pisa.startViewer(path)
                    except:
                        logger.error(
                            "Could not open the tutorial pdf with xhtml2pdf")
                        msg = "This feature requires 'PDF Viewer'\n"
                        wx.MessageBox(msg, 'Error')
            else:
                try:
                    command = "open '%s'" % path
                    os.system(command)
                except:
                    try:
                        # Try an alternate method
                        logger.error(
                            "Could not open the tutorial pdf, trying xhtml2pdf")
                        from xhtml2pdf import pisa
                        pisa.startViewer(path)