Coder Social home page Coder Social logo

pyfpdf's People

Contributors

craigahobbs avatar jredrejo avatar kalbermattenm avatar leonelcamara avatar niphlod avatar reingart avatar romankharin avatar yanone avatar

pyfpdf's Issues

Error when using IronPython 2.7: UnicodeDecodeError: ('unknown', u'\x9c', 0, 1, '')

What steps will reproduce the problem?
1. creating a new PDF instance
2. running any sample .py script in tutorial folder

What is the expected output? What do you see instead?
Any PDF. Instead script is interrupted in function _out >> at line 
self.buffer+=str(s)+"\n"

What version of the product are you using? On what operating system?
pyPDF 1.54b on IronPython 2.7.1


Original issue reported on code.google.com by [email protected] on 5 May 2012 at 1:31

web2py 2.0.9 sub() got an unexpected keyword argument 'flags'

What steps will reproduce the problem?
1.I move my web2py app from web2py 2.2.3 to web2py 2.0.9


Traceback (most recent call last):
  File "C:\web2py2\gluon\restricted.py", line 209, in restricted
    exec ccode in environment
  File "C:/web2py2/applications/EMPRE/controllers/default.py", line 530, in <module>
  File "C:\web2py2\gluon\globals.py", line 186, in <lambda>
    self._caller = lambda f: f()
  File "C:/web2py2/applications/EMPRE/controllers/default.py", line 155, in report
    pdf.image(logo,xy[0],xy[1],w=30)
  File "C:\web2py2\gluon\contrib\fpdf\fpdf.py", line 896, in image
    info=self._parsepng(name)
  File "C:\web2py2\gluon\contrib\fpdf\fpdf.py", line 1749, in _parsepng
    color += re.sub('(.{3}).',lambda m: m.group(1),line, flags=re.DOTALL)
TypeError: sub() got an unexpected keyword argument 'flags'


Original issue reported on code.google.com by [email protected] on 14 Feb 2013 at 5:51

  • Merged into: #42

according to web2py ticket: KeyError: 'item_description01'

What steps will reproduce the problem?
1.
def invoice2():
    from gluon.contrib.pyfpdf import Template
    import os.path

    # generate sample invoice (according Argentina's regulations)

    import random
    from decimal import Decimal

    # read elements from db 

    #elements = db(db.pdf_element.pdf_template_id==1).select(orderby=db.pdf_element.priority)
    elements = [
        { 'name': 'company_logo', 'type': 'I', 'x1': 20.0, 'y1': 17.0, 'x2': 78.0, 'y2': 30.0, 'font': None, 'size': 0.0, 'bold': 0, 'italic': 0, 'underline': 0, 'foreground': 0, 'background': 0, 'align': 'I', 'text': 'logo', 'priority': 2, },
        { 'name': 'company_name', 'type': 'T', 'x1': 17.0, 'y1': 32.5, 'x2': 115.0, 'y2': 37.5, 'font': 'Arial', 'size': 12.0, 'bold': 1, 'italic': 0, 'underline': 0, 'foreground': 0, 'background': 0, 'align': 'I', 'text': '', 'priority': 2, },
        { 'name': 'box', 'type': 'B', 'x1': 15.0, 'y1': 15.0, 'x2': 185.0, 'y2': 260.0, 'font': 'Arial', 'size': 0.0, 'bold': 0, 'italic': 0, 'underline': 0, 'foreground': 0, 'background': 0, 'align': 'I', 'text': None, 'priority': 0, },
        { 'name': 'box_x', 'type': 'B', 'x1': 95.0, 'y1': 15.0, 'x2': 105.0, 'y2': 25.0, 'font': 'Arial', 'size': 0.0, 'bold': 1, 'italic': 0, 'underline': 0, 'foreground': 0, 'background': 0, 'align': 'I', 'text': None, 'priority': 2, },
        { 'name': 'line1', 'type': 'L', 'x1': 100.0, 'y1': 25.0, 'x2': 100.0, 'y2': 57.0, 'font': 'Arial', 'size': 0, 'bold': 0, 'italic': 0, 'underline': 0, 'foreground': 0, 'background': 0, 'align': 'I', 'text': None, 'priority': 3, },
        { 'name': 'barcode', 'type': 'BC', 'x1': 20.0, 'y1': 246.5, 'x2': 140.0, 'y2': 254.0, 'font': 'Interleaved 2of5 NT', 'size': 0.75, 'bold': 0, 'italic': 0, 'underline': 0, 'foreground': 0, 'background': 0, 'align': 'I', 'text': '200000000001000159053338016581200810081', 'priority': 3, },
        ]

    f = Template(format="A4",
             elements = elements,
             title="Sample Invoice", author="Sample Company",
             subject="Sample Customer", keywords="Electronic TAX Invoice")

    # create some random invoice line items and detail data
    detail = "Lorem ipsum dolor sit amet, consectetur. " * 5
    items = []
    for i in range(1, 30):
        ds = "Sample product %s" % i
        qty = random.randint(1,10)
        price = round(random.random()*100,3)
        code = "%s%s%02d" % (chr(random.randint(65,90)), chr(random.randint(65,90)),i)
        items.append(dict(code=code, unit='u',
                          qty=qty, price=price, 
                          amount=qty*price,
                          ds="%s: %s" % (i,ds)))

    # divide and count lines
    lines = 0
    li_items = []
    for it in items:
        qty = it['qty']
        code = it['code']
        unit = it['unit']
        for ds in f.split_multicell(it['ds'], 'item_description01'):
            # add item description line (without price nor amount)
            li_items.append(dict(code=code, ds=ds, qty=qty, unit=unit, price=None, amount=None))
            # clean qty and code (show only at first)
            unit = qty = code = None
        # set last item line price and amount
        li_items[-1].update(amount = it['amount'],
                            price = it['price'])

    # split detail into each line description
    obs="\n<U>Detail:</U>\n\n" + detail
    for ds in f.split_multicell(obs, 'item_description01'):
        li_items.append(dict(code=code, ds=ds, qty=qty, unit=unit, price=None, amount=None))

    # calculate pages:
    lines = len(li_items)
    max_lines_per_page = 24
    pages = lines / (max_lines_per_page - 1)
    if lines % (max_lines_per_page - 1): pages = pages + 1

    # fill placeholders for each page
    for page in range(1, pages+1):
        f.add_page()
        f['page'] = 'Page %s of %s' % (page, pages)
        if pages>1 and page<pages:
            s = 'Continues on page %s' % (page+1)
        else:
            s = ''
        f['item_description%02d' % (max_lines_per_page+1)] = s

        f["company_name"] = "Sample Company"
        f["company_logo"] = os.path.join(request.env.web2py_path,"gluon","contrib","pyfpdf","tutorial","logo.png")
        f["company_header1"] = "Some Address - somewhere -"
        f["company_header2"] = "http://www.example.com"        
        f["company_footer1"] = "Tax Code ..."
        f["company_footer2"] = "Tax/VAT ID ..."
        f['number'] = '0001-00001234'
        f['issue_date'] = '2010-09-10'
        f['due_date'] = '2099-09-10'
        f['customer_name'] = "Sample Client"
        f['customer_address'] = "Siempreviva 1234"

        # print line item...
        li = 0 
        k = 0
        total = Decimal("0.00")
        for it in li_items:
            k = k + 1
            if k > page * (max_lines_per_page - 1):
                break
            if it['amount']:
                total += Decimal("%.6f" % it['amount'])
            if k > (page - 1) * (max_lines_per_page - 1):
                li += 1
                if it['qty'] is not None:
                    f['item_quantity%02d' % li] = it['qty']
                if it['code'] is not None:
                    f['item_code%02d' % li] = it['code']
                if it['unit'] is not None:
                    f['item_unit%02d' % li] = it['unit']
                f['item_description%02d' % li] = it['ds']
                if it['price'] is not None:
                    f['item_price%02d' % li] = "%0.3f" % it['price']
                if it['amount'] is not None:
                    f['item_amount%02d' % li] = "%0.2f" % it['amount']

        # last page? print totals:
        if pages == page:
            f['net'] = "%0.2f" % (total/Decimal("1.21"))
            f['vat'] = "%0.2f" % (total*(1-1/Decimal("1.21")))
            f['total_label'] = 'Total:'
        else:
            f['total_label'] = 'SubTotal:'
        f['total'] = "%0.2f" % total

    response.headers['Content-Type']='application/pdf'
    return f.render('invoice.pdf', dest='S')
2. and then calling http://127.0.0.1/app/invoice/invoice2.pdf
3.

What is the expected output? What do you see instead?

a pdf of the example invoice like the one in the samples

What version of the product are you using? On what operating system?

web2py latest for mercurial.

Please provide any additional information below.

notice that i replaced the elements from the db with the ones scripted in 
another example.

Original issue reported on code.google.com by [email protected] on 16 Sep 2010 at 4:03

emo path error

What steps will reproduce the problem?
1. Install the demo with last web2py trunk version
2. try the report example

What is the expected output? What do you see instead?
A downloaded pdf/A path error ticket

What version of the product are you using? On what operating system?
web2py Version 2.4.1-alpha.2+timestamp.2013.02.15.17.33.13
fpdf demo http://pyfpdf.googlecode.com/files/web2py.app.fpdf.w2p

The problem is fixed by changing the path at default.py line 79

Note: This is because the web2py contrib library removed the fpdf logo

Original issue reported on code.google.com by [email protected] on 16 Feb 2013 at 12:52

Unable to find documentation for how to rotate a cell, text, etc.

What steps will reproduce the problem?
1. Starting with tuto1.py and modified it a below.

from pyfpdf import FPDF

pdf=FPDF()
pdf.add_page()
pdf.set_font('Arial','B',16)
g=pdf.cell(40,10,'Hello World!')
pdf.rotate(g,45)

2. I have tried to use pdf.rotate(...) to rotate the cell to an arbitray angle.
3. This may just be a documentation issue.

What is the expected output? What do you see instead?
I hope to see the text rotate by the input angle.  What I get instead is and 
error as shown below.

> "C:\Python26\python.exe"  
"C:\Python26\Lib\site-packages\pyfpdf\tutorial\tuto1.py" 
Traceback (most recent call last):
  File "C:\Python26\Lib\site-packages\pyfpdf\tutorial\tuto1.py", line 7, in <module>
    pdf.rotate(g,45)
  File "C:\Python26\lib\site-packages\pyfpdf\fpdf.py", line 547, in rotate
    angle *= math.pi/180;
TypeError: unsupported operand type(s) for *=: 'NoneType' and 'float'

What version of the product are you using? On what operating system?

Current download installed in the site-packages directory.  The OS is windows XP
Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 14 Oct 2010 at 5:18

write_html use a fixed font size and family

When rendering a html using "write_html", the font size and family of the 
rendered part in the pdf is always the same. This is because the 
line 42 of html.py
self.set_font("times", 12)

What is the expected output? What do you see instead?

I'd expect the html rendered to take into account the font changes inserted in 
the html text.


Using the latest pyfpdf version included in web2py.

Regards.

Original issue reported on code.google.com by [email protected] on 15 Sep 2011 at 12:45

tag td without attribute width

What steps will reproduce the problem?
1 - generate a report containing a table, where the td tag, does not include 
the width attribute, the error will occur: 
"
  File ".../html.py", line 239, in handle_starttag
    if self.td['width']:
KeyError: 'width'

"

What version of the product are you using? On what operating system?
1.54b - 2010-09-10, Ubuntu 10.10

Please provide any additional information below.

I changed the expression "if self.td['width']:" to " if 'width' in self.td:", 
and the error no longer occurs.
What is the expected output? What do you see instead?

Original issue reported on code.google.com by [email protected] on 28 Nov 2010 at 3:12

on error IS_LIST_OF() changes the value of INPUT

What steps will reproduce the problem?
1. db.define_table('address',
    Field('name'),
    Field('emails','list:string', requires=IS_LIST_OF(IS_EMAIL())))

2. Add a row like
Name:    Smith
Emails:  [email protected]
         [email protected]

3. Change email-address to a wrong one. e.g. jsmith#example.com

What is the expected output? 
An error message

What do you see instead?
Name:    Smith
Emails:  ['jsmith#example.com', '[email protected]']
         ['jsmith#example.com', '[email protected]']


What version of the product are you using? On what operating system?
2.0.9

Please provide any additional information below.
To try use the admin interface


Original issue reported on code.google.com by [email protected] on 16 Sep 2012 at 6:01

Python 3 support

i'd be happy to help make this python3 happy.  i have a distinct need for 
generating PDFs and my knowledge about pdf structure etc is minimal at best but 
in trade, i write all my stuff for py3

i have a checkout copy of pyfpdf that currently runs for basic stuff.  i've 
made my own alterations purely to get it running so i can figure things out but 
i'd really like to clean up my changes and make it so it'll be happy in both 2 
and 3

-david

Original issue reported on code.google.com by [email protected] on 17 May 2011 at 6:35

'(' doesn't work

When i want to write the character '(' or ')' with Cell or MultiCell, pyfpdf 
shows '\(' instead 


Original issue reported on code.google.com by [email protected] on 31 Aug 2010 at 8:58

"Send the file to browser" options of output isn't applicable

All of these print to stdout, but the wording suggests they do different things 
although "sending to browser" doesn't make sense in python: 

I: send the file inline to the browser. The plug-in is used if available. The 
name given by name is used when one selects the "Save as" option on the link 
generating the PDF.
D: send to the browser and force a file download with the name given by name.
S: return the document as a string. name is ignored.

You are probably better of doing "raise NotImplemented" on at least I and D or 
removing them altogether.

Original issue reported on code.google.com by [email protected] on 13 Sep 2012 at 9:15

v1.7.1 Flowing image

I like the new feature of flowing images in version 1.7.1.

But in flowing mode the x-position is in the current implementation 
overwritten. Is it possible to keep the x-position?

I fixed the problem for me by commenting the corresponding lines as you can see 
here:

    def image(self, name, x=None, y=None, w=0,h=0,type='',link=''):
        # ...
        # Flowing mode
        if y is None:
            if (self.y + h > self.page_break_trigger and not self.in_footer and self.accept_page_break()):
                #Automatic page break
                #x = self.x
                self.add_page(self.cur_orientation)
                #self.x = x
            y = self.y
        #...

I mean the page break is realted to the y-position, but has nothing to do with 
the x-position, right?

Original issue reported on code.google.com by [email protected] on 14 Feb 2013 at 7:03

Support for non-BMP glyphs 0x100000-0x10FFFF

What steps will reproduce the problem?
1. Use font with non-BMP glyps (e.g. DroidSansFallback.ttf, see Issue 37 how to 
use this font)
2. Try to create PDF with non-BMP (0x100000-0x10FFFF) chars (0x010400, 
0x010428, 0x01044d, 0x01044e, 0x01044f, 0x01d30c in DroidSansFallback.ttf)


What is the expected output? What do you see instead?
PDF with non-BMP charters (DESERET code plane in this example)

INsted
Traceback (most recent call last):
  File "charmap.py", line 46, in <module>
    pdf.output(fn,'F')
  File "../tests/fpdf/fpdf.py", line 971, in output
    self.close()
  File "../tests/fpdf/fpdf.py", line 240, in close
    self._enddoc()
  File "../tests/fpdf/fpdf.py", line 1526, in _enddoc
    self._putresources()
  File "../tests/fpdf/fpdf.py", line 1473, in _putresources
    self._putfonts()
  File "../tests/fpdf/fpdf.py", line 1275, in _putfonts
    cidtogidmap[cc*2] = chr(glyph >> 8)
IndexError: list assignment index out of range

Please use labels and text to provide additional information.

Non BMP code planes lay in range 0x100000 .. 0x10FFFF.
This issue applied only in python with UCS-4 support or all python platforms >= 
3.3 (see PEP-393 http://www.python.org/dev/peps/pep-0393)


Original issue reported on code.google.com by [email protected] on 8 Jan 2013 at 10:28

Attachments:

Pillow and other corrected PIL forks support.

What steps will reproduce the problem?
1. install Pillow instead of PIL, through pypi
2. do any operation involving pyfpdf
3. pyfpdf throws an exception saying that it can't find any package named 
"Image"

What is the expected output? What do you see instead?
The expected output is for the operation to go through an continue.

What version of the product are you using? On what operating system?
Latest copy from pypi. Ubuntu 11.10

Please provide any additional information below.
My understanding is that PIL doesn't directly support setup-tools or the like, 
even though it is on pypi. Your code supports the pypi version of PIL by just 
using "import Image", when it really should be "from PIL import Image" (which 
sadly does't with on the pypi version). The code, in turn, does not work with 
Pillow, and (though I haven't tested this yet) it won't work with manually 
installed or corrected versions of PIL.

The catch-all solution is to use one more try/except so that it tries importing 
PIL both ways. I have included a patch file with my changes.

Original issue reported on code.google.com by [email protected] on 7 Dec 2012 at 11:09

Attachments:

Character encoding issues around non-US English

This is a great wrapper around the pdf libs, and I particularly like that it is 
standalone.

I am having issues using it for non-English words. I've included a small code 
snippet that attempts to encode the Spanish word año for year.

Instead of the expected output, I am seeing: año

I am using version 1.54b on OSX 10.6.8 with Python 2.6.1

SAMPLE CODE TO REPRODUCE ISSUE

#!/usr/bin/python
# -*- coding: latin-1 -*-

#import os
from pyfpdf import FPDF

#font = 'ISO-8859-1'
font = 'courier'                                                                


pdf = FPDF()                                                                    

pdf.add_page()                                                                  


pdf.set_font(font, 'B', 16.0)                                                   

pdf.set_xy(95.0,18.0)                                                           

pdf.cell(ln=0, h=10.0, align='C', w=75.0, txt='año', border=1)                 


pdf.set_font(font, '', 12.0)                                                    

pdf.set_xy(95.0,28.0)                                                           

pdf.cell(ln=0, h=10.0, align='R', w=75.0, txt='year', border=0)                 


pdf.output('SpanishWord.pdf', 'F')    

Original issue reported on code.google.com by [email protected] on 29 Sep 2012 at 7:26

_parsegif and _parsejpg doesn't download the images

_parsegif and _parsejpg doesn't download the image. _parsepng starts with:

if name.startswith("http://") or name.startswith("https://"):
            import urllib
            f = urllib.urlopen(name)

which is missing from _parsegif and _parsejpg. This is a bit unexpected since 
http://code.google.com/p/pyfpdf/wiki/Image just generally says putting in a 
link works.

Original issue reported on code.google.com by [email protected] on 13 Sep 2012 at 9:01

It's unclear how auto-calculation for images will fit the page.

If I take an image that is in portrait mode it gets cropped rather than being 
fit to the page, how come?

Example:

pdf = FPDF()
pdf.add_page()
pdf.image('https://mediapop-dev.s3.amazonaws.com/clients/canon/origame/24.png', 
0,0, type="PNG")
pdf.output('test.pdf', 'F')

Original issue reported on code.google.com by [email protected] on 13 Sep 2012 at 9:18

_freadint reads only a short instead of long --> Problem with PNG-Images with chunksizes > 0xFFFF

What steps will reproduce the problem?
--> Try to import a PNG-image with a chunk > 0xFFFF bytes. In my case the chunk 
size was 0x10000 (image converted to PNG using PIL).

What do you see instead?
--> _parsepng assumes a wrong chunk size and reads crap from the PNG-file. This 
leads finally to an exception.

What version of the product are you using? On what operating system?
--> FPDF 1.7, Python 2.6.6

Please provide any additional information below.

Is there a reason, why _freadint reads only the lower halfword and drops the 
upper half of the integer?
I simply changed it to read a unsigned doubleword and then importing my PNGs 
worked.

Changed: return struct.unpack('>HH',f.read(4))[1]
To:      return struct.unpack('>L', f.read(4))[0]

Original issue reported on code.google.com by [email protected] on 30 Jan 2013 at 12:29

Print avery labels with pyfpdf

I have "translated" http://www.fpdf.org/en/script/script29.php to be used with 
pyfpdf.
Just tell me if you want me to send it to to you using this issue or commiting 
it to the repo if you give me write access.

It adds one file to the sources, BUT it requires one change in fpdf.py:

class FPDF():
must be modified to
class FPDF(object):

The labels class inherited from FPDF and  needs to call a couple of super 
methods, so FPDF needs to be created in this way.
As far as I know, this change doesn't imply anything in the behaviour of FPDF.

Regards.
José L.

Original issue reported on code.google.com by [email protected] on 30 Sep 2011 at 8:03

error creating pdf

What steps will reproduce the problem?

I have an html string in web2py that can be converted into a pdf using pisa but 
fails with pyfpdf. The error is as follows:

File "C:\web2py\gluon\contrib\pyfpdf\html.py", line 388, in write_html
    h2p.feed(text)
  File "C:\Python27\lib\HTMLParser.py", line 108, in feed
    self.goahead(0)
  File "C:\Python27\lib\HTMLParser.py", line 148, in goahead
    k = self.parse_starttag(i)
  File "C:\Python27\lib\HTMLParser.py", line 271, in parse_starttag
    self.handle_starttag(tag, attrs)
  File "C:\web2py\gluon\contrib\pyfpdf\html.py", line 176, in handle_starttag
    self.align=attrs['align'].lower()
KeyError: 'align'

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 27 Oct 2011 at 3:27

new-style class

What steps will reproduce the problem?
1. inheritance of FPDF using super

What is the expected output? 
super exec ok

What do you see instead?
TypeError: super() argument 1 must be type, not classobj


Original issue reported on code.google.com by [email protected] on 25 Jan 2011 at 7:10

Unable to specify font and size when parsing html to ftp

While creating a PDF document, I had no problem generating the perfect header 
and footer, but when I passed html to your module, all styling was removed and 
I was unable to successfully change the font using the <font> tags.

So everything was coming out in times new roman, therefore I made the following 
changes you may want to include:

Basically I have added more fiends to the write_html() functions

e.g. pdf.write_html(text=str(XML(table, 
sanitize=False)),font="arial",fontsize=11)

This way you can specify the font and size of the text you are passing through. 
Changes done:

class HTMLMixin():
    def write_html(self, **kwargs):   
        "Parse HTML and convert it to PDF"
        h2p = HTML2FPDF(self,**kwargs)
        h2p.feed(kwargs["text"])

class HTML2FPDF(HTMLParser):
    "Render basic HTML to FPDF"

    def __init__(self, pdf, image_map):
        HTMLParser.__init__(self)
        self.image_map = kwargs.get("image_map","")
        self.set_font(kwargs.get("font","times"), kwargs.get("fontsize",12))

        (removed extra code)

Please let me know if you need anything else from me.

Tyrone Hattingh


Original issue reported on code.google.com by [email protected] on 14 Sep 2011 at 2:14

  • Merged into: #16

setPage function

Hi,
I wonder if pyfpdf could have this setPage function, like tcpdf.
Maybe it is a wishilist request.

Regards,

Original issue reported on code.google.com by [email protected] on 12 Jul 2012 at 11:16

Font does not have cmap for Unicode

What steps will reproduce the problem?
1. Install pyfpdf <= 1.7.1
2. Copy DroidSansFallback.ttf to font folder
3. Start unifonts.py test

What is the expected output? What do you see instead?

Expected: PDF with DroidSans glyphs
Got: RuntimeError: Font (../fpdf/font/DroidSansFallback.ttf) does not have cmap 
for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, 
format 4)

Please use labels and text to provide additional information.

This font contain only one cmap table with Platform=3, Encoding=10, Format=12 
which unsupported by now. 

http://partners.adobe.com/public/developer/opentype/index_cmap.html

This patch add preliminary format 12 support.

Original issue reported on code.google.com by [email protected] on 2 Jan 2013 at 7:48

Attachments:

Make it a proper package

The package should be installable, e.g. with setup.py script. But there is no 
setup.py script for it.

What version of the product are you using? On what operating system?
Python 2.5 through 3.3 on Windows XP SP3 32-bit.

http://www.blog.pythonlibrary.org/2012/07/10/an-intro-to-pyfpdf-a-simple-python-
pdf-generation-library/

Original issue reported on code.google.com by [email protected] on 11 Jul 2012 at 1:00

Windows exe installer triggers Norton 360 threat detection

What steps will reproduce the problem?
1. download/run the exe installer from link while Norton 360 is active
2.
3.

What is the expected output? What do you see instead?
expected: installer to run
instead: Norton 360 removed installer
see attached screenshot

What version of the product are you using? On what operating system?
trying to install 1.7 on Windows 7 64bit ultimate

Please provide any additional information below.
the msi installer works fine

Original issue reported on code.google.com by [email protected] on 16 Sep 2012 at 8:56

Attachments:

[WriteHTML] Bad alignment of the first row of each new page.

What steps will reproduce the problem?
1. Using the html/table example class: 

from pyfpdf import FPDF, HTMLMixin

class MyFPDF(FPDF, HTMLMixin):
    pass

pdf=MyFPDF()
#First page
pdf.add_page()
html = open('attached_html.html', 'r') # see attachments
pdf.write_html(html)
pdf.output('html.pdf','F')


What is the expected output? What do you see instead?

A centered table in all pages, but on each new page the first row is aligned to 
the left instead of to the center.

What version of the product are you using? On what operating system?

Latest trunk.


Original issue reported on code.google.com by [email protected] on 20 Sep 2010 at 8:49

Attachments:

Typos and documentation is off regarding fpdf.image

See: http://code.google.com/p/pyfpdf/wiki/Image

fpdf.mage(name, x=None, y=None, w=0, h=0, type='', link='')

should be

fpdf.image(self, name, x, y, w=0, h=0, type='', link=''):

The first parameter is also not "file" as mentioned later on the page.

Original issue reported on code.google.com by [email protected] on 13 Sep 2012 at 8:50

Error when calculating dimensions in inches

Thanks for the great tool.

What steps will reproduce the problem?

import fpdf
doc = fpdf.FPDF('P', 'in', 'Letter')
doc.set_font('Arial','B',32)
print doc.w
print doc.get_string_width("text")

What is the expected output? What do you see instead?
The expected output for doc.w is 8.5 but I get 8.
The expected out put for get_string_width is 0.790222222222 but I get 0.0

I have two suggested ways to fix the problem.  One is to use from __future__ 
import division (attached at 158.patch).  The second is to change the scale 
factors to be floats (attached as 159.patch).  

Original issue reported on code.google.com by [email protected] on 2 Jan 2013 at 3:45

Attachments:

sub() got an unexpected keyword argument 'flags'

What steps will reproduce the problem?
1. Run in python2.6
2. There are four lines of code that look like this:
color += re.sub('(.).',lambda m: m.group(1),line, flags=re.DOTALL)
3. Observe a crash, as the flags parameter was introduced in the sub() method 
in Python 2.7

What version of the product are you using? On what operating system?
1.7 on Linux

Please provide any additional information below.

I think this can be fixed like this:

foo = re.compile('(.{3}).',  flags=re.DOTALL)
color += foo.sub(lambda m: m.group(1),line) 


Original issue reported on code.google.com by [email protected] on 18 Jan 2013 at 4:36

Adobe Acrobat does not show one special utf-8 character. Other PDF-viewers do it well.

1. create PDF with the attached file 'unicodeSimple.py' (this file is utf-8 
coded).
2. open the created unicode-simple.pdf (also attached) with different 
pdf-viewers.

Any of these Adobe products show U+010A instead of U+010D:
- Adobe Reader X on Windows 7
- Adobe Reader XI on Windows 7
- Adobe Acrobat Pro X on Windows 7
- Adobe Acrobat Reader 5.0 on HP-UX

Any of these products show U+010D as expected:
- Google Chrome 24.0 on Windows 7
- Foxit Reader 5.4 on Windows 7
- Evince on linux
- Gimp 2.6 import on linux

As far as I can see, any other utf symbol (Latin-1 Supplement, Latin 
extended-A) is shown as expected by all viewers.

I use pyfpdf 1.7 with python 2.7 on windows 7.
I got same results with these fonts:
- DejaVuSansCondensed
- GNU FreeFont
- MS Arial 5.1

I checked the pdf-file with the Acrobat Pro X preflight-tool and did not find 
any problem or warning.

I don't know, is it a bug in Acrobat or in pyfpdf?

Original issue reported on code.google.com by [email protected] on 17 Jan 2013 at 3:10

Attachments:

web2py and image_map

I added the optional mapping parameter required by web2py. With this I can 
merge the latest version.

Original issue reported on code.google.com by [email protected] on 17 Feb 2013 at 5:25

Attachments:

FPDF can avoid "PIL not found" error

When installing PIL through pip-installing Pillow, no PIL.pth is placed in the 
site-packages directory. 

When no PIL.pth file exists PIL should be used like so:
from PIL import Image

When the PIL.pth does exist, PIL can be used like this:
import Image

(see 
http://stackoverflow.com/questions/8339991/why-in-python-sometimes-from-pil-impo
rt-image-fails-and-import-image-works for more info)

But PFPDF only checks for the latter case:

try:
    # Check if PIL is available, necessary for JPEG support.
    import Image
except ImportError:
    Image = None

It would be convenient if the other case were tested for.

Original issue reported on code.google.com by [email protected] on 15 Jan 2013 at 9:08

  • Merged into: #34

where can i get the chinese.py instead of chinese.php

i want make a chinese pdf file  by python , and found pyfpdf can do,. from the 
google code page tod there 
http://www.fpdf.org/phorum/read.php?f=1&i=5142&t=5142 
is a php file , it can uesd to  make chinese pdf,but PHP , i try transelate it 
into py ,but it too hard,

So,where can i get  the py file.( before that ,i try use the ex to makefont.py 
,but  
ERROR:
 die('Error: unrecognized font file extension: '+ext)  )

----------------
or help me ,3ku!


Original issue reported on code.google.com by [email protected] on 6 Apr 2011 at 3:54

add_font is broken in 1.54b


I convert ttf font for cp1250 codepage with makefont.py tool from pyfpdf 
package and when I try to add this font to my document, I got error:

pdf.add_font('CourierNewPSMT','','cour.py')

  File "/work/pyfpdf/pyfpdf-1.54b/fpdf.py", line 445, in add_font
    self.diffs[d]=diff
IndexError: list assignment index out of range

I made quick fix to solve problem, I will put fixed version of fpdf.py in 
attachment.

Original issue reported on code.google.com by [email protected] on 2 Oct 2010 at 1:20

Attachments:

Cannot import GIF files that don't have transparency.

What steps will reproduce the problem?
1. Try adding a gif that doesn't have transparency to a pdf, such as on the 
next line.
2. pdf.image("foo.gif")
3. Errors out (don't remember specifics, already patched my local copy).

What is the expected output? What do you see instead?
The GIF that has no transparency channel should be added to the page. Instead, 
fpdf fails with an error.

What version of the product are you using? On what operating system?
Newest copy from pip (not exactly sure, but the bug appears to still exist in 
your trunk).

Please provide any additional information below.
The error happens in def _parsegif(self, filename):   when trying to run 
transparency = im.info['transparency'].

The corrected code is in the first attachment. I have also uploaded an example 
gif to help demonstrate the problem. On my patched copy (with the fixed code 
from the attachment), it now tries to add the transparency parameter, and if it 
fails, it continues instead without adding the transparency parameter.

Original issue reported on code.google.com by [email protected] on 5 Dec 2012 at 12:32

Attachments:

import_csv errors due to hard-coded example file

What steps will reproduce the problem?
1. install 'web2py.app.fpdf.w2p'
2. Visit the 'default.py' controller page in the admin interface
3. Click the 'import_csv' action in the 'exposes' list

Traceback (most recent call last):
  File "/Users/lrivers/Documents/CurrentProjects/SPTI/trunk/web2py/gluon/restricted.py", line 188, in restricted
    exec ccode in environment
  File "/Users/lrivers/Documents/CurrentProjects/SPTI/trunk/web2py/applications/FPDF/controllers/default.py", line 326, in <module>
  File "/Users/lrivers/Documents/CurrentProjects/SPTI/trunk/web2py/gluon/globals.py", line 96, in <lambda>
    self._caller = lambda f: f()
  File "/Users/lrivers/Documents/CurrentProjects/SPTI/trunk/web2py/applications/FPDF/controllers/default.py", line 163, in import_csv
    f.parse_csv(infile="/home/reingart/web2py/gluon/contrib/pyfpdf/invoice.csv", delimiter=";", decimal_sep=",")
  File "/Users/lrivers/Documents/CurrentProjects/SPTI/trunk/web2py/gluon/contrib/pyfpdf/template.py", line 37, in parse_csv
    for row in csv.reader(open(infile, 'rb'), delimiter=delimiter):
IOError: [Errno 2] No such file or directory: 
'/home/reingart/web2py/gluon/contrib/pyfpdf/invoice.csv'

I would suggest putting that file in the 'static' directory of the appliance 
and calling it from there.

Original issue reported on code.google.com by [email protected] on 27 Nov 2010 at 8:10

Python 2.4 incompatibility

What steps will reproduce the problem?
1. try to inherit the Mixin class with Python 2.4

What is the expected output? What do you see instead?

The class would be instantiated with no errors.
But it thorws an invalide syntax error in the base class definition.
class HTMLMixin():


Original issue reported on code.google.com by yamandu.costa on 28 Sep 2010 at 11:28

The tag FONT has problems when configuring the color attribute

What steps will reproduce the problem?
1. fpdf.write_html('<font color="#ff00ff">que onda</font>')

What is the expected output? What do you see instead?
The text with color in the font

What version of the product are you using? On what operating system?
1.7.1, MACOSX

Please provide any additional information below.
The line 291 in the file fpdf/html.py has reference to a global variable named 
color, but it should be self.color

Code with the problem:
                self.set_text_color(*color)
                self.color = color

Code corrected:
                self.set_text_color(*self.color)
                self.color = self.color

Original issue reported on code.google.com by [email protected] on 11 Feb 2013 at 4:45

  • Merged into: #22

handle None value passed to write as empty string

Sometimes you just want to print objects that have properties that may be null 
(in my case printing fields from a django model) so having pyfpdf check for 
that and handle them as empty string would be nicer that having to add lot of 
checks for each field.

What steps will reproduce the problem?
1.  pdf.write(3, None);

What is the expected output? What do you see instead?
None handled like empty string. 

What version of the product are you using? On what operating system?
1.7


Original issue reported on code.google.com by [email protected] on 5 Jan 2013 at 11:24

Long text in table cells

1. Use write_html with a html table
2. Put long text in a table cell
3. The text is not shown entirely (truncated). 

Is there a way to show the whole text?


Original issue reported on code.google.com by [email protected] on 6 May 2011 at 3:55

tag th without attribute width (list index out of range)

What steps will reproduce the problem?
1 - generate a report containing a table, where the th tag, does not include 
the width attribute, the error will occur: 
"
  File ".../html.py", line 73, in handle_data
    l = [self.table_col_width[self.table_col_index]]
IndexError: list index out of range

"

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?
1.54b - 2010-09-10, Ubuntu 10.10

Please provide any additional information below.

I changed the expression: "if 'width' not in self.td and 'colspan' not in 
self.td:" to

"if 'width' not in self.td and 'colspan' not in self.td: and 
len(self.table_col_width) > 0 and not self.table_col_index > 
len(self.table_col_width) -1:
"

, and the error no longer occurs.

html used: 

"
<html>
    <body>
        <table>
            <thead>
                <tr>
                    <th>Id</th>
                    <th>Name</th>
                    <th>City</th>
                    <th>Birth date</th>
                </tr>
            </thead>
            <tbody>
                <tr class="even">
                    <td>1</td>
                    <td>Lucas</td>
                    <td>criciuma</td>
                    <td>2010-11-27</td>
                </tr>
                <tr class="odd">
                    <td>2</td>
                    <td>Lucas2</td>
                    <td></td>
                    <td></td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

"

Original issue reported on code.google.com by [email protected] on 28 Nov 2010 at 3:37

Dashed Line

I would appreceate it if a dashed line function would be included in the 
official release. A possible implementation would be:

    def dashed_line(self, x1,y1,x2,y2, on_length=1, off_length=1):
        self.setDash(on_length, off_length)
        self.line(x1, y1, x2, y2)
        self.setDash()

    def setDash(self, black=False, white=False):
        if(black and white):
            s = self.sprintf('[%.3f %.3f] 0 d', black*self.k, white*self.k)
        else:
            s = '[] 0 d'
        self._out(s)

    def sprintf(self, fmt, *args): return fmt % args


Adopted from FPDF Addon "Dashes": http://www.fpdf.de/downloads/addons/33/

Original issue reported on code.google.com by [email protected] on 18 Dec 2012 at 9:09

Web2py validation of fpdf template fields fails when validation for database is 'ALL'

What steps will reproduce the problem?
1. Copy the database templates to models in web2py
2. Add validation for 'ALL' databases 
3. launch web2py server

What is the expected output? What do you see instead?
"" Field is a reserved word. 
If you are iteratively solving the problem you will be able to find that the 
reserved words are: "type", "size" and "text". And this fields will not be 
accepted. It works correctly for sqlite, mysql and postgres


What version of the product are you using? On what operating system?
Last development version of web2py at today (28 january 2013)

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 28 Jan 2013 at 1:28

Tags in table cells start a new table cell

What steps will reproduce the problem?
1. <td>foo <b>bar</b></td>

What is the expected output? What do you see instead?
cell start - foo - bold bar - end cell

Actual output:
cell start - foo - end cell - cell start - bold bar - end cell


What version of the product are you using? On what operating system?

Don't know; Ubuntu


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 10 Feb 2013 at 2:40

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.