f



Printing a text over an image

Hi guys,

Using python, wxpython and sqlite in a windows system, Im trying to
print some certificates/diplomas/cards with a image at background with
the name of person/text over it.

I know the basic steps to print the text using win32print from Pywin32
but...:

1) I dont know how to add an image and set it to background.

   while .....

        .....

        # Query sqlite rows and collumn name and set the self.text for
each certificate

        .....

        # Now send to printer

        DC = win32ui.CreateDC()
        DC.CreatePrinterDC(win32print.GetDefaultPrinter())

        DC.SetMapMode(win32con.MM_TWIPS)

        DC.StartDoc("Certificates Job")

        DC.StartPage()

        ux = 1000
        uy = -1000
        lx = 5500
        ly = -55000

        DC.DrawText(self.text, (ux, uy, lx, ly),win32con.DT_LEFT)

        DC.EndPage()
        DC.EndDoc()

This printer-code is inside a while loop calling each people name from
a sqlite database per check condition.


2) All the names of database was printed at same page... how i command
the printer to spit out 1 page per name from the database?


3) Any more simple approach or module to deals with printers (paper
and/or pdf) will be welcome.

Thanks in advance,

Martha
0
mmorrigan (1)
11/7/2012 4:52:35 PM
comp.lang.python 77058 articles. 6 followers. Post Follow

2 Replies
613 Views

Similar Articles

[PageSpeed] 21

Martha Morrigan wrote:

> 
> 3) Any more simple approach or module to deals with printers (paper
> and/or pdf) will be welcome.

For pdf, you can take a look at ReportLab's Toolkit. I used it to build a 
"trombinoscope" (ie an employee directory with each member's photo on top of 
his name and room number).

http://www.reportlab.com/software/opensource/

Once created the pdf, you must find a solution to send it to the printer...

> 
> Thanks in advance,
> 
> Martha

A+
Laurent.

0
11/7/2012 6:16:58 PM
On Wednesday, November 7, 2012 5:52:36 PM UTC+1, Martha Morrigan wrote:
> Hi guys,
>=20
>=20
>=20
> Using python, wxpython and sqlite in a windows system, Im trying to
>=20
> print some certificates/diplomas/cards with a image at background with
>=20
> the name of person/text over it.
>=20
>=20
>=20
> I know the basic steps to print the text using win32print from Pywin32
>=20
> but...:
>=20
>=20
>=20
> 1) I dont know how to add an image and set it to background.
>=20
>=20
>=20
>    while .....
>=20
>=20
>=20
>         .....
>=20
>=20
>=20
>         # Query sqlite rows and collumn name and set the self.text for
>=20
> each certificate
>=20
>=20
>=20
>         .....
>=20
>=20
>=20
>         # Now send to printer
>=20
>=20
>=20
>         DC =3D win32ui.CreateDC()
>=20
>         DC.CreatePrinterDC(win32print.GetDefaultPrinter())
>=20
>=20
>=20
>         DC.SetMapMode(win32con.MM_TWIPS)
>=20
>=20
>=20
>         DC.StartDoc("Certificates Job")
>=20
>=20
>=20
>         DC.StartPage()
>=20
>=20
>=20
>         ux =3D 1000
>=20
>         uy =3D -1000
>=20
>         lx =3D 5500
>=20
>         ly =3D -55000
>=20
>=20
>=20
>         DC.DrawText(self.text, (ux, uy, lx, ly),win32con.DT_LEFT)
>=20
>=20
>=20
>         DC.EndPage()
>=20
>         DC.EndDoc()
>=20
>=20
>=20
> This printer-code is inside a while loop calling each people name from
>=20
> a sqlite database per check condition.
>=20
>=20
>=20
>=20
>=20
> 2) All the names of database was printed at same page... how i command
>=20
> the printer to spit out 1 page per name from the database?
>=20
>=20
>=20
>=20
>=20
> 3) Any more simple approach or module to deals with printers (paper
>=20
> and/or pdf) will be welcome.
>=20
>=20
>=20
> Thanks in advance,
>=20
>=20
>=20
> Martha

Hi Martha,

Since you are on windows, why don't you use MS/Word directly from Python. I=
t has all the abstractions you need (documents, pages, tables, figures, pri=
nting etc.). Working with MS/Word through the win32 bindings is really simp=
le.
I have done this a while ago for some automatic report generation. The basi=
c routine is to start recording your actions with the MS/Word macro recorde=
r, do the things you want to do, stop recording, look at the VB code and gu=
ess the equivalent Python code. This is not as bad as it sounds. It normall=
y is really straightforward.

I am on Linux at the moment, so I cannot present any code examples. Feel fr=
ee to try and post some example code if you get stuck.

Marco
0
nawijn (46)
11/15/2012 10:43:50 AM
Reply:

Similar Artilces:

Printing text, image, text, image, ...
I have bunch of text files (about 20 lines) and bunch of image files. Is there a clean way to print text, then image, then text, then image, ...., as though there are in single continuous document? -- William Park <opengeometry@yahoo.ca>, Toronto, Canada ThinFlash: Linux thin-client on USB key (flash) drive http://home.eol.ca/~parkw/thinflash.html BashDiff: Super Bash shell http://freshmeat.net/projects/bashdiff/ ["Followup-To:" header set to comp.os.linux.misc.] On Fri, 23 Jun 2006 20:01:01 -0400, William Park staggered into the Black Sun and said: > I have [a] bu...

Printing images through Python
I've done a lot of searching to try to find a way to print PIL images to a normal (i.e. non-PostScript) printer through Python on a Windows system... and have found squat! The only sample I found used a hokey hook through PythonWin via a shellExecute command. Does ANYONE have Python code to print PIL images? Thanks! Kevin Cazabon. ...

Text printing mirror image
My computer has just developed a strange printing symptom: Pages which contain only text print mirror image. If there is any graphic content on the page, they print normally. If the document contains some pages with graphics, and some without, the pages with graphics print normally; those without print mirror image. The problem occurs with NotePad, WordPad and Word 2000. Outlook, Outlook Express, and IE 6 print normally. I run Windows 2000, recently upgraded to SP4 with all critical patches. My printer is an Epson 750, running as an LPR printer (on a "pocket" print server appliance). The latest Norton AntiVirus signatures turn up no viruses. Any thoughts? - David In article <blfkbg$bmkc7$1@ID-128035.news.uni-berlin.de>, "David D." <daviddiamond@comcast.net> wrote: > My computer has just developed a strange printing symptom: > > Pages which contain only text print mirror image. If there is any graphic > content on the page, they print normally. If the document contains some > pages with graphics, and some without, the pages with graphics print > normally; those without print mirror image. > > The problem occurs with NotePad, WordPad and Word 2000. Outlook, Outlook > Express, and IE 6 print normally. > > I run Windows 2000, recently upgraded to SP4 with all critical patches. My > printer is an Epson 750, running as an LPR printer (on a "...

RE: Printing images through Python
> From: Kevin [mailto:other@cazabon.com] > Does ANYONE have Python code to print PIL images? It just so happens that I've been going through the same bit of grief recently. Depending on just how much control you want, I advocate two approaches, with several others possible if I had more time to explore the, frankly arcane, possibilities offered by the Win32 SDK: 1) Use ReportLab's PDF generator to embed the image. Get the ReportLab docs (http://www.reportlab.com/docs/userguide.pdf) and search for InlineImage. If you need a code example I can give you one, but it's pretty st...

Printing Images through python post
The example in this post appears to be incomplete, -----Original Message----- > From: Tim Golden > Sent: 03 October 2003 09:49 > To: 'Kevin' > Cc: python-list@python.org > Subject: RE: Printing images through Python Is The ratios calculation correct? It does not appear to be complete. # # Resize the image to fit the page but not to overflow # ratios = [1.0 * printer_resolution[0] / bmp.size[0], 1.0 * printer_resolution[1] / bmp.size[1]] print "ratios =", ratios scale = min (ratios) print "scale =", scale Jody Burgess ISP Systems Analyst Sewar...

RE: Printing images through Python #2
> -----Original Message----- > From: Tim Golden > Sent: 03 October 2003 09:49 > To: 'Kevin' > Cc: python-list@python.org > Subject: RE: Printing images through Python > > > > From: Kevin [mailto:other@cazabon.com] > > Does ANYONE have Python code to print PIL images? > > It just so happens that I've been going through the same bit > of grief recently. Depending on just how much control you > want, I advocate two approaches, with several others possible > if I had more time to explore the, frankly arcane, > possibilities ...

Font size of text when printing images
Hello i have the problem that when printing images from 2 different series out of one study to a paperprinter, the demographic datas do not have the same size for the images of the different studies. Question: Where in the dicomheader are these values to find (size and fonts of the demograhhics). Any other ideas of that behavior Thanks in advance for your help Martin Hi Moser, How did you print the demographic details? Where did you say that you want demographic details printed? moser martin wrote: > Hello > i have the problem that when printing images from 2 different series out of > one study to a paperprinter, the demographic datas do not have the same size > for the images of the different studies. > > Question: > Where in the dicomheader are these values to find (size and fonts of the > demograhhics). > > Any other ideas of that behavior > > Thanks in advance for your help > > Martin Hi Ramesh i did send the studies from a pacs displaystation to a printserver (hipax) where a paperprinter is connected to. There is no option to enable/disable demographic layouts for printing, it is just a dicom-print from a pacs displaystation. ramesh.s.raghavan@gmail.com schrieb: > Hi Moser, > > How did you print the demographic details? Where did you say that you > want demographic details printed? > > moser martin wrote: > > Hello > > i hav...

RE: Printing Images through python post
| Is The ratios calculation correct? It does not appear to be complete. The code is listed in full on this page: (warning; slightly long URL) http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ ...

Text in images to a text file
Hello, Does anyone know of any software for Linux which converts text in images to a text file. I have loads of paper documents that I intend to scan. The contents of these documents needs to eventually end up on a web site but as text. Darren <bobblebob@gmail.com> wrote in message news:1151612491.407262.124690@75g2000cwc.googlegroups.com > Does anyone know of any software for Linux which converts text in > images to a text file. I have loads of paper documents that I intend > to scan. The contents of these documents needs to eventually end up > on a web site but as text....

Resizable image with image text
I'm looking for some help with a group of templates for images on my blog. The images appear in the main content column, and will normally span 100% of its allocated width. The column layout is flexible and I want the images to resize automatically with it. Here's my solution: <div class="image-box"> <img src="..."/> <div class="image-text">...</div> </div> ..image-box { clear: both; } ..image-box img { display: block; width: 100%; } ..image-text { padding: 6px 10px 8px 10px; ba...

Tip: printing text above an image displayed with imshow
I have just found a way to display text in a window containing an image which has been displayed with the SIP function imshow. The trick is to divide the window in 2 parts, using the xsetech. If the window is not divided, imshow will delete the text, or if imshow is first used and the text subsequently written, the image is lost. This works (adapt the font size, size of subwindows, and coordinates of where printing your string): initial_dir = PWD; chdir (SIPDIR + 'images'); xbasc(); xsetech([0,0,1,0.5]); xstring(0.1,0.97,"Scilab is not esilaB",0,0) halt xsetech([0,0.5,1,0.5]); imshow('example.png'); chdir(initial_dir); This doesn't work: initial_dir = PWD; chdir (SIPDIR + 'images'); xbasc(); imshow('example.png'); halt xstring(0.1,0.97,"Scilab is not esilaB",0,0) chdir(initial_dir); This doesn't work either: initial_dir = PWD; chdir (SIPDIR + 'images'); xbasc(); xstring(0.1,0.97,"Scilab is not esilaB",0,0) halt imshow('example.png'); chdir(initial_dir); Ludovic ...

How to make this Python code print blocks of text?
This code prints output in rows like this: ****** ****** ****** How to make print in blocks like this? ***** ***** ****** ***** ***** ****** ***** ***** ***** start= int (raw_input("StartTable?")) upperlimit= int (raw_input ("FinalTable?")) cycle= start while cycle <= upperlimit: ........table= cycle ........counter= 0 ........while counter < 10: ...............counter= counter + 1 ...............print table, "X", counter, "=", counter * table ........cycle= cycle + 1 The program prints multyply tables like this 4 X1 = 4 4 X2 = 8 5 X 1= 5 5 X 2...

Text IN an Image To Straight Text?
Hi. (I'm not sure where to ask this so I'm trying a few newsgroups) I have some .jpg's of text documents. Is there a utility which will work like OCR in a scanner, helping to convert the text WITHIN the image to straight text? I don't have a printer working at the moment, or I'd print the .jpg's and then scan them using OCR. (The format doesn't necessarily have to be .jpg) Thanks in advance for any help GP Yes, if the image is not to bad a pic (not much noise and all that). Try http://www.twocows.com/windows.html I know they have a couple of ocr programs s...

Replacing text with a background image affects printing
I have seen lots of examples where some HTML text is replaced with a background image using CSS. For example, replacing the text of an <h1> with a graphical logo, like so: CSS: h1 span { display: none; } h1 { height: 100px; background: url("mycompany.gif") no-repeat 35px 40px; } HTML: <h1><span>My Company</span></h1> This allows the text version to be displayed for non-CSS browsers, and allows a more visually appealing logo to be displayed for CSS enabled browsers (assuming they don't have images turned off). One side effect of thi...

aligning text and image-text
I use a program to make Email addresses harder for spammers to harvest. It converts them to slightly blurred images using http://mindprod.com/products1.html#MASKER When I embed them in text, I have figured out how to get them to align naturally with the surrounding text, but the browser inserts extra inter-line spacing above the line containing the image. You can see the effect at http://mindprod.com/book/books.html at the bottom of the page where it says: "Please email your feedback for publication, letters to the editor, errors, omissions, typos, formatting errors, ambig...

How to.. Large image and text over image?
L.S., (just started using LaTeX 4 months ago) I have written my thesis and it's almost ready to be printed, but I have two problems: For my titlepage I've made an image which covers 98% of an A4-paper (size used to print my thesis on). The first problem is about the size of the image: how do I get the image to be correctly centered on the title-page. I've tryed serveral things, but none seemed to help. The second problem is that over the image text will have to be displayed and printed. The image is a background-image, so to say. How can I do this? Thank for your help, Koos On W...

Text and Image inside table <td> Alight Text Left and Image right in same cell ??
Is that possible? How? <td > <asp:Label ID="StartDateLabel" runat="server" Text="Start Date:"> <asp:imagebutton ID="Imagebutton1" width=18 Height=18 CommandName=SetDate imageUrl="../cal.jpg" runat=server /> </asp:Label> </td> <td > On 2006-10-24, Jason <jason@cyberpine.com> wrote: > Is that possible? How? Set text-align: left on the cell as usual (it's likely to be the default), and make the image float: right. To work around a Firefox float bug, better to put the image befor...

using python to visit web sites and print the web sites image to files
Hi there, I wonder whether python can be used to simulate a real user to do the following: 1) open a web site in a browser; 2) printscreen, so to copy the current active window image to clipboard; 3) save the image file to a real file Any pointer will be apprieciated! Xiong On Mar 12, 7:32 am, "imx" <xiong.xu...@gmail.com> wrote: > I wonder whether python can be used to simulate a real user to do the > following: > 1) open a web site in a browser; > 2) printscreen, so to copy the current active window image to > clipboard; > 3) save the image file to a re...

PDF image of text to readable text ?
Seems there are web based tools and software. My son needs text to have it read for him. He has a PC. Found PDF reader $50 , http://thurly.net/11ia and http://thurly.net/11i4 the last being google. Wondering what you folks found useful or use ? Thanks! -- Bill S. Jersey USA zone 5 shade garden http://uppitywis.org/ live WI ...

Replace text with image in text widget
I'm trying to replace an emoticon with an actual image in a text widget. I know I'm not doing this correctly: the sample code below inserts two images randomly and seems to garble the text in other ways. The idea is to have two emoticons (one on each line) and replace them with an image, nothing more. Can anyone take a look and suggest how I might get this to work? Thanks. --- SPfHZvvOGvfQEvfGdvjQE/rNMfrOMfrNPfvQHfzQHfjQLfrNRvjQL/vRJfzRJvrOWvbMh/3VHPfM h/3WHPzVMP7XF/zVMfrPdv7YGP7YG/7YHPzWPPzWPfvUVP7ZHf7ZIPvWVf7aJv7aJ/7bJv7bM/7b NP7cLf7dMPvXeP7dNvrVlv7eOPrWlvvaevrYmP7gRP7gRf7gRv7i...

Slow image printing with print server
We recently bought a print server box (D-Link DP-300U) which would allow us to use our Canon i9100 (A3) USB printer as a network (ethernet) printer. I installed the box, plugged the printed and configured all the stuff according to the printserver's manual. It works. Documents sent through the server are printed properly. However, while text documents prints at a seemingly normal speed, big images prints sluggishly compared to a direct USB connection. Instead of printing the image's lines continuously (as it used to do), the printer waits about 10 (!) seconds between ea...

Scanned text (image) needs to be converted to text
Hello all, I have a PDF of a contract that was scanned in and stored as an image (so we can't select the text). Is there any way to convert an image to text (preferably built in to Adobe Acrobat or a free plug-in)? We are using Adobe Acrobat 5.0. Thanks for any help anyone can provide, Conan Kelly Conan Kelly wrote: > Hello all, > > I have a PDF of a contract that was scanned in and stored as an image > (so we can't select the text). > > Is there any way to convert an image to text (preferably built in to > Adobe Acrobat or a free plug-in)? > &...

Print Images from Windows Photo Printing Wizard
Hi, when printing from the above via an Epson r200 printer prints are too dark. If I print from Paintshop Pro they are fine. Settings in the printer interface is the same. Anyone know why and what the solution is please. Ron ...

If a text field is not empty, print a comma after the text
How do I do this in the calculation field? I do a lot of formatting of text in FM (8) on a Mac and am trying to learn on my own. This should be a simple task, but I can't figure it out. Thanks for any help. John Oliver composer <spamisevil@shaw.ca> writes: > How do I do this in the calculation field? I do a lot of formatting of > text in FM (8) on a Mac and am trying to learn on my own. This should > be a simple task, but I can't figure it out. > Thanks for any help. if( not isempty(self) ; self & "," ) Jens -- Free PlugIn for Regular Expressions ...

Web resources about - Printing a text over an image - comp.lang.python

Printing - Wikipedia, the free encyclopedia
This article is about the process of reproducing text and images. For the handwriting method often called printing, see block letters . For other ...

Help Mr Plumbum sort his printing box in this matching game
... path in Linken, an elegant puzzler or Meteors are falling, dont get squished in Danger Dodgers . Mr Plumbum Help Mr Plumbum sort his printing ...

Why is the UK still printing its laws on vellum?
After a U-turn, the UK government is to continue printing and storing its laws on vellum. Shouldn't it go digital?

Kids can easily make their own toys with 3D printing
This year's must-have toy: a machine to make your own toy. Mattel's ThingMaker is a kid-safe 3D printer, and the 3Doodler Start Pen won't burn ...

Printing Human Tissue? Why Not?
Six years ago in Washington, DC, a State Department security SUV made an illegal left turn and struck me as I crossed the street. My tibial plateau ...

Tokyo students develop architectural 3D-printing pen
A group of University of Tokyo students overseen by architect Kengo Kuma have developed a 3D-printing pen that can be used to create complex ...

Barclays' 'MakerSpaces' offer 3D printing to local businesses
The worlds of banking and technology intersect at many points, but you'd hardly consider 3D printing a shared interest. In Barclays' "MakerSpaces," ...

Mattel Is Making a $300 3D Printing Toy Studio For Kids
One of the world’s largest toy makers, Mattel, has long embraced the idea of helping kids build their own toys. Back in the 1960s, the company ...

Getting it Right by Getting it Wrong: RepRap and the Evolution of 3D Printing
The beginning of the DIY 3D printing movement was a heady time. There was a vision of a post-scarcity world in which everything could and would ...

3-D Printing: Gigi The Macaw Gets First-Ever Titanium Prosthetic Beak (PHOTOS)
Gigi the macaw is the first-ever recipient of the world's first 3-D-printed titanium beak.

Resources last updated: 3/10/2016 12:12:10 PM