Solved

Issues with printing .tiff images through VB 6 application

Posted on 2004-09-22
6
3,623 Views
Last Modified: 2013-12-26
Hi,

I am trying to print a .tiff image from VB 6 application. ImgEdit1.PrintImage is printing the image but in slightly expanded size.  The original image when printed individually is exactly fitting the page but when printed through the VB application, it is getting cut on the right hand side.  Any clue why is it happening and any possible solutions?

I appreciate your help.
0
Comment
Question by:sanagavarapu
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:sgayatri
Comment Utility
Use Kodak image admin control
replace form1 with your form name in the following code and try

 ImgAdmin1.Image = ImgEdit1.Image
   ImgAdmin1.PrintRangeOption = PrintAll
   ImgAdmin1.ShowPrintDialog (form1.hWnd)
   ImgAdmin1.CancelError = True
   ImgEdit1.PrintImage ImgAdmin1.PrintStartPage, ImgAdmin1.PrintEndPage, ImgAdmin1.PrintOutputFormat, True
0
 
LVL 11

Expert Comment

by:dbrckovi
Comment Utility
Hi!

Be carefull with Kodak's Imaging controls if you are planning to distribute your application.
WinXP doesn't have these controls, and it's illegal to distribute them with your applicatnion in any way.
0
 

Author Comment

by:sanagavarapu
Comment Utility
Hi dbrckovi,
Thanks for reminding me that Kodak Imaging control does not work with WinXP. Fortunately my OS is Win2000.

Hi sgayatri,

Let me repeat my problem - download a .tif file from the internet or create one using any imaging application like Paint Shop or Kodak Imaging application(comes with any standard windows installation under Programs - accessories - Imaging) and print it. Now using the piece of code you suggested in VB print it again. When you compare both printouts, second copy will be slightly bigger than the first copy.

Your suggested solution does not help me in this case because my application will be printing several hundred images in a given folder and I do not intend to display the print control dialogue box every time. The images should be continuously printed to the default printer.  I tested your piece of code and Image control is still enlarging the images while printing.  I would like to know how to avoid that or is there anyway to make the image fit to the page while printing.

I appreciate your time though.

Any other suggestions? Thanks.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 11

Accepted Solution

by:
dbrckovi earned 125 total points
Comment Utility
Hi again.

I wanted to post this sollution earlier but I thought sgayatri's sollution will work, and as you'll see mine is not very elegant.


I had the same problem in my last project, and I solved it by using Printer object.
These are the steps I was using for printing:

- load the TIFF image in ImageEdit control

- save the TIFF image in BMP format:             ImgEdit.SaveAs App.path & "\temp.bmp", 3, 1, 1, 0, False

- load the picture in invisible picture box:        picTemp.Picture = LoadPicture(App.path & "\temp.bmp")

- set Printer settings:

        Printer.ScaleMode = vbPixels
        Printer.ScaleTop = 0
        Printer.ScaleLeft = 0
        Printer.ScaleWidth = 8 * frmMain.ImgCopy.ImageResolutionX
        Printer.ScaleHeight = 11.5 * frmMain.ImgCopy.ImageResolutionY

 - position the picture on a page:            Printer.PaintPicture picTemp.Picture, x, y, ImgEdit.ImageWidth, ImgEdit.ImageHeight
      ( where x and y are coordinates of pictures top-left corner)

 - send the page to printer:
       Printer.EndDoc


Note these two lines:
        Printer.ScaleWidth = 8 * frmMain.ImgCopy.ImageResolutionX
        Printer.ScaleHeight = 11.5 * frmMain.ImgCopy.ImageResolutionY

I got 8 and 11.5 by printing the scanned image and comparing the result with the original.

P.S.
I'm not sure, but if I remember correctly, the printed image will be smaller than the original for few percent, but you can play with these values to get it out perfectly.
0
 

Author Comment

by:sanagavarapu
Comment Utility
Hi dbrckovi,

I like your idea and that is why I am accepting the answer.

I have one concern though. Printing a bmp file could lead to perfomance issues because bmp images are usually large in size compared to tiff and when I am talking about hundreds of images everyday, the additional time required to complete the job could be multiplied several times.

I did some research on the internet and evaluated few other controls and found the better replacement for Kodak Image Edit Control in "ImageViewerCP ActiveX Control" developed by Viscomsoft (http://www.viscomsoft.com/products/imageviewercp/).  The developer licence costs USD 60. It has more features than Kodak to convert the file formats, print the images reduced/enlarged, add annotations etc. I thought it is worth spending $60 keeping in mind the processing time I am gaining on a daily basis.
0
 
LVL 11

Expert Comment

by:dbrckovi
Comment Utility
Thanks for accepting.

I agree. This method is much slower, but it's still faster than any printer can print, and if you delete the temp.bmp after processing an image, it doesn't consume much disk space either.

I also thought about buying souch control becouse our company works with TIFF images a lot, but for now we're using ImageEdit.
(We'll first upgrade to .NET. Maybe it provides something for manipulating TIFF images.)

Regards!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now