Solved

Issues with printing .tiff images through VB 6 application

Posted on 2004-09-22
6
3,657 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:sgayatri
ID: 12131095
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
ID: 12131452
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
ID: 12133034
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Accepted Solution

by:
dbrckovi earned 125 total points
ID: 12136168
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
ID: 12137134
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
ID: 12137629
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 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