473,624 Members | 2,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printing Large image Files in VB.NET

I have written the below class for printing out large jpg files (1
page wide, multiple pages high) over multiple pages. The class will
get instantiated multiple times at once by a windows service.

For each page that the class prints, it gets visibly slower, when the
third document, third page and onwards starts to print, it takes over
20 seconds a page, am I doing something wrong, or is this the wrong
way to go about the task (could be printing 20 documents at 10 second
intevals), if so, can you suggest a better way?

Kind Regards,

Ben.

===== CODE ====

Private Sub PrintImage(ByVa l sender As Object, ByVal e As
PrintPageEventA rgs)
Dim iTotalPages As Integer = Math.Round(prnt Img.Height /
(prntImg.Width * (2 ^ 0.5)))
Dim srcRect As New RectangleF(0, prntiPage * (prntImg.Width *
(2 ^ 0.5)), prntImg.Width, prntImg.Width * (2 ^ 0.5))

e.Graphics.Draw Image(prntImg, 0, 0, srcRect,
GraphicsUnit.Pi xel)

If prntiPage = iTotalPages - 1 Then
e.HasMorePages = False
Else
prntiPage += 1
e.HasMorePages = True
End If
End Sub

Sub New(ByVal sImgagePath)
Try
prntImg = Image.FromFile( sImgagePath)
Dim printer As PrintDocument = New PrintDocument
AddHandler printer.PrintPa ge, AddressOf PrintImage
printer.Print()
Catch ex As Exception
Log("PRINTER ERROR: " & ex.Message,
EventLogEntryTy pe.Error)
End Try
End Sub

===== END CODE ====

Mar 20 '07 #1
0 1335

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1942
by: lubprog | last post by:
hi, I am printing jpg files which are on a disk. The file name is selected from a database and the file is located on the disk and then printed. I am able to print the file but it takes a long time to do it(between 35-40 seconds). I am posting the code in the print event handler , please suggest how i can speed up the printing.btw i am printing to a network printer. string name =
3
2063
by: Brad | last post by:
I'm working on a web app which will display LARGE tiff image files (e.g files 10-20+ mb). Files are hidden from users direct access. For other, smaller image files I have used FileStream to read in a file in a single Read and so my quesitons are: (1) What is a practical file size limit for reading using FileStream.Read (reading the file in a single read)...especially on a web server where I don't think I'd want to tax memory...
1
5699
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 of a Microsoft book, "Visual Basic,Net Step by Step" in Chapter 18. All but the bottom two subroutines will open a text file, and then allow me to use the above controls, example 1. The bottom two subroutines will print a graphic file, example...
1
1212
by: Jos Roijakkers | last post by:
I am writing a program in Visual Studio 2005 (VB) that can print scanned images (saved as jpg-files). The printing is done by the following code: Private Sub pdoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument.PrintPage Dim i As Integer Dim intPrintAreaHeight, intPrintAreaWidth, marginLeft, marginTop As Int32 With PrintDocument.DefaultPageSettings
1
1969
by: ian.hubling | last post by:
I'm not sure if this is a javascript or a CSS issue... I'm looking for a way to force the printing of a background image when a page is printed. I'm dealing with a couple of large corporate policy manuals. Some of the material is archived. The archived pages have watermarks to visually identify them as outdated material. However, if the user has printing of background images turned off, how can I override this? This is also a...
8
5885
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web clients (Internet Explorer). My flash content was originally brought in via the “flash satay” method, but I have since used some server-side magic do deliver one <objecttag
1
3805
by: jake | last post by:
When I draw (using DrawString() and other Draw...() methods) directly to the PrintDocument using the PrintDocument's PrintPageEventArgs e, the print-out comes out nice and sharp. But when I direct my graphics to memory first then using PrintDocument's PrintPageEventArgs e.DrawImage(), I get the image printed with the right scale and everything, but the characters and everything else is blurry, out of focus and just generally very bad. ...
3
2940
by: =?Utf-8?B?dGtpZWhs?= | last post by:
I have large 1bpp tiff scans of arch. drawings that are typically 12032x16890 pixels (filesize is about a 1 meg +/-) While I can readily view smaller (dimension) files, when I try to do anything after loading I've looked at most of the samples on the web in using GDI+... they all fall over dead with these large files. Any help is appreciated.
0
1680
by: gnewsgroup | last post by:
In my asp.net 2.0 web application. I create chart images on the fly by getting the data from the database. These chart images all have fixed width, but the height is dynamic depending on the number of rows in the table returned from the database. These chart images are put into an HTML table through code-behind. They display nicely in either IE or FireFox. But, there is a problem printing them when the chart image is too big to fit...
0
8685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2613
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.