Solved

Issues with printing .tiff images through VB 6 application

Posted on 2004-09-22
6
3,645 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
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

820 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