473,321 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

print document in vb.net 2.0

There is mapcontrol containing map in my application. I want to print it. I placed printpreviewdialog n print control on my page. it is showing preview well. my requirement is, I want to print this map as well as want to write some text on it. I want all this in preview as well as in print.
How can I write text on it?
thks
Apr 23 '08 #1
1 2552
deric
92
I have not tried using map control yet, but i guess you can try printing the map with a DrawImage. If there's an "image" attribute of the map control then you can set it as the parameter of the DrawImage.
Maybe there's another way but you can get an idea from this sample:

Expand|Select|Wrap|Line Numbers
  1. 'I have a form with a button and a picturebox named Button1 and PictureBox1, respectively.
  2. Imports System.Drawing.Printing
  3. ...
  4. Private WithEvents pd As New PrintDocument
  5. Private prev As New PrintPreviewDialog
  6.  
  7. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  8.         prev.Document = pd
  9.         prev.Show()
  10. End Sub
  11.  
  12. 'Let's say that the image set to the PictureBox is 100x100, and we need to print a text on it at x=50, y=30 location.
  13. Private Sub pd_Print(ByVal sender As System.Object, ByVal e As PrintPageEventArgs) Handles pd.PrintPage
  14.         e.Graphics.DrawImage(PictureBox1.Image, 0, 0)
  15.         e.Graphics.DrawString("Hello World", New Font("Arial", 10), Brushes.White, 50, 30)
  16. End Sub
If you'd like, you can dynamically calculate the x and y locations of every image or text you print (consider the paper's size and the margins).
You can read more about PrintDocument here.
Apr 24 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: dan | last post by:
This works in mozilla but I can't figure out why this won't work in IE. Say I have this html <html> header goes here header goes here
4
by: Julie Siebel | last post by:
Apologies...I'm sure this has been asked before, but I can't seem to come up with the correct Google search terms. While my problem is with stylesheets, the errors are being caused by my...
3
by: Craig | last post by:
First of all, this one is driving me crazy, so thanks in advance for any help!! I've got a javascript function in a parent document that generates an HTML document on the fly when a button is...
21
by: Steel | last post by:
Hi at all, I have a very long html page with many photo. Therefore the best to print this page is to print the some page as PDF. Therefore I maked a PDF file like my page to print best. I'ld want...
2
by: Asad | last post by:
I have a main window that creates a new window called printWin (which contains the printable format of the page). From the main window I embed a javascript in the printWin window that calls the...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
22
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the...
10
by: jon | last post by:
I'm trying to use a hidden iframe to print the contents of one div seamlessly. Currently I can create the hidden iframe, copy the contents of the div to the iframe, and print it. I even have a...
2
by: Brad Pears | last post by:
I have some sample code that uses the print dialog, print preview and a print direct options. If I select print preview and then click the printer icon from that, the document prints. If I...
10
by: S_K | last post by:
Hi, I have a directory full of a number of .PDF files that I need to print. Is there any simple way to do this? Using PdfReader purhaps? Thanks in advance. Steve
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.