Parametrer une impression

Forum destiné aux questions sur le développement : Formules, LotusScript, Java ...

Parametrer une impression

Messagepar Niclos » 22 Déc 2003 à 17:14

Bonjour,J'aimerais s'il est possible de parametrer une impression pour que les masques s'impriment en Paysage ?Merci d'avance.[%sig%]
Niclos
 

Re: Parametrer une impression

Messagepar Stephane Maillard » 22 Déc 2003 à 18:49

Bonjour,Voici un code que j'utilise en VB, il faut certainement l'adapté pour le Lotus Script :Type DIVT quot As Long remain As LongEnd TypePrivate Type PRINTER_DEFAULTS pDatatype As Long pDevmode As Long DesiredAccess As LongEnd TypePrivate Type PRINTER_INFO_2 pServerName As Long pPrinterName As Long pShareName As Long pPortName As Long pDriverName As Long pComment As Long pLocation As Long pDevmode As Long pSepFile As Long pPrintProcessor As Long pDatatype As Long pParameters As Long pSecurityDescriptor As Long Attributes As Long Priority As Long DefaultPriority As Long StartTime As Long UntilTime As Long Status As Long cJobs As Long AveragePPM As LongEnd TypeType DEVMODE dmDeviceName As String * 32 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 * 32 dmUnusedPadding As Integer dmBitsPerPel As Integer dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As Long dmICMMethod As Long dmICMIntent As Long dmMediaType As Long dmDitherType As Long dmReserved1 As Long dmReserved2 As LongEnd TypeDeclare Function ClosePrinter Lib "winspool.drv" (Byval hPrinter As Long) As LongDeclare Function DocumentProperties Lib "winspool.drv"_Alias "DocumentPropertiesA" (Byval hwnd As Long, _Byval hPrinter As Long, Byval pDeviceName As String, _pDevModeOutput As Long, pDevModeInput As Long, _Byval fMode As Long) As LongDeclare Function GetPrinter Lib "winspool.drv" Alias _"GetPrinterA" (Byval hPrinter As Long, Byval Level As Long, _pPrinter As Long, Byval cbBuf As Long, pcbNeeded As Long) As LongDeclare Function OpenPrinter Lib "winspool.drv" Alias _"OpenPrinterA" (Byval pPrinterName As String, phPrinter As Long, _pDefault As PRINTER_DEFAULTS) As LongDeclare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" (Byval hPrinter As Long,_Byval Level As Long, pPrinter As Long, Byval commandl As Long) As LongDeclare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" _(pDest As DEVMODE, pSource As Long, Byval cbLength As Long)Declare Sub CopyMemoryBack Lib "Kernel32" Alias "RtlMoveMemory" _(pDest As Long, pSource As DEVMODE, Byval cbLength As Long)Declare Sub CopyMemoryPI Lib "Kernel32" Alias "RtlMoveMemory" _(pDest As PRINTER_INFO_2, pSource As Long, Byval cbLength As Long)Declare Sub CopyMemoryBackPI Lib "Kernel32" Alias "RtlMoveMemory" _(pDest As Long, pSource As PRINTER_INFO_2, Byval cbLength As Long)Declare Function labs Lib "msvcrt.dll" Alias "labs"_(param As Long) As LongDeclare Function ldiv Lib "msvcrt.dll" (Byval q As Long, divisor As Long) As LongPublic Function SetPrinterOrientation(Byval sPrinterName As String,Byval orientation As Integer) As Long Const DM_IN_BUFFER = 8 Const DM_OUT_BUFFER = 2 Const PRINTER_ACCESS_ADMINISTER = &H4 Const PRINTER_ACCESS_USE = &H8 Const STANDARD_RIGHTS_REQUIRED = &HF0000 Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or _ PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE) Dim hPrinter As Long Dim pd As PRINTER_DEFAULTS Dim pinfo As PRINTER_INFO_2 Dim dm As DEVMODE Dim dm2 As DEVMODE Dim yDevModeData() As Long Dim yPInfoMemory() As Long Dim nBytesNeeded As Long Dim nRet As Long, nJunk As Long Dim q As Long On Error Goto cleanup 'Open printer with all access to be able to modify settings pd.DesiredAccess = PRINTER_ALL_ACCESS nRet = OpenPrinter(sPrinterName, hPrinter, pd) nRet = DocumentProperties(0, hPrinter, sPrinterName, 0, 0, 0) If (nRet < 0) Then Msgbox "Cannot get the size of the DEVMODE structure." Goto cleanup End If Redim yDevModeData(nRet + 100) As Long nRet = DocumentProperties(0, hPrinter, sPrinterName, yDevModeData(0), 0, DM_OUT_BUFFER) If (nRet < 0) Then Msgbox "Cannot get the DEVMODE structure." Goto cleanup End If Call CopyMemory(dm, yDevModeData(0), Len(dm)) dm.dmOrientation = orientation Call CopyMemoryBack(yDevModeData(0), dm, Len(dm)) nRet = DocumentProperties(0, hPrinter, sPrinterName, _ yDevModeData(0), yDevModeData(0), _ DM_IN_BUFFER Or DM_OUT_BUFFER) If (nRet < 0) Then Msgbox "Unable to set some settings to this printer." Goto cleanup End If Call GetPrinter(hPrinter, 2, 0, 0, nBytesNeeded) If (nBytesNeeded = 0) Then Goto cleanup Redim yPInfoMemory(nBytesNeeded + 100) As Long nRet = GetPrinter(hPrinter, 2, yPInfoMemory(0), nBytesNeeded, nJunk) If (nRet = 0) Then Msgbox "Unable to get shared printer settings." Goto cleanup End If Call CopyMemoryPI(pinfo, yPInfoMemory(0), Len(pinfo)) pinfo.pDevmode = labs(yDevModeData(0)) pinfo.pSecurityDescriptor = 0 Call CopyMemoryBackPI(yPInfoMemory(0), pinfo, Len(pinfo)) nRet = SetPrinter(hPrinter, 2, yPInfoMemory(0), 0) If (nRet = 0) Then Msgbox "Unable to set shared printer settings." End If SetPrinterOrientation = nRetcleanup: If (hPrinter <> 0) Then Call ClosePrinter(hPrinter)End FunctionUtilisation :Declare Function GetProfileString Lib "Kernel32" Alias "GetProfileStringA" (Byval lpAppName As String, Byval lpKeyName As String, _Byval lpDefault As String, Byval lpReturnedString As String, Byval nSize As Long) As LongDim result As VariantDim printerName As StringDim nPos As StringprinterName = String(128, 0)result = GetProfileString("WINDOWS", "DEVICE", "", printerName, 127)nPos = Instr(printerName, ",")printerName = Left(printerName, nPos - 1)result = SetPrinterOrientation(printerName, 2)[%sig%]
Cordialement

Stéphane Maillard
Avatar de l’utilisateur
Stephane Maillard
Lord of DominoArea
Lord of DominoArea
 
Message(s) : 8695
Inscrit(e) le : 16 Déc 2004 à 01:10
Localisation : Bretagne

Re: Parametrer une impression

Messagepar AdminExpert » 22 Déc 2003 à 19:30

j'ai unebase pour toiva voir sur l'un des deux siteshttp://intelliprint.cybernetsoft.c ... enDocument
AdminExpert
 

Re: Parametrer une impression

Messagepar Stephane Maillard » 22 Déc 2003 à 19:54

Bonjour,Je connais cette base elle ne fonctionne pas sous NT/2000/XP/2003.[%sig%]
Cordialement

Stéphane Maillard
Avatar de l’utilisateur
Stephane Maillard
Lord of DominoArea
Lord of DominoArea
 
Message(s) : 8695
Inscrit(e) le : 16 Déc 2004 à 01:10
Localisation : Bretagne


Retour vers Développement

cron