Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing TIFF w/ Kodak ActiveX Control 1

Status
Not open for further replies.

Gameboy9

Programmer
Jun 8, 2001
39
0
0
US
I'm attempting to be able to print a TIFF file with the Kodak ActiveX Control. (the PrintImage method) I'm successful, save one problem: it uses the default printer, and the default settings.

My superiors would like to have the ability to print in landscape mode. I'd like to have this accomplished without the users changing the default printer settings all of the time. (default for most workmates is portrait)

There's a parameter where you can pass the hDC, but I have been currently unsuccessful, even using Tek-Tips's faq 184-3770. (Courtesy: Mike Gagnon)

I used the same code as said faq, with a small modification:

If PrintDlg (@lcStruct) <> 0
hDc = buf2dword (Substr (lcStruct, 17, 4)) && same as FAQ
* I don't use delete hDC because I want to keep it for the PrintImage method
Else
RETURN .f.
Endif

thisform.viewtiff.printImage(1,1,2,.f.,hDc)

... but the last line gives me an error: invalid printer name.

If you know of a solution to this problem, I'd be highly grateful. Thanks!
 
Gameboy9

Maybe you need to force a Default Windows printer temporarely pior to printing your image. Take a look at faq184-4140 under the heading &quot;How to set a Windows default printer &quot;


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I use the Kodak Image Admin control to print.

I created a form with:
1. oleImageAdmin = Kodak Image Admin control.
2. oleImageEdit = Kodak Image Edit control

Here is my code to print:

WITH THISFORM.oleImageAdmin.Object

* Set filename to be printed to the displayed file. If this property
* is not set the dialog box will not display.
.Image = THISFORM.oleImageEdit.Object.Image
.PageNumber = THISFORM.oleImageEdit.Object.Page
* Reset NumCopies in case user printed multiple copies last time.
.PrintNumCopies = 1

* Make sure .oleImageAdmin.CancelError is True.
* That will trigger an error if user cancels print dialog.
TRY
* - If you don't pass form handle, you get a modeless dialog.
* - If user cancels dialog, goes to &quot;CATCH&quot;.
.ShowPrintDialog( THISFORM.HWnd )
* Print the Image using the options selected in the dialog.
*Syntax: PrintImage( [StartPage,EndPage,OutputFormat,Annotations,Printer,Driver,PortNumber] )
IF .PrintRangeOption = 2
* Current page.
THISFORM.oleImageEdit.Object.PrintImage( .PageNumber, ;
.PageNumber, ;
.PrintOutputFormat )
ELSE
* All pages or pages selected.
THISFORM.oleImageEdit.Object.PrintImage( .PrintStartPage, ;
.PrintEndPage, ;
.PrintOutputFormat )
ENDIF

CATCH
*
ENDTRY

ENDWITH && THISFORM.oleImageAdmin.Object


Andy Rice
San Diego, CA
 
Andy:

That worked perfectly! Thanks a lot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top