Problème Urgent d'Impression PDF

B_Gates Messages postés 5 Date d'inscription lundi 24 janvier 2005 Statut Membre Dernière intervention 28 novembre 2005 - 25 nov. 2005 à 17:31
B_Gates Messages postés 5 Date d'inscription lundi 24 janvier 2005 Statut Membre Dernière intervention 28 novembre 2005 - 28 nov. 2005 à 08:57
Je dois réaliser un programme qui imprime des PDF à la volée. Pour ce faire, j'utilise la fonction de l'API ShellExecute.

Or je ne peut détecter si mon impression s'est bien déroulée ou non.

J'aimerais donc savoir comment fait-on pour détecter si l'impression est en route, s'est bien passé ou s'il y a eu une erreur.

Merci pour vos réponses

3 réponses

Julien237 Messages postés 883 Date d'inscription vendredi 3 novembre 2000 Statut Membre Dernière intervention 3 mars 2009 7
25 nov. 2005 à 20:51
Voilà, je viens de pondre ceci (merci MSDN : ) ):



Private Declare Function GetPrinter
Lib "winspool.drv" Alias "GetPrinterA" (ByVal hPrinter As Long, ByVal
Level As Long, pPrinter As Any, ByVal cbBuf As Long, pcbNeeded As Long)
As Long

Private Declare Function OpenPrinter Lib "winspool.drv" Alias
"OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long,
pDefault As Any) As Long



Private Enum PrinterStatus

PRINTER_STATUS_BUSY = &H200

PRINTER_STATUS_DOOR_OPEN = &H400000

PRINTER_STATUS_ERROR = &H2

PRINTER_STATUS_INITIALIZING = &H8000

PRINTER_STATUS_IO_ACTIVE = &H100

PRINTER_STATUS_MANUAL_FEED = &H20

PRINTER_STATUS_NO_TONER = &H40000

PRINTER_STATUS_NOT_AVAILABLE = &H1000

PRINTER_STATUS_OFFLINE = &H80

PRINTER_STATUS_OUT_OF_MEMORY = &H200000

PRINTER_STATUS_OUTPUT_BIN_FULL = &H800

PRINTER_STATUS_PAGE_PUNT = &H80000

PRINTER_STATUS_PAPER_JAM = &H8

PRINTER_STATUS_PAPER_OUT = &H10

PRINTER_STATUS_PAPER_PROBLEM = &H40

PRINTER_STATUS_PAUSED = &H1

PRINTER_STATUS_PENDING_DELETION = &H4

PRINTER_STATUS_PRINTING = &H400

PRINTER_STATUS_PROCESSING = &H4000

PRINTER_STATUS_TONER_LOW = &H20000

PRINTER_STATUS_USER_INTERVENTION = &H100000

PRINTER_STATUS_WAITING = &H2000

PRINTER_STATUS_WARMING_UP = &H10000

End Enum



Private Type PRINTER_INFO_6

dwStatus As Long

End Type



Private Function GetPrinterState(PrinterName As String) As PrinterStatus

Dim PrinterHwnd As Long, PI As PRINTER_INFO_6, S As Long

OpenPrinter PrinterName, PrinterHwnd, ByVal 0

GetPrinter PrinterHwnd, 6, PI, Len(PI), S

GetPrinterState = PI.dwStatus

End Function



Si tu utilise CutePDF pour faire tes pdf, le paramètre de GetPrinterState doit être "CutePDF Writer".



Julien.
0
B_Gates Messages postés 5 Date d'inscription lundi 24 janvier 2005 Statut Membre Dernière intervention 28 novembre 2005
28 nov. 2005 à 08:32
Merci pour ta réponse Julien.

J'essaie cela et je te tiens au courant.
0
B_Gates Messages postés 5 Date d'inscription lundi 24 janvier 2005 Statut Membre Dernière intervention 28 novembre 2005
28 nov. 2005 à 08:57
J'ai essayé et la fonction GetPrinterState me retourne toujours 0.

Pour info, 'imprime mes PDF grace à l'API Shellexecute :

ShellExecute(handle, "print", Chemin_Facture, nil, nil, SW_HIDE)

Ce qui imprime les documents avec le programme par défaut c'est à dire Adobe Acrobat Reader.

Je sens que nous ne sommes pas loin de la réponse.
0
Rejoignez-nous