def generate_card(IMG_FILE,IMG_URL,TEXT_FRONT,TEXT_INSIDE):
    """Main function to generate PDF and print to stdout. Designed to be
    run as a CGI application."""
    if not (IMG_FILE or IMG_URL):
        print 'You must upload an image file or provide a URL to one'
        return

    tmp = StringIO()

    #Canvas Setup
    c = canvas.Canvas(tmp, pagesize=letter, pageCompression=0)
    #If output size is important set pageCompression=1, but remember that, compressed documents
    #will be smaller, but slower to generate. Note that images are always compressed, and this option will only
    #save space if you have a very large amount of text and vector graphics on each page.
    #Do I need 'MacRomanEncoding' for Macs?
    #Note: 0,0 coordinate in canvas is bottom left.
    c.setAuthor('Utility Mill - utilitymill.com/utility/greeting_card_generator')
    c.setTitle('Beautiful, expensive greeting card created at utilitymill.com')

    #add_fold_lines(c) #early feedback says lines aren't necessary. Uncomment here to put them in
    put_in_front_picture(c,IMG_FILE,IMG_URL)
    write_text(c,TEXT_FRONT.replace('\r',''),TEXT_INSIDE.replace('\r',''))

    #The showPage method saves the current page of the canvas
    c.showPage()
    #The save method stores the file and closes the canvas.
    c.save()

    tmp.seek(0)
    print 'Content-Type: application/pdf'
    print tmp.read()
Main function to generate PDF and print to stdout. Designed to be
    run as a CGI application.
recipes/Python/535155_Generate_a_PDF_Greeting_Card/recipe-535155.py