[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Python PDF + Pictures

durumdara

3/11/2008 9:00:00 AM

Hi, dear Python Masters!

I wanna ask about the Python and PDF creating.

I have many photos, and I wanna make some "presentation" from these
photos, a "thumbnail" like document with one image per one page.

If I wanna make one document now I do this:
I execute a python script that create a html site with resized pictures,
and split this html site to 50 images per one html file.
Next I open these files in OpenOffice Writer by hand, and save them as
PDF document with poor quality (image compression 95%, image DPI 75).
This generates a medium sized PDF documents (2,5 - 5,6 MB for each) that
can opened everywhere (because of PDF format).

But I wanna automatize this process with python.
The technic that I will use is this:
1.) Collect the files in dirs.
2.) I process one dir in one time.
3.) I get the files.
4.) I resize them to max. 1024/768.
5.) I put the actual image file to the PDF document.
6.) After each 50. file I open new numbered PDF.
7.) Every picture placed in one page, and every page orientation set up
as the picture orientation (Portrait or Landscape).

The PDF must be parameterized to image compression 95%, and 75 or 96 DPI.

Do you knows about a PDF maker library with I can make this thing?

Or other technic to simplify the making?

Thanks for your help!
dd


5 Answers

Bruno Desthuilliers

3/11/2008 11:32:00 AM

0

durumdara@gmail.com a écrit :
> Hi, dear Python Masters!
>
> I wanna ask about the Python and PDF creating.
>
> I have many photos, and I wanna make some "presentation" from these
> photos, a "thumbnail" like document with one image per one page.
>
> If I wanna make one document now I do this:
> I execute a python script that create a html site with resized pictures,
> and split this html site to 50 images per one html file.
> Next I open these files in OpenOffice Writer by hand, and save them as
> PDF document with poor quality (image compression 95%, image DPI 75).
> This generates a medium sized PDF documents (2,5 - 5,6 MB for each) that
> can opened everywhere (because of PDF format).
>
> But I wanna automatize this process with python.
> The technic that I will use is this:
> 1.) Collect the files in dirs.
> 2.) I process one dir in one time.
> 3.) I get the files.
> 4.) I resize them to max. 1024/768.
> 5.) I put the actual image file to the PDF document.
> 6.) After each 50. file I open new numbered PDF.
> 7.) Every picture placed in one page, and every page orientation set up
> as the picture orientation (Portrait or Landscape).
>
> The PDF must be parameterized to image compression 95%, and 75 or 96 DPI.
>
> Do you knows about a PDF maker library with I can make this thing?
>
> Or other technic to simplify the making?

Dont know if this will match your needs, but you may want to have a look
at pisa:
http://www.html...

Stefan Behnel

3/11/2008 11:45:00 AM

0

durumdara@gmail.com wrote:
> I have many photos, and I wanna make some "presentation" from these
> photos, a "thumbnail" like document with one image per one page.
>
> If I wanna make one document now I do this:
> I execute a python script that create a html site with resized pictures,
> and split this html site to 50 images per one html file.
> Next I open these files in OpenOffice Writer by hand, and save them as
> PDF document with poor quality (image compression 95%, image DPI 75).
> This generates a medium sized PDF documents (2,5 - 5,6 MB for each) that
> can opened everywhere (because of PDF format).
>
> But I wanna automatize this process with python.
> The technic that I will use is this:
> 1.) Collect the files in dirs.
> 2.) I process one dir in one time.
> 3.) I get the files.
> 4.) I resize them to max. 1024/768.
> 5.) I put the actual image file to the PDF document.
> 6.) After each 50. file I open new numbered PDF.
> 7.) Every picture placed in one page, and every page orientation set up
> as the picture orientation (Portrait or Landscape).
>
> The PDF must be parameterized to image compression 95%, and 75 or 96 DPI.

PIL can write PDFs, and it's clearly a good choice for image processing.

http://www.pythonware.com/pro...

Stefan

durumdara

3/11/2008 11:53:00 AM

0

Hi!

Bruno Desthuilliers wrote:
> durumdara@gmail.com a écrit :
>> Hi, dear Python Masters!
>>
>> I wanna ask about the Python and PDF creating.
> Dont know if this will match your needs, but you may want to have a look
> at pisa:
> http://www.html...
>

With HTML I have only one problem.
The HTML is not page specific language.
But I wanna use pages (for example: A4) with diff. orientation to show
images correctly.

But I try it if possible.

Thanks for your help:
dd

jocknerd

3/11/2008 3:45:00 PM

0

On Mar 11, 5:00 am, "durumd...@gmail.com" <durumd...@gmail.com> wrote:
> Hi, dear Python Masters!
>
> I wanna ask about the Python and PDF creating.
>
> I have many photos, and I wanna make some "presentation" from these
> photos, a "thumbnail" like document with one image per one page.
>
> If I wanna make one document now I do this:
> I execute a python script that create a html site with resized pictures,
> and split this html site to 50 images per one html file.
> Next I open these files in OpenOffice Writer by hand, and save them as
> PDF document with poor quality (image compression 95%, image DPI 75).
> This generates a medium sized PDF documents (2,5 - 5,6 MB for each) that
> can opened everywhere (because of PDF format).
>
> But I wanna automatize this process with python.
> The technic that I will use is this:
> 1.) Collect the files in dirs.
> 2.) I process one dir in one time.
> 3.) I get the files.
> 4.) I resize them to max. 1024/768.
> 5.) I put the actual image file to the PDF document.
> 6.) After each 50. file I open new numbered PDF.
> 7.) Every picture placed in one page, and every page orientation set up
> as the picture orientation (Portrait or Landscape).
>
> The PDF must be parameterized to image compression 95%, and 75 or 96 DPI.
>
> Do you knows about a PDF maker library with I can make this thing?
>
> Or other technic to simplify the making?
>
> Thanks for your help!
> dd

You might also want to take a look at ReportLab. Its a PDF library
for Python. You can find it at http://www.repo...

Project Mangler

3/27/2010 12:35:00 PM

0

Raj,

I'm till not sure what your target cell should look like but here are two
ideas:

Remove the single quote, retain the = but accept #NAME errors:
Sub Cleancolumn1()
For i = 1 To ThisWorkbook.Worksheets("Sheet1").Cells _
(Rows.Count, 14).End(xlUp).Row
Cells(i, 14) = Cells(i, 14).Value
Next i
End Sub


Remove the single quote, retain =, display without name error:
This means for a string like '123 yiu will end up with ="123"
I have no idea if this is acceptable.

Sub Cleancolumn2()
Dim A As String
Dim B As Long
For i = 1 To ThisWorkbook.Worksheets("Sheet1").Cells _
(Rows.Count, 14).End(xlUp).Row
A = Cells(i, 14)
B = Len(A)
Select Case B
Case 0
'do nothing
Case 1
'paste whatever is there
Cells(i, 14) = Cells(i, 14).Value
Case Is >= 2
If Left(Cells(i, 14), 1) = "=" Then
A = Right(Cells(i, 14), B - 1)
ThisWorkbook.Worksheets("Sheet1").Cells(i, 14) = "=" & A
ThisWorkbook.Worksheets("Sheet1").Cells(i, 14) = "=" & Chr(34) & A & Chr(34)
Else
Cells(i, 14) = Cells(i, 14).Value
End If
End Select
Next i
End Sub





"Raj" <rspai9@gmail.com> wrote in message
news:e44e445f-56fd-4693-843c-bfd5d2aed3e6@n20g2000prh.googlegroups.com...
I want to remove the apostrophe but retain the =

Regards,
Raj


On Mar 26, 8:30 pm, "Project Mangler" <dbl...@ntlworld.com> wrote:
> Raj,
>
> I see the point of the single quote.
>
> If you remove it and paste the truncated string back into the cell you
will
> get the name error again? Is this what you are trying to achieve or should
> you remove the = as well?
>
> DB
>
> "Raj" <rsp...@gmail.com> wrote in message
>
> news:f558f9d9-a4e6-46de-ad73-f9c37755a786@x11g2000prb.googlegroups.com...
> Maybe this information will throw light on the underlying problem and
> also help me with a solution:
>
> Column 14 which is being cleaned has some cells beginning with an
> apostrophe and an = sign. eg. '=KKRRNN
> This has been done obviously because without the apostrophe Excel
> treats the string as a formula and shows a Name error because it does
> not understand the gibberish following the equal to sign.
> The code was written to remove the apostrophe where one existed. I am
> wondering whether the problem is occurring because string without the
> apostrophe becomes a formula.
>
> Please examine and also let me know any other way to get rid of the
> leading apostrophe in a string in a cell.
>
> Thanks in Advance.
>
> Regards,
> Raj
>
> On Mar 26, 3:54 pm, "Project Mangler" <dbl...@ntlworld.com> wrote:
>
> > Raj,
>
> > I can't duplicate your error here, the code works OK if I try to detect
a
> > haracter other than "'" .
>
> > I'm wondering how you are going to detect a single quote at the start of
a
> > string? e.g.
>
> > If Left(Cells(i, 4), 1) = "'" Then
> > MsgBox "Apostrophe!"
> > Else
> > MsgBox "No Apostrophe!"
> > End If
>
> > The above line copied from your post gives me No Apostrophe.
>
> > In a cell containing the string 'Length I get a Len() of 6.
>
> > DB
>
> > "Raj" <rsp...@gmail.com> wrote in message
>
> >news:9aab4b9b-9698-4667-84cf-6dda14d15489@g1g2000pre.googlegroups.com...
>
> > > Hi,
>
> > > When I run the following code, I am getting the Application or object
> > > defined error. The second line is a single line in my code. The VBE
> > > highlights the portion after "Then" in the second line.
>
> > > Sub Cleancolumn1()
> > > For i = 1 To ThisWorkbook.Worksheets("Sheet1").Cells(Rows.Count,
> > > 14).End(xlUp).Row
> > > If Left(Cells(i, 14), 1) = "'" Then
> > > ThisWorkbook.Worksheets("Sheet1").Cells(i, 14) = Right(Cells(i, 14),
> > > Len(Cells(i, 14)) - 1)
> > > Next i
> > > End Sub
>
> > > What is going wrong?
>
> > > Thanks in advance for the help.
>
> > > Regards,
> > > Raj