Prev: EjectNtmsMedia
Next: MSCOMM and Binary
From: Mike Williams on 8 Aug 2006 17:09 "Helge Haensel" <dj1wm(a)nurfuerspam.de> wrote in message news:op.tdzettaasjedh2(a)hhh... > Killed my pdf995-driver due to blocked job in PDF-printer > queue. Were did you get your your version 7.9. The official > PDF-web-Page is unreachable. I got it from: http://www.pdf995.com/download.html The site is working fine here, and all the downloads are available. Tomorrow I'll try to download VB5 SP3 and try it myself. I'll let you know how it goes. Mike
From: Mike Williams on 8 Aug 2006 17:37 .. . . by the way, I've just downloaded and installed VB5 SP3 and the code works fine, printing to the PDF995 driver (version 7.9) without any problems. Here is the code I'm currently using. I can't see any reason why it shouldn't work just as well at your end. I'm using the freeware version of PDF995, which defaults to displaying the pdf as soon as it has created it, and the file itself is generated fine and is exactly where you select to save it. p.s. Thanks to Geoff for the link to the service pack. Mike Option Explicit Private Const OUT_DEFAULT_PRECIS = 0 Private Const CLIP_DEFAULT_PRECIS = 0 Private Const DEFAULT_QUALITY = 0 Private Const DEFAULT_PITCH = 0 Private Const FF_ROMAN = 16 Private Const CCHDEVICENAME = 32 Private Const CCHFORMNAME = 32 Private Const GMEM_MOVEABLE = &H2 Private Const GMEM_ZEROINIT = &H40 Private Const DM_DUPLEX = &H1000& Private Const DM_ORIENTATION = &H1& Private Const PD_PRINTSETUP = &H40 Private Const PD_DISABLEPRINTTOFILE = &H80000 Private Const PHYSICALOFFSETX As Long = 112 Private Const PHYSICALOFFSETY As Long = 113 Private Const OPAQUE = 0 Private Const TRANSPARENT = 1 Private Type POINTAPI x As Long y As Long End Type Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type PRINTDLG_TYPE lStructSize As Long hwndOwner As Long hDevMode As Long hDevNames As Long hdc As Long flags As Long nFromPage As Integer nToPage As Integer nMinPage As Integer nMaxPage As Integer nCopies As Integer hInstance As Long lCustData As Long lpfnPrintHook As Long lpfnSetupHook As Long lpPrintTemplateName As String lpSetupTemplateName As String hPrintTemplate As Long hSetupTemplate As Long End Type Private Type DEVNAMES_TYPE wDriverOffset As Integer wDeviceOffset As Integer wOutputOffset As Integer wDefault As Integer extra As String * 100 End Type Private Type DEVMODE_TYPE dmDeviceName As String * CCHDEVICENAME dmSpecVersion As Integer dmDriverVersion As Integer dmSize As Integer dmDriverExtra As Integer dmFields As Long dmOrientation As Integer dmPaperSize As Integer dmPaperLength As Integer dmPaperWidth As Integer dmScale As Integer dmCopies As Integer dmDefaultSource As Integer dmPrintQuality As Integer dmColor As Integer dmDuplex As Integer dmYResolution As Integer dmTTOption As Integer dmCollate As Integer dmFormName As String * CCHFORMNAME dmUnusedPadding As Integer dmBitsPerPel As Integer dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As Long End Type Private Declare Function GetDeviceCaps Lib "gdi32" _ (ByVal hdc As Long, ByVal nindex As Long) As Long Private Declare Function PrintDialog Lib "comdlg32.dll" _ Alias "PrintDlgA" (pPrintdlg As PRINTDLG_TYPE) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias _ "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, _ ByVal cbCopy As Long) Private Declare Function GlobalLock Lib "kernel32" _ (ByVal hMem As Long) As Long Private Declare Function GlobalUnlock Lib "kernel32" _ (ByVal hMem As Long) As Long Private Declare Function GlobalAlloc Lib "kernel32" _ (ByVal wFlags As Long, ByVal dwBytes As Long) As Long Private Declare Function GlobalFree Lib "kernel32" _ (ByVal hMem As Long) As Long Private Declare Function SetBkMode Lib "gdi32" _ (ByVal hdc As Long, ByVal nBkMode As Long) As Long Private Sub SetPrinterOrigin(x As Single, y As Single) With Printer .ScaleLeft = .ScaleX(GetDeviceCaps(.hdc, PHYSICALOFFSETX), vbPixels, _ ..ScaleMode) - x .ScaleTop = .ScaleY(GetDeviceCaps(.hdc, PHYSICALOFFSETY), vbPixels, _ ..ScaleMode) - y .CurrentX = 0 .CurrentY = 0 End With End Sub Private Function PrintReport(frmOwner As Form, _ Optional InitialPrinter As String, _ Optional PrintFlags As Long) As Boolean Dim PrintDlg As PRINTDLG_TYPE Dim DevMode As DEVMODE_TYPE Dim DevName As DEVNAMES_TYPE Dim lpDevMode As Long, lpDevName As Long Dim bReturn As Integer, OriginalPrinter As String Dim objPrinter As Printer, NewPrinterName As String PrintDlg.lStructSize = Len(PrintDlg) PrintDlg.hwndOwner = frmOwner.hWnd PrintDlg.flags = PrintFlags On Error Resume Next ' save the current VB printer device name in case the user ' presses cancel and we need to restore it OriginalPrinter = Printer.DeviceName ' Set the initial printer in the dialog If Len(InitialPrinter) > 0 Then For Each objPrinter In Printers If InStr(1, objPrinter.DeviceName, InitialPrinter, _ vbTextCompare) > 0 Then Set Printer = objPrinter Exit For End If Next End If ' DevMode.dmDeviceName = Printer.DeviceName DevMode.dmSize = Len(DevMode) DevMode.dmFields = DM_ORIENTATION Or DM_DUPLEX DevMode.dmPaperWidth = Printer.Width DevMode.dmOrientation = Printer.Orientation DevMode.dmPaperSize = Printer.PaperSize DevMode.dmDuplex = Printer.Duplex On Error GoTo 0 PrintDlg.hDevMode = GlobalAlloc(GMEM_MOVEABLE Or _ GMEM_ZEROINIT, Len(DevMode)) lpDevMode = GlobalLock(PrintDlg.hDevMode) If lpDevMode > 0 Then CopyMemory ByVal lpDevMode, DevMode, Len(DevMode) bReturn = GlobalUnlock(PrintDlg.hDevMode) End If With DevName .wDriverOffset = 8 .wDeviceOffset = .wDriverOffset + 1 + Len(Printer.DriverName) .wOutputOffset = .wDeviceOffset + 1 + Len(Printer.Port) .wDefault = 0 End With With Printer DevName.extra = .DriverName & Chr(0) & .DeviceName _ & Chr(0) & .Port & Chr(0) End With PrintDlg.hDevNames = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, _ Len(DevName)) lpDevName = GlobalLock(PrintDlg.hDevNames) If lpDevName > 0 Then CopyMemory ByVal lpDevName, DevName, Len(DevName) bReturn = GlobalUnlock(lpDevName) End If If PrintDialog(PrintDlg) <> 0 Then DoEvents ' allow the dialog to remove itself from the display Me.Refresh PrintReport = True lpDevName = GlobalLock(PrintDlg.hDevNames) CopyMemory DevName, ByVal lpDevName, 45 bReturn = GlobalUnlock(lpDevName) GlobalFree PrintDlg.hDevNames lpDevMode = GlobalLock(PrintDlg.hDevMode) CopyMemory DevMode, ByVal lpDevMode, Len(DevMode) bReturn = GlobalUnlock(PrintDlg.hDevMode) GlobalFree PrintDlg.hDevMode NewPrinterName = UCase$(Left(DevMode.dmDeviceName, _ InStr(DevMode.dmDevic
From: Helge Haensel on 9 Aug 2006 07:22 Am 08.08.2006, 23:37 Uhr, schrieb Mike Williams <Mike(a)WhiskyAndCoke.com>: WindowsXP/HE SP2, OfficeXP/Pro SP3, VB5E > > . . . by the way, I've just downloaded and installed VB5 SP3 and the > code works fine, printing to the PDF995 driver (version 7.9) without any > problems. Here is the code I'm currently using. I can't see any reason > why it shouldn't work just as well at your end. I'm using the freeware > version of PDF995, i do too > which defaults to displaying the pdf as soon as it has created it, and > the file itself is generated fine and is exactly where you select to > save it. Nothing of these now here! See below. > <... snipped> Hi, Mike, problems, problems Sorry, i am a little bit stressed. A history of actions taken (08.08.2006): Checked my version vb5sp3.exe against vbsp3.exe from Geoff's link. They are identical in all aspects. Installed vb5sp3.exe. Replaced code here with yours newly supplied one. No diff's at all. Started code, dialogbox came up, print directed to PDF, seemed to work. But A-Reader didnt open! Checked pdf-printer queue, found 1 job, no kill, delete, restart possible. By fiddling around to clear the queue i killed the driver. DL of new one didnt succeed on the first try because i block the pdf-URL in the hosts-file to avoid the pdf-ads-screen. Fixed that. DL v7.9, installed it. Tried the code -> job sticks in queue. Tried with excel to print to pdf resulted in that the sticky first job was 'pressed out' of the queue and displayed but the excel-print is now sticky. Un-/installed pdf-driver (in the meantime i am really fast with that) to clear queue. A cold start seems to have the same effekt. Today (09.08.2006): Cold start of pc. Something happened, excel and other seem to print to pdf, the driver comes up asks where to store (ack) but no a-reader, no stored pdf-file somewhere, pdf-printer-queue empty. I HAVE A PROBLEM! Your code: Puts a sticky job in printerqueue. Un-/install .... Other tries put there jobs also in the queue without further actions. But these simply could be killed/deleted. Something is completely wrong with my system. Executed 'sfc /scannow': ran 6 mins, but no output, no hint. Scanned registry for entries with 'pdf995: folder DevMode2 contains some binary data for my hp and pdf printer. folder settings contains some binary data for my hp and pdf printer. There are entries under devices and printerports, looking allright. Under Print/Printers/pdf995 are several entries not looking bad. Under Print/Printers/pdf995/DsSpooler are several entries not looking bad. Under Print/Printers/pdf995/PrinterDriverData are several entries not looking bad. There some other entries in a folder PDF995Port and others and many entries show up duplicated (in different folders). I think all were in /HKLM/... Well as a stupid hobbyist i have no idea of correctnes of this entries. Probably i shall uninstall pdf995 and delete related entries if still any in the registry. I have an other pdf-driver on a cd. But i think that irritates only without helping here. The hp-printer works OK. I have a systemrestorepoint on 07.08. Probably i shall try that one. I'll think about it. BTW: vb5sp3.exe created a C:\DevStudio\VS7_SP3-folder with ~36 MB of contents. I think i can delete that one. OK? Vy 73! Helge
From: Helge Haensel on 9 Aug 2006 09:39 Am 09.08.2006, 13:22 Uhr, schrieb Helge Haensel <dj1wm(a)nurfuerspam.de>: <... snipped> Well, the sticky jobs (status: printing) i told about delete themselves automatically after 30 minutes. All that can be found afterwards is a 'some_name.pdf.lnk'. Vy 73! Helge
From: Mike Williams on 9 Aug 2006 10:23
"Helge Haensel" <dj1wm(a)nurfuerspam.de> wrote in message news:op.td0kkglbsjedh2(a)hhh... > Hi, Mike, problems, problems > Sorry, i am a little bit stressed. > A history of actions taken (08.08.2006): > Installed vb5sp3.exe. > Replaced code here with yours newly supplied one. No diff's at > all. Started code, dialogbox came up, print directed to PDF, seemed > to work. But A-Reader didnt open! Checked pdf-printer queue, > found 1 job, no kill, delete, restart possible. Well actually that *is different* from your original problem. If you remember, your original problem was that when using the VB printer object to print to a HP printer using CommonDialog Showprinter the orientation did not work. That's standard behaviour in WinXP. It happens because the only built in method the VB printer object has of finding out what choices the user made in the CommonDialog is to look at the new settings of the default printer (which by default the CommonDialog attempts to change). That method used to work in Win98, but it does not work in XP because although XP allows the CommonDialog to change the default printer it does not allow it to change any of its default properties, such as orientation or anything else. That is why when using the VB printer object you need to use a different method other than the standard CommonDialog control, and that is why you need to use the code I posted, or something similar. Your current reported behaviour also *is different* from your secondary problem, in which the printer completely ignored the PDF995 choice and instead printed to the default printer. That problem was caused by a bug in the VB printer object, and the VB5 service pack 3 fixed that problem for you because the VB printer object now *does* send its output to the chosen PDF995 driver. So, the problem you currently have is a *new problem*, and it is probably nothing at all to do with the code you are using or with VB itself. It is most likely a problem with your PDF995 driver itself or some of the system settings it is using. What you need to do right now is to "split the problem up into two possible halves" and see which half is actually causing the trouble. So, the very first thing you should do is to open the Windows Control Panel printer applet and right click the PDF995 driver and select "Set as Default Printer". When you have done that, try a simple: Printer.Print Printer.Print "This is a test" Printer.EndDoc Also (again after setting the PDF995 driver as the system default printer) create a fresh MS Word document (or NotePad document or whatever) and type just a few words into it and then print it, just clicking OK on the MSWord print dialog without altering any settings. Post back with the result of both of those actions. > BTW: vb5sp3.exe created a C:\DevStudio\VS7_SP3-folder > with ~36 MB of contents.I think i can delete that one. OK? Yep. You can delete that folder. The service pack contains service components for all parts of the Visual Studio setup, and only a small part of it is actually used for the VB5 update. You do of course need to run the Setup.exe file which is inside that folder, but once you have done so you can delete the entire folder. Then, just to make sure, open up VB5 and use the menu Help / About and it should show you (in brackets after the Visual Basic name) what service pack is installed. I would suggest that you hang on to the original compressed vbsp3 (or vb5sp3) file though, just in case you need it again in the future. Anyway, use the Control Panel printer applet to set your Windows default printer to PDF995 and then try the two small tests I have suggested and post back with detailed results Mike Williams (MVP - Visual Basic) |