[reportlab-users] PDF File corrupt

1,188 views
Skip to first unread message

Dani Reguera

unread,
Dec 4, 2009, 6:06:47 AM12/4/09
to For users of Reportlab open source software
hi everybody!

I have the next problem and maybe anyone could help me,
I have created a pdf file with reportlab, and with the document viewer of Ubuntu, I can see the file, but the problem is where I try to open this file with adobe acrobat reader. It says me that the file is corrupted. How can I solve this? Anyone more have had the same problem? How gives me this message "File corrupted" if I can see with the document viewer of Ubuntu?

Any help would be appreciated,

Thanks.

--

Dani Reguera
dreg...@tagzania.com

Tagzania Services [www.tagzania-services.com]
Azitaingo Industrialdea 3 K
E-20600 Eibar
Tel: (+34) 943 82 17 80

Robin Becker

unread,
Dec 4, 2009, 6:20:03 AM12/4/09
to For users of Reportlab open source software
Dani Reguera wrote:
> hi everybody!
>
> I have the next problem and maybe anyone could help me,
> I have created a pdf file with reportlab, and with the document viewer of
> Ubuntu, I can see the file, but the problem is where I try to open this file
> with adobe acrobat reader. It says me that the file is corrupted. How can I
> solve this? Anyone more have had the same problem? How gives me this message
> "File corrupted" if I can see with the document viewer of Ubuntu?
>
> Any help would be appreciated,
>
> Thanks.
.......
did you copy the file or email it to get to the Acrobat Reader? My colleague is
using ubuntu + reportlab and can open reportlab pdfs with the linux version of
acrobat reader.
--
Robin Becker
_______________________________________________
reportlab-users mailing list
reportl...@lists2.reportlab.com
http://two.pairlist.net/mailman/listinfo/reportlab-users

Dani Reguera

unread,
Dec 4, 2009, 6:25:16 AM12/4/09
to For users of Reportlab open source software
I generated the pdf file with reportlab, then I choose "Open with..." and select "Acrobe REader" and gives me that error, all this with Ubuntu.
Also I have tested sending via e-mail and trying to open with Windows and gives me the same problem. File corrupted.



2009/12/4 Robin Becker <ro...@reportlab.com>

King Simon-NFHD78

unread,
Dec 4, 2009, 6:40:13 AM12/4/09
to For users of Reportlab open source software
> -----Original Message-----
> From: reportlab-u...@lists2.reportlab.com
> [mailto:reportlab-u...@lists2.reportlab.com] On
> Behalf Of Dani Reguera
> Sent: 04 December 2009 11:25
> To: For users of Reportlab open source software
> Subject: Re: [reportlab-users] PDF File corrupt
>
> I generated the pdf file with reportlab, then I choose "Open
> with..." and select "Acrobe REader" and gives me that error,
> all this with Ubuntu.
> Also I have tested sending via e-mail and trying to open with
> Windows and gives me the same problem. File corrupted.
>

Have you tried using a different font? I've had occasional problems with
PDFs apparently being corrupted when using the font "Arial Unicode MS".
When I try a different font, the problem goes away.

Hope that helps,

Simon

Dani Reguera

unread,
Dec 4, 2009, 6:42:20 AM12/4/09
to For users of Reportlab open source software
I have used Helvetica, and this is a predefinited, font... in getAvalaibleFonts() it appears.



2009/12/4 King Simon-NFHD78 <simon...@motorola.com>

Robin Becker

unread,
Dec 4, 2009, 6:42:19 AM12/4/09
to For users of Reportlab open source software
Dani Reguera wrote:
> I generated the pdf file with reportlab, then I choose "Open with..." and
> select "Acrobe REader" and gives me that error, all this with Ubuntu.
> Also I have tested sending via e-mail and trying to open with Windows and
> gives me the same problem. File corrupted.
.....
post a short example to the list that illustrates the problem.

Dani Reguera

unread,
Dec 4, 2009, 9:18:36 AM12/4/09
to For users of Reportlab open source software
Hi everybody!


>>>> post a short example to the list that illustrates the problem.

The problem is when I open the file with acrobat reader (In Win or in Linux). Reportlab generates the file well (I can see it with the document viewer) but I can open it with acrobat reader. The file is corrupted

"An error exists on this page. Acrobat does not display the page correctly. Please contact the person who created the PDF document to correct the problem"



2009/12/4 Robin Becker <ro...@reportlab.com>

Carl Karsten

unread,
Dec 4, 2009, 9:42:10 AM12/4/09
to For users of Reportlab open source software
Dani,

You should post either some python code that generates the pdf, and or the pdf.

--
Carl K

Dani Reguera

unread,
Dec 4, 2009, 9:53:30 AM12/4/09
to For users of Reportlab open source software
Here is the code:

from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import landscape,A4
from reportlab.pdfgen.textobject import PDFTextObject
from reportlab.lib.colors import HexColor
from reportlab.pdfbase import pdfmetrics

mycanvas = canvas.Canvas(SUBTITLE,pagesize=landscape(A4))

mycanvas.drawImage(styles['credits']['path'],int(styles['credits']['x'])*mm,int(styles['credits']['y'])*mm,width=int(styles['credits']['width'])*mm,height=int(styles['credits']['height'])*mm, mask='auto')

kk = canvas.textobject.PDFTextObject(mycanvas)
kk.setTextOrigin(x=0*mm,y=0*mm)
kk.textOut(text)

mycanvas.drawRightString(x*mm,y*mm,text)

mycanvas.showPage()
mycanvas.save()

2009/12/4 Carl Karsten <ca...@personnelware.com>

Robin Becker

unread,
Dec 4, 2009, 10:20:14 AM12/4/09
to For users of Reportlab open source software
Dani, thanks for the code, but I think we need to have a sample image that
actually causes a problem. I see nothing objectionable here, but we have seen
jpegs that cause a problem. Presumably SUBTITLE is the name of a file.
--
Robin Becker

Dani Reguera wrote:
> Here is the code:
>
> from reportlab.pdfgen import canvas
> from reportlab.lib.pagesizes import landscape,A4
> from reportlab.pdfgen.textobject import PDFTextObject
> from reportlab.lib.colors import HexColor
> from reportlab.pdfbase import pdfmetrics
>
> mycanvas = canvas.Canvas(SUBTITLE,pagesize=landscape(A4))
>
> mycanvas.drawImage(styles['credits']['path'],int(styles['credits']['x'])*mm,int(styles['credits']['y'])*mm,width=int(styles['credits']['width'])*mm,height=int(styles['credits']['height'])*mm,
> mask='auto')
>
> kk = canvas.textobject.PDFTextObject(mycanvas)
> kk.setTextOrigin(x=0*mm,y=0*mm)
> kk.textOut(text)
>
> mycanvas.drawRightString(x*mm,y*mm,text)
>
> mycanvas.showPage()
> mycanvas.save()
>

..........

Dani Reguera

unread,
Dec 4, 2009, 10:52:09 AM12/4/09
to For users of Reportlab open source software
It could be the images?? I have choosen 4 png images and added to the file and now seems that is not corrupted but I cant see them.

Now I can open the file but I see anything.

please help.


2009/12/4 Robin Becker <ro...@reportlab.com>

Andy Robinson

unread,
Dec 4, 2009, 10:55:47 AM12/4/09
to For users of Reportlab open source software
2009/12/4 Dani Reguera <dreg...@tagzania.com>:

> It could be the images?? I have choosen 4 png images and added to the file
> and now seems that is not corrupted but I cant see them.
>
> Now I can open the file but I see anything.
>

Can you try slightly resizing or changing the 4 images using some
well-known tool? e.g Gimp, Paint.NET, Photoshop.

We know that some 'buggy images' have confused Adobe Reader in the
past. I have even known images in PDFs to make a printing press
crash. Usually changing the image file fixes this.

Best Regards,
--
Andy

Dani Reguera

unread,
Dec 4, 2009, 10:59:23 AM12/4/09
to For users of Reportlab open source software
Andy thanks for your answer but i don't know why doens't work. I have 4 PNG images and two text "Helvetica".

PNG is not compatible with adobe acrobat?

Thanks,

2009/12/4 Andy Robinson <an...@reportlab.com>

Carl Karsten

unread,
Dec 4, 2009, 11:08:56 AM12/4/09
to For users of Reportlab open source software
png is compatible, assuming it is a proper png.

Try using this png:

http://www.reportlab.org/media/imadj/data/RLIMG_6845acae97ac366a765e5acb5b8ac27f.PNG

--
Carl K

Dani Reguera

unread,
Dec 4, 2009, 11:20:25 AM12/4/09
to For users of Reportlab open source software
I have tried with the png and the same problem. I can see it in the document viewer but in adobe acrobat reader not.

What could be the problem? I don't kwnow why. may be it's incompatible?

thanks for your answers.

2009/12/4 Carl Karsten <ca...@personnelware.com>

Andy Robinson

unread,
Dec 4, 2009, 12:47:34 PM12/4/09
to For users of Reportlab open source software
2009/12/4 Dani Reguera <dreg...@tagzania.com>:

> Andy thanks for your answer but i don't know why doens't work. I have 4 PNG
> images and two text "Helvetica".
>
> PNG is not compatible with adobe acrobat?

I am saying that it is possible to create a 'buggy PNG' which may view
OK in some tools but not others. To eliminate this possibility, use
some well known image library to change them. If you converted from
PNG to GIF and back to PNG again, saving each time, and it worked
afterwards, you'd know there was a fault with the original image.

We're closing the office now for the weekend, but if this does not
work and you can send us your PNGs or put them somewhere we can see
them, we will take a look on monday.

- Andy

Tim Roberts

unread,
Dec 4, 2009, 2:03:53 PM12/4/09
to For users of Reportlab open source software
Dani Reguera wrote:
> I have tried with the png and the same problem. I can see it in the
> document viewer but in adobe acrobat reader not.
>
> What could be the problem? I don't kwnow why. may be it's incompatible?

Look, none of us are mind readers!!! The rest of create many, many,
many PDFs every day that all work fine. We cannot possibly help you
unless you send us a PDF file that doesn't work, and/or runnable Python
code to create a file that fails. The code you sent was NOT runnable,
because the names "SUBTITLE" and "styles" were not defined.

Can't you see how frustrating it is for you to say "Reportlab generates
corrupted PDF files. Why?" That question cannot possibly be answered.

--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Onur Tuna

unread,
Dec 5, 2009, 4:48:21 AM12/5/09
to reportlab-users
i want to make a file from a text edit. but an error occured when a new line exists. in pdf file the text is seen as one line. anybody to help?

Dani Reguera

unread,
Dec 5, 2009, 12:44:51 PM12/5/09
to reportlab-users
Hi everybody!
First of all I have never said that Reportlab generates corrupted files. REportlab works fine, I have been using reportlab during a year for all my projects and I have never had a problem with this fantastic library.

The only problem that I have is that I generated a file with images with reportlab and i can see in document viewer well. This file is OK it has all the images and strings that I want. The only problem is that this file when I try to open with Adobe Acrobat reader, says me that is corrupted. Not more.

I will send you the code and the PDF file to let you see this trouble.

Thank you a lot for your help and your answers.

2009/12/4 Tim Roberts <ti...@probo.com>

Dani

Gabe Black

unread,
Dec 5, 2009, 7:55:34 PM12/5/09
to reportlab-users
On Sat, Dec 5, 2009 at 3:48 AM, Onur Tuna <tuna...@yahoo.com> wrote:
> i want to make a file from a text edit. but an error occured when a new line
> exists. in pdf file the text is seen as one line. anybody to help?

There are a variety of ways you could handle it. If you are using
platypus you can replace newlines with a break, a new paragraph
flowable, etc.

If you aren't using platypus, try doing a python split on the newline
and then write a new line for each element in your array of text
lines.

Reply all
Reply to author
Forward
0 new messages