f



Postscript to pdf

Hello,

I'm doing a software to make an id card for a school club so i used TKINTER to make this software.
So i can enter details like name, student number etc..

So finally i got a Postscript file the problem is that i want to make a pdf file do you have any ideas? "convert ps to pdf"

Thank u
regards
0
Bala
9/20/2015 4:20:10 PM
comp.lang.python 77058 articles. 6 followers. Post Follow

16 Replies
1077 Views

Similar Articles

[PageSpeed] 45

In a message of Sun, 20 Sep 2015 09:20:10 -0700, Bala Ji writes:
>Hello,
>
>I'm doing a software to make an id card for a school club so i used TKINT=
ER to make this software.
>So i can enter details like name, student number etc..
>
>So finally i got a Postscript file the problem is that i want to make a p=
df file do you have any ideas? "convert ps to pdf"
>
>Thank u
>regards

There is a free program that does this called ps2pdf  which is
available for linux, windows and mac os.

Laura 
0
Laura
9/20/2015 4:40:18 PM
Thank u laura,
I tired it but the problem when i use it there is only half of the image 
its like the software cut the image
0
Bala
9/20/2015 4:50:02 PM
In a message of Sun, 20 Sep 2015 09:50:02 -0700, Bala Ji writes:
>Thank u laura,
>I tired it but the problem when i use it there is only half of the image 
>its like the software cut the image
>-- 
>https://mail.python.org/mailman/listinfo/python-list

Ok.  We need more information.
What OS are you using?
What version of ps2pdf did you use, and where did you get it?

The next thing we need to find out is whether your ps file contained
all the infomation, or whether you lost data before you tried to
convert it to a pdf.  Do you know?  Have you seen your ps file
and are sure it is ok?

We will get this to work.

Laura
0
Laura
9/20/2015 6:12:33 PM
Hello,

I'm using macosx, ps2pdf version i don't know :/ sorry....
ok actually i found what is the problem...

There is no problem with the ps file every thing is fine =3D)

Can u please just tell me how to change paper settings ?
i want to go from portait to landscape ?



2015-09-20 20:12 GMT+02:00 Laura Creighton <lac@openend.se>:
> In a message of Sun, 20 Sep 2015 09:50:02 -0700, Bala Ji writes:
>>Thank u laura,
>>I tired it but the problem when i use it there is only half of the image
>>its like the software cut the image
>>--
>>https://mail.python.org/mailman/listinfo/python-list
>
> Ok.  We need more information.
> What OS are you using?
> What version of ps2pdf did you use, and where did you get it?
>
> The next thing we need to find out is whether your ps file contained
> all the infomation, or whether you lost data before you tried to
> convert it to a pdf.  Do you know?  Have you seen your ps file
> and are sure it is ok?
>
> We will get this to work.
>
> Laura



--=20
KICHENASSAMY Baladjy
Ing=C3=A9nieur en G=C3=A9nie M=C3=A9canique
Sp=C3=A9cialiste Contr=C3=B4le Non Destructif et Qualification des proc=C3=
=A9d=C3=A9s sp=C3=A9ciaux
COSAC CND Niveau 2 RT et PT
Aircelle SAFRAN
Tel:06.03.72.53.12
0
Baladjy
9/20/2015 6:27:48 PM
In a message of Sun, 20 Sep 2015 20:27:48 +0200, Baladjy KICHENASSAMY writes:
>Hello,
>
>I'm using macosx, ps2pdf version i don't know :/ sorry....
>ok actually i found what is the problem...
>
>There is no problem with the ps file every thing is fine =)
>
>Can u please just tell me how to change paper settings ?
>i want to go from portait to landscape ?
>

Aha!  Great to know.
Do you have a real printer there, in which case is this a printer problem?
If so, I need the name of the printer and its model number to help look up
the way to make it do landscape.

If you just want to have ps2pdf produce landscape files, that is
surprisingly difficult, for the ps2pdf that uses ghostscript to
get the work done.  ps2pdf 'guesses' what is the correct orientation
and, stupidly, there is no way to tell it 'stop guessing, I know
what I want'.  It's very bad at guessing things that don't have
text -- or enough text -- in them.

Most of the time ps2pdf is just this:

gs \
  -o output.pdf \
  -sDEVICE=pdfwrite \
  -dPDFSETTINGS=/prepress \
  -dHaveTrueTypes=true \
  -dEmbedAllFonts=true \
  -dSubsetFonts=false \
  -c ".setpdfwrite <</NeverEmbed [ ]>> setdistillerparams" \
  -f input.ps

where input.ps is the file you have and output.pdf is the pdf you want.
and we can make gs orient itself as you want with

    -c "<</Orientation 3>> setpagedevice"

Orientation 3 is landscape.  Orientation 0 is portrait.

If this is your problem, then see if you have gs (ghostscript)
and in that case see if this horrible long command works.

Laura

0
Laura
9/20/2015 7:09:03 PM
ohhhh ok i got it
actually it's very easy the commande is :
ps2pdf -dEPSCrop image.ps

sorry but i'm new to python  my last question is how to integrate this
to python... i want that the output file must be a pdf ?

1) i created a button which i'll save my id card as "ps" file

def save():
    Canevas.update()
    Canevas.postscript(file=3DtkFileDialog.asksaveasfilename(), colormode=
=3D'color')


2) so now i want to create a button to convert this "ps" file into "pdf" ..=
...

def convert():
   help :/

Regards




2015-09-20 21:09 GMT+02:00 Laura Creighton <lac@openend.se>:
> In a message of Sun, 20 Sep 2015 20:27:48 +0200, Baladjy KICHENASSAMY wri=
tes:
>>Hello,
>>
>>I'm using macosx, ps2pdf version i don't know :/ sorry....
>>ok actually i found what is the problem...
>>
>>There is no problem with the ps file every thing is fine =3D)
>>
>>Can u please just tell me how to change paper settings ?
>>i want to go from portait to landscape ?
>>
>
> Aha!  Great to know.
> Do you have a real printer there, in which case is this a printer problem=
?
> If so, I need the name of the printer and its model number to help look u=
p
> the way to make it do landscape.
>
> If you just want to have ps2pdf produce landscape files, that is
> surprisingly difficult, for the ps2pdf that uses ghostscript to
> get the work done.  ps2pdf 'guesses' what is the correct orientation
> and, stupidly, there is no way to tell it 'stop guessing, I know
> what I want'.  It's very bad at guessing things that don't have
> text -- or enough text -- in them.
>
> Most of the time ps2pdf is just this:
>
> gs \
>   -o output.pdf \
>   -sDEVICE=3Dpdfwrite \
>   -dPDFSETTINGS=3D/prepress \
>   -dHaveTrueTypes=3Dtrue \
>   -dEmbedAllFonts=3Dtrue \
>   -dSubsetFonts=3Dfalse \
>   -c ".setpdfwrite <</NeverEmbed [ ]>> setdistillerparams" \
>   -f input.ps
>
> where input.ps is the file you have and output.pdf is the pdf you want.
> and we can make gs orient itself as you want with
>
>     -c "<</Orientation 3>> setpagedevice"
>
> Orientation 3 is landscape.  Orientation 0 is portrait.
>
> If this is your problem, then see if you have gs (ghostscript)
> and in that case see if this horrible long command works.
>
> Laura
>



--=20
KICHENASSAMY Baladjy
Ing=C3=A9nieur en G=C3=A9nie M=C3=A9canique
Sp=C3=A9cialiste Contr=C3=B4le Non Destructif et Qualification des proc=C3=
=A9d=C3=A9s sp=C3=A9ciaux
COSAC CND Niveau 2 RT et PT
Aircelle SAFRAN
Tel:06.03.72.53.12
0
Baladjy
9/20/2015 7:32:34 PM
In a message of Sun, 20 Sep 2015 21:32:34 +0200, Baladjy KICHENASSAMY writ=
es:
>ohhhh ok i got it
>actually it's very easy the commande is :
>ps2pdf -dEPSCrop image.ps
>
>sorry but i'm new to python  my last question is how to integrate this
>to python... i want that the output file must be a pdf ?
>
>1) i created a button which i'll save my id card as "ps" file
>
>def save():
>    Canevas.update()
>    Canevas.postscript(file=3DtkFileDialog.asksaveasfilename(), colormode=
=3D'color')

>2) so now i want to create a button to convert this "ps" file into "pdf" =
.....
>
>def convert():
>   help :/

You need to run the subprocess module to run your command.
https://docs.python.org/2/library/subprocess.html  (for python 2)
https://docs.python.org/3.4/library/subprocess.html (for python 3)

is this enough or do you need more help getting it to work?

Laura

0
Laura
9/20/2015 7:52:43 PM
well one more question :/

i tried this

def save():
     Canevas.update()
     Canevas.postscript(file=3DtkFileDialog.asksaveasfilename(),
colormode=3D'color')
     subprocess.call(["ps2pdf", "-dEPSCrop", "test.ps", "test.pdf"])


i got the ps file but i didn't get the pdf file :/

2015-09-20 21:52 GMT+02:00 Laura Creighton <lac@openend.se>:
> In a message of Sun, 20 Sep 2015 21:32:34 +0200, Baladjy KICHENASSAMY wri=
tes:
>>ohhhh ok i got it
>>actually it's very easy the commande is :
>>ps2pdf -dEPSCrop image.ps
>>
>>sorry but i'm new to python  my last question is how to integrate this
>>to python... i want that the output file must be a pdf ?
>>
>>1) i created a button which i'll save my id card as "ps" file
>>
>>def save():
>>    Canevas.update()
>>    Canevas.postscript(file=3DtkFileDialog.asksaveasfilename(), colormode=
=3D'color')
>
>>2) so now i want to create a button to convert this "ps" file into "pdf" =
.....
>>
>>def convert():
>>   help :/
>
> You need to run the subprocess module to run your command.
> https://docs.python.org/2/library/subprocess.html  (for python 2)
> https://docs.python.org/3.4/library/subprocess.html (for python 3)
>
> is this enough or do you need more help getting it to work?
>
> Laura
>



--=20
KICHENASSAMY Baladjy
Ing=C3=A9nieur en G=C3=A9nie M=C3=A9canique
Sp=C3=A9cialiste Contr=C3=B4le Non Destructif et Qualification des proc=C3=
=A9d=C3=A9s sp=C3=A9ciaux
COSAC CND Niveau 2 RT et PT
Aircelle SAFRAN
Tel:06.03.72.53.12
0
Baladjy
9/20/2015 9:11:20 PM
In a message of Sun, 20 Sep 2015 23:11:20 +0200, Baladjy KICHENASSAMY writes:
>well one more question :/
>
>i tried this
>
>def save():
>     Canevas.update()
>     Canevas.postscript(file=tkFileDialog.asksaveasfilename(),
>colormode='color')
>     subprocess.call(["ps2pdf", "-dEPSCrop", "test.ps", "test.pdf"])
>
>
>i got the ps file but i didn't get the pdf file :/

It's 00:41 here in Sweden, and I have an 08:00 meeting.  I am off to bed.
Perhaps somebody else can help now, otherwise I will be back
tomorrow.

I've never tried to get subprocess to run as part of a savefile dialog.
Try building a tkinter app that takes a filename argument (somepostscript
file you have lying around) and then push the button, in the same dir
makes a pdf of your ps using subprocess.

If that works, then see about getting save to run that subprocess as
part of the save process.  I am very curious about whether that can
be done -- but first check that your subprocess is working, period.
The wretched thing is slightly different between windows and linux,
and even between different linuxes, so needing to fiddle a bit here is
normal (and frustrating).

So right now I cannot tell if your problem is 'save doesn't like
it like that' or 'your subprocess isn't working'.

But nothing in Tkinter likes 'Canevas' -- (which is great French
but rotten English) you must have written Canvas in your code.

Paste the real thing in next time, ok?

Sorry I am off now,
Laura
0
Laura
9/20/2015 10:50:12 PM
On Sun, 20 Sep 2015 21:52:43 +0200, Laura Creighton <lac@openend.se>
declaimed the following:

>In a message of Sun, 20 Sep 2015 21:32:34 +0200, Baladjy KICHENASSAMY writes:
>>ohhhh ok i got it
>>actually it's very easy the commande is :
>>ps2pdf -dEPSCrop image.ps
>>
>>sorry but i'm new to python  my last question is how to integrate this
>>to python... i want that the output file must be a pdf ?
>>
>>1) i created a button which i'll save my id card as "ps" file
>>
>>def save():
>>    Canevas.update()
>>    Canevas.postscript(file=tkFileDialog.asksaveasfilename(), colormode='color')
>
>>2) so now i want to create a button to convert this "ps" file into "pdf" ....
>>
>>def convert():
>>   help :/
>
>You need to run the subprocess module to run your command.
>https://docs.python.org/2/library/subprocess.html  (for python 2)
>https://docs.python.org/3.4/library/subprocess.html (for python 3)
>
>is this enough or do you need more help getting it to work?
>
>Laura


	At this point one begins to wonder if, since PDF is the desired end
product, it might not be better to redo the effort targeting the use of
ReportLab rather than the round-about PS to PDF conversion?
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

0
Dennis
9/21/2015 12:25:02 AM
On 9/20/2015 12:20 PM, Bala Ji wrote:
> Hello,
>
> I'm doing a software to make an id card for a school club so i used
> TKINTER to make this software. So i can enter details like name,
> student number etc..
>
> So finally i got a Postscript file the problem is that i want to make
> a pdf file do you have any ideas? "convert ps to pdf"

Where does the .ps file come from?  tkinter canvas to .ps?  If so, I 
suggest not to do that.  Get reportlab or another python pdf generator 
(search pypi.python.org for 'pdf' or web for 'python generate pdf'.)

-- 
Terry Jan Reedy

0
Terry
9/21/2015 4:17:47 AM
On Sun, 20 Sep 2015 23:11:20 +0200, Baladjy KICHENASSAMY wrote:

> i tried this
> 
> def save():
>      Canevas.update()
>      Canevas.postscript(file=tkFileDialog.asksaveasfilename(),
> colormode='color')
>      subprocess.call(["ps2pdf", "-dEPSCrop", "test.ps", "test.pdf"])
> 
> 
> i got the ps file but i didn't get the pdf file :/

Check that subprocess.call() returns zero, or use subprocess.check_output()
instead. Also, if this is a GUI program and you have no easy way to check
what is written to stdout or stderr, try:

    p = subprocess.Popen(["ps2pdf", "-dEPSCrop", "test.ps", "test.pdf"],
                         stderr=subprocess.PIPE)
    out, err = p.communicate()
    if p.returncode != 0:
        raise RuntimeError(err)

0
Nobody
9/21/2015 12:56:29 PM
Am 20.09.15 um 20:27 schrieb Baladjy KICHENASSAMY:
> Hello,
>
> I'm using macosx, ps2pdf version i don't know :/ sorry....
> ok actually i found what is the problem...
>
> There is no problem with the ps file every thing is fine =)


You could try

ps2pdf -dEPSCrop input.ps output.pdf

that should create a PDF with the papersize derived from an EPS image.

	Christian
0
Christian
9/21/2015 1:39:25 PM
Hello,
This is my programe : on mac i was able to output ps file but i didn't
got the pdf file :/

# -*- coding: utf-8 -*-
# script lecture_gif.py
from Tkinter import *
import tkMessageBox
import Tkconstants
import tkFileDialog
from PIL import ImageTk
import PIL.Image
import os, sys
import subprocess


def Ouvrir():
    Canevas.delete(ALL) # on efface la zone graphique

    filename =3D tkFileDialog.askopenfilename(title=3D"Ouvrir une
image",filetypes=3D[('gif files','.gif'),('all files','.*')])
    print(filename)
    photo =3D PhotoImage(file=3Dfilename)
    gifdict[filename] =3D photo  # r=C3=A9f=C3=A9rence
    print(gifdict)

    Canevas.create_image(0,0,anchor=3DNW,image=3Dphoto)
    Canevas.config(height=3Dphoto.height(),width=3Dphoto.width())

    Mafenetre.title("Image "+str(photo.width())+" x "+str(photo.height()))

def insertimage():
n=3DtkFileDialog.askopenfilename(filetypes =3D [("Image Files", ("*.jpg",
"*.gif")),("JPEG",'*.jpg'),("GIF",'*.gif'),('All','*')])
img =3D PIL.Image.open(n)
img =3D img.resize((229, 253))
photoimg =3D ImageTk.PhotoImage(img)
label =3D Label(image=3Dphotoimg)
label.image =3D photoimg # keep a reference!
Canevas.create_image(65,320,anchor=3DW,image =3D photoimg)
def insertsign():
n=3DtkFileDialog.askopenfilename(filetypes =3D [("Image Files", ("*.jpg",
"*.gif")),("JPEG",'*.jpg'),("GIF",'*.gif'),('All','*')])
img =3D PIL.Image.open(n)
img =3D img.resize((300, 100))
photoimg =3D ImageTk.PhotoImage(img)
Canevas.create_image(600,500,anchor=3DW,image =3D photoimg)
Canvas.pack()

def Fermer():
    Canevas.delete(ALL)
    Mafenetre.title("Image")

def save():
Canevas.update()
Canevas.postscript(file=3DtkFileDialog.asksaveasfilename(), colormode=3D'co=
lor')
subprocess.call(["ps2pdf", "-dEPSCrop", "test.ps", "test.pdf"])

# def convert():
# ps2pdf -dEPSCrop image.ps
# convert -density 300 PASSPORTQUALITE.ps output.png

# class TkFileDialogExample(Tkinter.Frame):
#
#     def __init__(self, root):
#
#         Tkinter.Frame.__init__(self, root)
#         button_opt =3D {'fill': Tkconstants.BOTH, 'padx': 5, 'pady': 5}
#         Tkinter.Button(self, text=3D'Save',
command=3Dself.asksaveasfilename).pack(**button_opt)
#
#         self.file_opt =3D options =3D {}
#         options['filetypes'] =3D [('all files', '.*'), ('text files', '.t=
xt')]
#         options['initialfile'] =3D 'myfile.txt'
#         options['parent'] =3D root
#
#     def asksaveasfilename(self):
#         filename =3D tkFileDialog.asksaveasfilename(**self.file_opt)
#
#         if filename:
#             return open(filename, 'w')
#
# if __name__=3D=3D'__main__':
#     root =3D Tkinter.Tk()
#     TkFileDialogExample(root).pack()
#     root.mainloop()
def Apropos():
    tkMessageBox.showinfo("A propos","Tutorial")

def Write():
def delete():
e1.delete(0,END)
e2.delete(0,END)
e3.delete(0,END)
e4.delete(0,END)
e5.delete(0,END)
e6.delete(0,END)
Canevas.delete("e1")
def valider():
Canevas.create_text(315,200,anchor=3DW,text=3D"Surname/Nom",fill=3D'Black',=
font=3D'Arial
14')
Canevas.create_text(315,220,anchor=3DW,text=3De1.get(),fill=3D'Black',font=
=3D'Arial
30',tags =3D"e1")
Canevas.create_text(315,250,anchor=3DW,text=3D"Given
name/Pr=C3=A9nom",fill=3D'Black',font=3D'Arial 14')
Canevas.create_text(315,270,anchor=3DW,text=3De2.get(),fill=3D'Black',font=
=3D'Arial
30',tags =3D"e1")
Canevas.create_text(315,300,anchor=3DW,text=3D"Fonction/Function",fill=3D'B=
lack',font=3D'Arial
14')
Canevas.create_text(315,320,anchor=3DW,text=3De3.get(),fill=3D'Black',font=
=3D'Arial
30',tags =3D"e1")
Canevas.create_text(470,395,anchor=3DW,text=3De4.get(),fill=3D'Black',font=
=3D'Arial
30',tags =3D"e1")
Canevas.create_text(500,438,anchor=3DW,text=3De5.get(),fill=3D'Black',font=
=3D'Arial
30',tags =3D"e1")
Canevas.create_text(228,503,anchor=3DW,text=3De6.get(),fill=3D'Black',font=
=3D'Arial
30',tags =3D"e1")
master =3D Tk()
Label(master, text=3D"Surname/Nom").grid(row=3D0)
Label(master, text=3D"Given name/Pr=C3=A9nom").grid(row=3D1)
Label(master, text=3D"Fonction/Function").grid(row=3D2)
Label(master, text=3D"Validity Date").grid(row=3D3)
Label(master, text=3D"Chef").grid(row=3D4)
Label(master, text=3D"Student number").grid(row=3D5)
e1 =3D Entry(master)
e2 =3D Entry(master)
e3 =3D Entry(master)
e4 =3D Entry(master)
e5 =3D Entry(master)
e6 =3D Entry(master)
e1.grid(row=3D0, column=3D1)
e2.grid(row=3D1, column=3D1)
e3.grid(row=3D2, column=3D1)
e4.grid(row=3D3, column=3D1)
e5.grid(row=3D4, column=3D1)
e6.grid(row=3D5, column=3D1)
Button(master, text=3D'Ok', command=3Dvalider).grid(row=3D2, column=3D2,
sticky=3DW, pady=3D4)
Button(master, text=3D'Delete', command=3Ddelete).grid(row=3D3, column=3D2,
sticky=3DW, pady=3D4)
mainloop( )

# Main window
Mafenetre =3D Tk()
Mafenetre.title("Image")

# Cr=C3=A9ation d'un widget Menu
menubar =3D Menu(Mafenetre)

menufichier =3D Menu(menubar,tearoff=3D0)
menufichier.add_command(label=3D"Open mask",command=3DOuvrir)
menufichier.add_command(label=3D"Save mask",command=3Dsave)
#menufichier.add_command(label=3D"Convert pdf",command=3Dconvert)
menufichier.add_command(label=3D"Close mask",command=3DFermer)
menufichier.add_command(label=3D"Quit",command=3DMafenetre.destroy)
menubar.add_cascade(label=3D"File", menu=3Dmenufichier)

menuwrite =3D Menu(menubar,tearoff=3D0)
menuwrite.add_command(label=3D"Insert informations",command=3DWrite)
menuwrite.add_command(label=3D"Insert image",command=3Dinsertimage)
menuwrite.add_command(label=3D"Insert signature",command=3Dinsertsign)
menubar.add_cascade(label=3D"Informations", menu=3Dmenuwrite)


menuaide =3D Menu(menubar,tearoff=3D0)
menuaide.add_command(label=3D"A propos",command=3DApropos)
menubar.add_cascade(label=3D"Aide", menu=3Dmenuaide)

# Affichage du menu
Mafenetre.config(menu=3Dmenubar)

# Cr=C3=A9ation d'un widget Canvas
Canevas =3D Canvas(Mafenetre)
Canevas.pack(padx=3D5,pady=3D5)

# Utilisation d'un dictionnaire pour conserver une r=C3=A9f=C3=A9rence
gifdict=3D{}

Mafenetre.mainloop()

2015-09-21 0:50 GMT+02:00 Laura Creighton <lac@openend.se>:
> In a message of Sun, 20 Sep 2015 23:11:20 +0200, Baladjy KICHENASSAMY wri=
tes:
>>well one more question :/
>>
>>i tried this
>>
>>def save():
>>     Canevas.update()
>>     Canevas.postscript(file=3DtkFileDialog.asksaveasfilename(),
>>colormode=3D'color')
>>     subprocess.call(["ps2pdf", "-dEPSCrop", "test.ps", "test.pdf"])
>>
>>
>>i got the ps file but i didn't get the pdf file :/
>
> It's 00:41 here in Sweden, and I have an 08:00 meeting.  I am off to bed.
> Perhaps somebody else can help now, otherwise I will be back
> tomorrow.
>
> I've never tried to get subprocess to run as part of a savefile dialog.
> Try building a tkinter app that takes a filename argument (somepostscript
> file you have lying around) and then push the button, in the same dir
> makes a pdf of your ps using subprocess.
>
> If that works, then see about getting save to run that subprocess as
> part of the save process.  I am very curious about whether that can
> be done -- but first check that your subprocess is working, period.
> The wretched thing is slightly different between windows and linux,
> and even between different linuxes, so needing to fiddle a bit here is
> normal (and frustrating).
>
> So right now I cannot tell if your problem is 'save doesn't like
> it like that' or 'your subprocess isn't working'.
>
> But nothing in Tkinter likes 'Canevas' -- (which is great French
> but rotten English) you must have written Canvas in your code.
>
> Paste the real thing in next time, ok?
>
> Sorry I am off now,
> Laura



--=20
KICHENASSAMY Baladjy
Ing=C3=A9nieur en G=C3=A9nie M=C3=A9canique
Sp=C3=A9cialiste Contr=C3=B4le Non Destructif et Qualification des proc=C3=
=A9d=C3=A9s sp=C3=A9ciaux
COSAC CND Niveau 2 RT et PT
Aircelle SAFRAN
Tel:06.03.72.53.12
0
Baladjy
9/21/2015 3:20:47 PM
Am 21.09.15 um 17:20 schrieb Baladjy KICHENASSAMY:
> Hello,
> This is my programe : on mac i was able to output ps file but i didn't
> got the pdf file :/

Maybe ps2pdf is not installed? I think it doesn't come with the Mac. You 
need to get it via fink, homebrew, macports or an official ghostscript 
binary. The same holds true for convert, which is a tool from ImageMagick.

Yet another option would be to wrap the pdf4tcl library:

http://sourceforge.net/projects/pdf4tcl/

It can create PDF from a canvas without an external dependency. The Tcl 
code for it looks like this:

> package require pdf4tcl
> set size [list [winfo width $win] [winfo height $win]]
> set pdf [pdf4tcl::new %AUTO% -paper $size -compress false]
> $pdf canvas $win
> $pdf write -file $fn
> $pdf destroy

In principle, you could run this code via Tkinter.eval()
You would need to set "win" to your canvas path and "fn" to the file 
name path.

Yet another option would be to use a Python package like Reportlab to 
create the PDFs, which requires you to reimplement the drawing code.

	Christian
0
Christian
9/23/2015 6:40:58 AM
On Tuesday, September 22, 2015 at 2:20:56 AM UTC-5, Bala Ji wrote:
> Hello,
> This is my programe : on mac i was able to output ps file but i didn't
> got the pdf file :/
>=20
> # -*- coding: utf-8 -*-
> # script lecture_gif.py
> from Tkinter import *
> import tkMessageBox
> import Tkconstants
> import tkFileDialog
> from PIL import ImageTk
> import PIL.Image
> import os, sys
> import subprocess
>=20
>=20
> def Ouvrir():
>     Canevas.delete(ALL) # on efface la zone graphique
>=20
>     filename =3D tkFileDialog.askopenfilename(title=3D"Ouvrir une
> image",filetypes=3D[('gif files','.gif'),('all files','.*')])
>     print(filename)
>     photo =3D PhotoImage(file=3Dfilename)
>     gifdict[filename] =3D photo  # r=E9f=E9rence
>     print(gifdict)
>=20
>     Canevas.create_image(0,0,anchor=3DNW,image=3Dphoto)
>     Canevas.config(height=3Dphoto.height(),width=3Dphoto.width())
>=20
>     Mafenetre.title("Image "+str(photo.width())+" x "+str(photo.height())=
)
>=20
> def insertimage():
> n=3DtkFileDialog.askopenfilename(filetypes =3D [("Image Files", ("*.jpg",
> "*.gif")),("JPEG",'*.jpg'),("GIF",'*.gif'),('All','*')])
> img =3D PIL.Image.open(n)
> img =3D img.resize((229, 253))
> photoimg =3D ImageTk.PhotoImage(img)
> label =3D Label(image=3Dphotoimg)
> label.image =3D photoimg # keep a reference!
> Canevas.create_image(65,320,anchor=3DW,image =3D photoimg)
> def insertsign():
> n=3DtkFileDialog.askopenfilename(filetypes =3D [("Image Files", ("*.jpg",
> "*.gif")),("JPEG",'*.jpg'),("GIF",'*.gif'),('All','*')])
> img =3D PIL.Image.open(n)
> img =3D img.resize((300, 100))
> photoimg =3D ImageTk.PhotoImage(img)
> Canevas.create_image(600,500,anchor=3DW,image =3D photoimg)
> Canvas.pack()
>=20
> def Fermer():
>     Canevas.delete(ALL)
>     Mafenetre.title("Image")
>=20
> def save():
> Canevas.update()
> Canevas.postscript(file=3DtkFileDialog.asksaveasfilename(), colormode=3D'=
color')
> subprocess.call(["ps2pdf", "-dEPSCrop", "test.ps", "test.pdf"])
>=20
> # def convert():
> # ps2pdf -dEPSCrop image.ps
> # convert -density 300 PASSPORTQUALITE.ps output.png
>=20
> # class TkFileDialogExample(Tkinter.Frame):
> #
> #     def __init__(self, root):
> #
> #         Tkinter.Frame.__init__(self, root)
> #         button_opt =3D {'fill': Tkconstants.BOTH, 'padx': 5, 'pady': 5}
> #         Tkinter.Button(self, text=3D'Save',
> command=3Dself.asksaveasfilename).pack(**button_opt)
> #
> #         self.file_opt =3D options =3D {}
> #         options['filetypes'] =3D [('all files', '.*'), ('text files', '=
..txt')]
> #         options['initialfile'] =3D 'myfile.txt'
> #         options['parent'] =3D root
> #
> #     def asksaveasfilename(self):
> #         filename =3D tkFileDialog.asksaveasfilename(**self.file_opt)
> #
> #         if filename:
> #             return open(filename, 'w')
> #
> # if __name__=3D=3D'__main__':
> #     root =3D Tkinter.Tk()
> #     TkFileDialogExample(root).pack()
> #     root.mainloop()
> def Apropos():
>     tkMessageBox.showinfo("A propos","Tutorial")
>=20
> def Write():
> def delete():
> e1.delete(0,END)
> e2.delete(0,END)
> e3.delete(0,END)
> e4.delete(0,END)
> e5.delete(0,END)
> e6.delete(0,END)
> Canevas.delete("e1")
> def valider():
> Canevas.create_text(315,200,anchor=3DW,text=3D"Surname/Nom",fill=3D'Black=
',font=3D'Arial
> 14')
> Canevas.create_text(315,220,anchor=3DW,text=3De1.get(),fill=3D'Black',fon=
t=3D'Arial
> 30',tags =3D"e1")
> Canevas.create_text(315,250,anchor=3DW,text=3D"Given
> name/Pr=E9nom",fill=3D'Black',font=3D'Arial 14')
> Canevas.create_text(315,270,anchor=3DW,text=3De2.get(),fill=3D'Black',fon=
t=3D'Arial
> 30',tags =3D"e1")
> Canevas.create_text(315,300,anchor=3DW,text=3D"Fonction/Function",fill=3D=
'Black',font=3D'Arial
> 14')
> Canevas.create_text(315,320,anchor=3DW,text=3De3.get(),fill=3D'Black',fon=
t=3D'Arial
> 30',tags =3D"e1")
> Canevas.create_text(470,395,anchor=3DW,text=3De4.get(),fill=3D'Black',fon=
t=3D'Arial
> 30',tags =3D"e1")
> Canevas.create_text(500,438,anchor=3DW,text=3De5.get(),fill=3D'Black',fon=
t=3D'Arial
> 30',tags =3D"e1")
> Canevas.create_text(228,503,anchor=3DW,text=3De6.get(),fill=3D'Black',fon=
t=3D'Arial
> 30',tags =3D"e1")
> master =3D Tk()
> Label(master, text=3D"Surname/Nom").grid(row=3D0)
> Label(master, text=3D"Given name/Pr=E9nom").grid(row=3D1)
> Label(master, text=3D"Fonction/Function").grid(row=3D2)
> Label(master, text=3D"Validity Date").grid(row=3D3)
> Label(master, text=3D"Chef").grid(row=3D4)
> Label(master, text=3D"Student number").grid(row=3D5)
> e1 =3D Entry(master)
> e2 =3D Entry(master)
> e3 =3D Entry(master)
> e4 =3D Entry(master)
> e5 =3D Entry(master)
> e6 =3D Entry(master)
> e1.grid(row=3D0, column=3D1)
> e2.grid(row=3D1, column=3D1)
> e3.grid(row=3D2, column=3D1)
> e4.grid(row=3D3, column=3D1)
> e5.grid(row=3D4, column=3D1)
> e6.grid(row=3D5, column=3D1)
> Button(master, text=3D'Ok', command=3Dvalider).grid(row=3D2, column=3D2,
> sticky=3DW, pady=3D4)
> Button(master, text=3D'Delete', command=3Ddelete).grid(row=3D3, column=3D=
2,
> sticky=3DW, pady=3D4)
> mainloop( )
>=20
> # Main window
> Mafenetre =3D Tk()
> Mafenetre.title("Image")
>=20
> # Cr=E9ation d'un widget Menu
> menubar =3D Menu(Mafenetre)
>=20
> menufichier =3D Menu(menubar,tearoff=3D0)
> menufichier.add_command(label=3D"Open mask",command=3DOuvrir)
> menufichier.add_command(label=3D"Save mask",command=3Dsave)
> #menufichier.add_command(label=3D"Convert pdf",command=3Dconvert)
> menufichier.add_command(label=3D"Close mask",command=3DFermer)
> menufichier.add_command(label=3D"Quit",command=3DMafenetre.destroy)
> menubar.add_cascade(label=3D"File", menu=3Dmenufichier)
>=20
> menuwrite =3D Menu(menubar,tearoff=3D0)
> menuwrite.add_command(label=3D"Insert informations",command=3DWrite)
> menuwrite.add_command(label=3D"Insert image",command=3Dinsertimage)
> menuwrite.add_command(label=3D"Insert signature",command=3Dinsertsign)
> menubar.add_cascade(label=3D"Informations", menu=3Dmenuwrite)
>=20
>=20
> menuaide =3D Menu(menubar,tearoff=3D0)
> menuaide.add_command(label=3D"A propos",command=3DApropos)
> menubar.add_cascade(label=3D"Aide", menu=3Dmenuaide)
>=20
> # Affichage du menu
> Mafenetre.config(menu=3Dmenubar)
>=20
> # Cr=E9ation d'un widget Canvas
> Canevas =3D Canvas(Mafenetre)
> Canevas.pack(padx=3D5,pady=3D5)
>=20
> # Utilisation d'un dictionnaire pour conserver une r=E9f=E9rence
> gifdict=3D{}
>=20
> Mafenetre.mainloop()
>=20
> 2015-09-21 0:50 GMT+02:00 Laura Creighton <lac@openend.se>:
> > In a message of Sun, 20 Sep 2015 23:11:20 +0200, Baladjy KICHENASSAMY w=
rites:
> >>well one more question :/
> >>
> >>i tried this
> >>
> >>def save():
> >>     Canevas.update()
> >>     Canevas.postscript(file=3DtkFileDialog.asksaveasfilename(),
> >>colormode=3D'color')
> >>     subprocess.call(["ps2pdf", "-dEPSCrop", "test.ps", "test.pdf"])
> >>

Try putting the entire path to ps2pdf in the subprocess call, something lik=
e:
/usr/local/bin/ps2pdf
0
mithra
9/24/2015 12:01:56 AM
Reply:

Similar Artilces:

Postscript to PDF with pdf-tools, pdf-writer, or other
Does anyone have a way to convert Postscript to PDF using pdf-tools, pdf-writer, or other method? Any suggestions? On 14/04/2008, Sean Nakasone <seannakasone@yahoo.com> wrote: > Does anyone have a way to convert Postscript to PDF using pdf-tools, > pdf-writer, or other method? Any suggestions? ps2pdf is standard on any install of Ghostscript, at least on most flavours of Linux/BSD Farrel ...

PDF PDF PDF
For anyone struggling to figure out how to create a PDF in SWX it's pretty simple but you may have to have the Bluebeam version of swx FIRST go to Tools>Options and check "Save as PDF" Then you can save them right from the save as dialog. Maybe I'm the only dumbass that could't figure that out! ;0) But it was in help under "PDF" An easier way is to download a program from www.pdf995.com that "prints" you files to a PDF foramat. This program works with SW and any other program you use to print with. "3d" <jmiller at marvelindustri...

postscript and pdf missing base postscript fonts
I am in the process of sending my ph.d. thesis to a printing firm, and I am trying to create a pdf file that suits them. My first attempt met some objections, most nobably the absence of embedded Times, Helvetica etc. All the other fonts (I used a custom type 1 font for the body text) were embedded in the pdf file. I use teTeX 1.0.7 and ghostscript 7.05 to generate the pdf through the dvips -> ps2pdf route. I am a little reluctant to upgrade these so close to a deadline. Indeed, Times and Helvetica were not embedded. When I look at the psfonts.map file in $TEXMF/dvips/config, I fi...

Need Cups-PDF to actually create PDF not Postscript
From: CUPS 127.0.0.1:631 Description: Cups-PDF Location: RN Printer Driver: Generic postscript color printer rev4 Printer State: idle, accepting jobs, published. Device URI: cups-pdf:/ Hi All, I am using CentOS 5.5. I installed cups-pdf-2.4.6-1.el5.i386.rpm and now have the nicest CUPS to Postscript printer. Okay, I need that to use with HylaFAX, but I also need a print to PDF (not Postscript). What did I do wrong? Many thanks, -T On 2010-06-05, Todd <todd@invalid.com> wrote: > From: CUPS 127.0.0.1:631 > Description: Cups-PDF > Location: RN > Printer...

python is a python
python is a python ...

PostScript to PDF conversion creating Huge Font sizes in PDF
I generated a PostScript file by using the Windows GDI to print to a postscript printer (HP LaserJet 8500 PS) which uses the PSCRIPT5 driver. I can open the PostScript file in GSView and it looks fine. I then used Adobe Acrobat Distiller to distill the file to PDF. Again I can open it in Reader and it looks fine. Finally I took the same PostScript file and used a third-party "distiller" and distilled the PostScript to PDF - but I did perform the conversion on another machine on our network. This last time, the PDF file created contains huge fonts. In fact, the fonts are so large t...

PDF To Postscript
PyPDF (and others) provide a very nice mechanism for creating and manipulating PDF documents. Is there any *Python* module or technique to turn a PDF document into Postscript [to print, for example]? ...

PDF TO PDF/A
Hello, is it possible to convert a PDF file to PDFA file ? i tried the -dPDFA option and i vefy my pdf file with PDF longlife. I have an error. Thanks for help. ...

PostScript to PDF
Hi, When you open a PostScript file with Preview (on Panther) it will convert the file to PDF. Does anyone know how I can do this in my programs ? Can I do this with Quartz ? Thanks Marc ...

PDF in a Bottle
pdf_bottle.py is a program I wrote that allows you to create a PDF file from text, over the web, by entering your text into a form and submitting it. Here is the post about it: http://jugad2.blogspot.in/2013/05/pdf-in-bottle-creating-pdf-using-xtopdf.html - Vasudev Ram dancingbison.com jugad2.blogspot.com ...

PDF in a Bottle
Hi list, Might be of interest: PDF in a Bottle - creating PDF using xtopdf, ReportLab, Bottle and Python http://jugad2.blogspot.in/2013/05/pdf-in-bottle-creating-pdf-using-xtopdf.html - Vasudev Ram Python, Linux and open source training and development www.dancingbison.com ...

Postscript and PDF-Files
Hi Folks, is there any module or other possibilty to convert postscript-files generated by the postscript-method of the canvas-widget into a pdf-file ??? Thanks Pit wrote: > Hi Folks, > > is there any module or other possibilty to convert postscript-files > generated by the postscript-method of the canvas-widget into a pdf-file > ??? > > Thanks You may use the ps2pdf program included in the ghostscript package from alladin software or a windows one called pdfwriter (search google for both) depending on the platform you use. rgds -- Johnn...

Embed PDf in Postscript
This is a very preliminary question at this point, but is there any way to `embed' code in a postscript document that is only activated when distilled to a PDf? Alas, I fear that the answer is no, or else some of our packages would be written without the need for options specifying PS versus PDf specials. Even if it can be done in postscript, the next obvious question would be whether or not there's a way to get the result with TeX \specials passed through dvips. -- Brian Blackmore blb8 at po dot cwru dot edu On Sep 5, 5:32 pm, Brian Blackmore <b...@po.cwru.edu> wrote: > ...

convert from PDF to postscript
We are creating PDF files in our application and storing them, but we must also print them. I have it narrowed down to executing LPR from the application. Sample postscript files printed OK with this command, so I need to convert PDF files to postscript. I've been looking for something to do this and can't find it. I found such things as a2ps and pdf2ps but no java implementation of these. Help is desperately needed converting PDF to PS for printing. hanks "David McDivitt" <x12code-del@del-yahoo.com> wrote in message news:vhvfv0p0ot5lnl236cefdvc61fdvno5cbj@4ax.com......

Web resources about - Postscript to pdf - comp.lang.python

PostScript - Wikipedia, the free encyclopedia
The concepts of the PostScript language were seeded in 1976 when John Warnock was working at Evans & Sutherland , a computer graphics company. ...

John Eligon - A postscript to my interview with white... - Facebook
A postscript to my interview with white nationalist, Paul Craig Cobb ... I had knocked on doors in high-crime neighborhoods, spent time interviewing... ...

Flickr: PostScript.EdmontonJournal's Photostream
Explore PostScript.EdmontonJournal's photostream on Flickr. This user has 138 photos on Flickr.

Admire Rakti death a sad Cup postscript
... and died after finishing last in the Melbourne Cup. Favourite Admire Rakti collapsed and died after the Melbourne Cup, adding a sad postscript ...

A postscript to 'The Killing Season': Was there a coup d'etat over mining tax?
Sarah Ferguson's ABC series left one crucial question unanswered.


TFS Kanban talk in Indianapolis, postscript
I've been wanting to write this since giving a talk last week at the Indianapolis TFS user group. Paul Hacker started this group and leads the ...

Potter postscript: 10 great, and 10 not-so-great, things about Harry Potter (Plus: The best scenes) ...
As the Harry Potter film series reaches the end of the story, we look back on the highs and lows of the Harry Potter phenomenon.

Postscript from Penn State-Loyola Maryland men's lacrosse
The Loyola Maryland men&rsquo;s lacrosse team likes to pepper opposing goalkeepers with shots. But the offense prefers to have a little production ...

Sunday Classics preview: A Leon Fleisher postscript
... this July 1956 Epic Debussy-Ravel LP. by Ken No, no, Fleisher hasn't died at least not that I know. What I mean in the post title is a "postscript" ...

Resources last updated: 1/25/2016 5:30:41 AM