Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - printing on Windows 98
  FAQ FAQ  Forum Search   Register Register  Login Login

printing on Windows 98

 Post Reply Post Reply
Author
Message
hbarclay View Drop Down
Team Player
Team Player


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 39
Post Options Post Options   Thanks (0) Thanks(0)   Quote hbarclay Quote  Post ReplyReply Direct Link To This Post Topic: printing on Windows 98
    Posted: 14 Mar 06 at 5:26PM
I thought I had seen this question answered previously, but I don't seem to find it now.

I am using the Quickpdf object to create and print pdf files to HP laser printers. On Windows XP systems everything works great. On Windows 98 machines (second edition) it will not print and returns "Printer selected is not valid".

Is this a known issue that someone else has already solved?

Thanks
Harry

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 15 Mar 06 at 2:25AM
Hi Harry!

This works on my machines...

    fa := FileGetAttr(Trim(Edit1.Text));
    FileSetAttr(Trim(Edit1.Text), faArchive);

    QP := TiSEDQuickPDF.Create;
    try
       QP.UnlockKey('mykey');
       QP.LoadFromFile(Edit1.text);

       If QP.Encrypted > 0 Then
          QP.Unencrypt;
       pc := QP.PageCount;

       prName     := QP.GetDefaultPrinterName();
       prOptions := QP.PrintOptions(2, 1, Edit1.Text);
       QP.PrintDocument(prName, 1, pc, prOptions);

    finally

       QP.Free;
       FileSetAttr(Trim(Edit1.Text), fa);

    end;

The next code is more easy and should work, too...

// ShellExecute(hinstance,'open',PChar(c),PChar('/p ' + Edit1.Text),nil,SW_SHOWNORMAL);
Back to Top
hbarclay View Drop Down
Team Player
Team Player


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 39
Post Options Post Options   Thanks (0) Thanks(0)   Quote hbarclay Quote  Post ReplyReply Direct Link To This Post Posted: 15 Mar 06 at 11:45AM
Ingo,

Thanks for the help.

I changed the code slightly, but I think what I have below is pretty much the same as what you had except for the hard coding of the file name. On XP this works fine, but on our Windows 98 machines I get "Printer selected is not valid". The printer I am currently trying to print to is an HP 1320tn, but I have also tried using an HP 4550 and an HP 4000.

What version of Win98 are you using?
What printer are you using?

I'm sure the shellexecute would print fine, but we need for this to work without user intervention, and we need more control over the printer than that would allow.

Does the following code work on your Win98 machine?

Thanks again
Harry

   //FileName := 'Xtlearlp.pdf';
FileName := 'RegCC.pdf';

fa := FileGetAttr(FileName);
    FileSetAttr(FileName, faArchive);

    QP := TiSEDQuickPDF.Create;
    try
      QP.UnlockKey(Mykey);
       QP.LoadFromFile(FileName);

       If QP.Encrypted > 0 Then
          QP.Unencrypt;
       pc := QP.PageCount;

       prName     := QP.GetDefaultPrinterName();
       prOptions := QP.PrintOptions(2, 1, FileName);
       QP.PrintDocument(prName, 1, pc, prOptions);

    finally

       QP.Free;
       FileSetAttr(FileName, fa);

    end;
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 15 Mar 06 at 3:55PM
Hi!
I'm using win xp home and pro and win98se.
Sorry for this question: On the win98-system you've marked a printer as default? ;-)
What about to get the printername with a function out of quickpdf? You should google a bit...
Best regards,
Ingo
Back to Top
hbarclay View Drop Down
Team Player
Team Player


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 39
Post Options Post Options   Thanks (0) Thanks(0)   Quote hbarclay Quote  Post ReplyReply Direct Link To This Post Posted: 15 Mar 06 at 6:06PM
I understand the question about the default, I regularly solve problems by asking tellers if they have their receipt printer turned on. It's amazing how many times they don't.

Yes it is the default. In our application we put the printer name in rather than using default, but for this test I am duplicating your suggested code using the default.

The problem seems to be in the uiSEDQuickPDF creation of the tPrinter object. I have a printer named "Test". On Windows 98 it is passing the printer name as "Test on <insert ip address here>" on the network and on my VMWare test it is showing the port name as a part of the printer name. That seems to be causing some confusion and preventing the object from being created.

No time left today, but I'll try to figure it all out on Thursday.

Thanks
Harry

Back to Top
hbarclay View Drop Down
Team Player
Team Player


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 39
Post Options Post Options   Thanks (0) Thanks(0)   Quote hbarclay Quote  Post ReplyReply Direct Link To This Post Posted: 16 Mar 06 at 1:13PM
My guess about the cause was correct. The QP.PrintDocument function is in uiSedQuickPdf.pas and it contains this line

LocalPrinter.SetPrinter(@OriginalPrinterName[1], 'WINSPOOL', '', 0);

On XP machines the GetPrinterName is returning just the name of the printer. On Win98 machines the name it returns includes the port number. On XP the printer would be "HP Color LaserJet 4550" and on Win98 it would be "HP Color LaserJet 4550 on 192.168.1.198".

If the full name including port is passed to the SetPrinter function it will fail. If I strip off the " on..." portion of what is returned and just send the name, it works fine.

I guess I'm having a hard time understanding why this fails on my computers and on my customers computers, but works on Ingo's machines and I'm assuming everyone elses since no one has complained of this issue previously.

Harry

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 17 Mar 06 at 1:53AM
Hi Harry!

First it seems easy... strip all at " on"...
But do you know how many printer names are out there?

Using Google i found this:

uses printers

Printer.PrinterIndex := -1;
Result := Printer.Printers.Strings[Printer.PrinterIndex];

Actually i could try it only on win xp pro... and it works. Please tell me if it's working in win98, too.

Best regards,
Ingo


Edited by Ingo
Back to Top
hbarclay View Drop Down
Team Player
Team Player


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 39
Post Options Post Options   Thanks (0) Thanks(0)   Quote hbarclay Quote  Post ReplyReply Direct Link To This Post Posted: 17 Mar 06 at 9:24AM
Ingo,

Stripping the ' on ' was just a test to see if that was the issue, the actual work around is a little more involved.

The code you just posted (Result := Printer.Printers.Strings[Printer.PrinterIndex]) does not work on Windows 98, although it works fine on XP and should work fine on any windows system of NT or newer.

The root of the problem seems to be in the TPrinters Delphi object, specifically in the TPrinter.Getprinters function where it builds the list of printer names. That function checks the Win32Platform flag and if it is VER_PLATFORM_WIN32_NT then it will use a TPrinterInfo4 record to add the printer object and just add the Device Name to the stringlist as the printer name. However if it is not VER_PLATFORM_WIN32_NT then it uses a TPrinterInfo5 object and in the addobject call it uses this for the PrinterName parameter (Format(SDeviceOnPort, [pPrinterName, Port]). SDeviceOnPort is a resourcestring defined as '%s on %s'.

My solution to the problem is to loop through the printers using printer.printers.count and for each one make a call to printer.GetPrinter(Device,Driver,Port,DevMode). The Device parameter will be the printer name. This is a little slower that just checking the already created TStringlist, but it seems to work on 98 and XP.

What is really baffling me is why this is not an issue on your Windows 98 machine. What version of Delphi are you using? I don't have D6 installed anymore, but I checked on D7 and D2006 and both TPrinter objects are working the same way.

Thanks for the help
Harry
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store