|
-
October 4th, 2001, 09:42 AM
#1
Printing EMF
i need to print a emf file
i'm using this code, and i get a message saying "no print job...." when printing to acrobat distiler. Can you help me?
Code:
' ***************
' Win32 API Calls
' ***************
private Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (byval lpAppName as string, byval lpKeyName as Any, byval lpDefault as string, byval lpReturnedString as string, byval nSize as Long) as Long
private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (byval pPrinterName as string, phPrn as Long, pDefault as Any) as Long
private Declare Function StartDocPrinter Lib "winspool.drv" Alias "StartDocPrinterA" (byval hPrn as Long, byval Level as Long, pDocInfo as DOC_INFO_1) as Long
private Declare Function StartPagePrinter Lib "winspool.drv" (byval hPrn as Long) as Long
private Declare Function EndPagePrinter Lib "winspool.drv" (byval hPrn as Long) as Long
private Declare Function EndDocPrinter Lib "winspool.drv" (byval hPrn as Long) as Long
private Declare Function ClosePrinter Lib "winspool.drv" (byval hPrn as Long) as Long
private Declare Function GetEnhMetaFile Lib "gdi32" Alias "GetEnhMetaFileA" (byval lpszMetaFile as string) as Long
private Declare Function GetEnhMetaFileHeader Lib "gdi32" (byval hEMF as Long, byval cbBuffer as Long, lpemh as ENHMETAHEADER) as Long
private Declare Function PlayEnhMetaFile Lib "gdi32" (byval hDC as Long, byval hEMF as Long, lpRect as Any) as Long
' *********************************************
' Estrutura requerida pelo GetEnhMetaFileHeader
' *********************************************
private Type RECT
LEFT as Long
Top as Long
Right as Long
Bottom as Long
End Type
private Type SIZEL
cx as Long
cy as Long
End Type
private Type ENHMETAHEADER
iType as Long
nSize as Long
rclBounds as RECT
rclFrame as RECT
dSignature as Long
nVersion as Long
nBytes as Long
nRecords as Long
nHandles as Integer
sReserved as Integer
nDescription as Long
offDescription as Long
nPalEntries as Long
szlDevice as SIZEL
szlMillimeters as SIZEL
End Type
' ****************************************
' Estrutura requerida pelo StartDocPrinter
' ****************************************
private Type DOC_INFO_1
pDocName as string
pOutputFile as string
pDatatype as string
End Type
public Sub SpoolFile(sFile as string, PrnName as string, optional AppName as string = "")
Dim hPrn as Long
Dim hEMF as Long
Dim di as DOC_INFO_1
Dim emh as ENHMETAHEADER
' **********************************
' Define DOC_INFO_1 e abre print Job
' **********************************
di.pDocName = sFile
di.pOutputFile = vbNullString
di.pDatatype = "RAW"
' *******************************
' Prepara e inicializa impressora
' *******************************
Call OpenPrinter(PrnName, hPrn, byval 0&)
Call StartDocPrinter(hPrn, 1, di)
Call StartPagePrinter(hPrn)
' *****************************************
' Abre ficheiro e envia-o para a impressora
' *****************************************
hMF = GetEnhMetaFile(sFile)
Call GetEnhMetaFileHeader(hMF, len(emh), emh)
Call PlayEnhMetaFile(hDC, hEMF, emh.rclBounds)
' ******************************
' Termina o processo de spolling
' ******************************
Call EndPagePrinter(hPrn)
Call EndDocPrinter(hPrn)
Call ClosePrinter(hPrn)
End Sub
Last edited by Cimperiali; July 30th, 2004 at 04:39 AM.
Reason: Adding Code tags
-
July 29th, 2004, 08:02 AM
#2
Instead of using
OpenPrinter
StartDocPrinter
StartPagePrinter
EndPagePrinter
EndDocPrinter
try using
CreateDC
StartDoc
StartPage
EndPage
EndDoc
instead. this should work for playing an EMF to a DC.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|