473,395 Members | 1,401 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,395 software developers and data experts.

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(ByVal sender As Object, ByVal e As
PrintPageEventArgs)
Dim iTotalPages As Integer = Math.Round(prntImg.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.DrawImage(prntImg, 0, 0, srcRect,
GraphicsUnit.Pixel)

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.PrintPage, AddressOf PrintImage
printer.Print()
Catch ex As Exception
Log("PRINTER ERROR: " & ex.Message,
EventLogEntryType.Error)
End Try
End Sub

===== END CODE ====

Mar 20 '07 #1
0 1326

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

Similar topics

0
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...
3
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...
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...
1
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...
1
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...
8
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...
1
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...
3
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.