Page 1 sur 1
[..] Imprimer fichier txt au format A5
Posté : lun. 27 oct. 2014 08:52
par Hugues
Bonjour,
J'aimerai savoir comment faire pour imprimer un fichier txt au format A5.
Pour le moment j'utilise la fonction _FilePrint(), mais j'utilise une imprimante que a 2 bacs (1 A4 et 1 A5). Moi je voudrais imprimer que sur le A5.
Merci par avance.
Re: [..] Imprimer fichier txt au format A5
Posté : lun. 27 oct. 2014 13:42
par Ks10
Je croit que cela ne vien pas de la fonction _FilePrint()
Il faut changer le bac par default dans les paramètres de l'imprimante.
Re: [..] Imprimer fichier txt au format A5
Posté : lun. 27 oct. 2014 14:07
par TommyDDR
Je n'ai pas poussé la recherche plus loin mais je me souviens que la structure DEVMODE possède justement une propriété paperSize :
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Re: [..] Imprimer fichier txt au format A5
Posté : jeu. 30 oct. 2014 12:57
par Hugues
Merki, mais c'est un peu du p'tit chinois pour moi...

Re: [..] Imprimer fichier txt au format A5
Posté : jeu. 30 oct. 2014 13:17
par jchd
但它是在那裡它被播放。
► Afficher le texte
C'est pourtant bien là que ça se joue.
Re: [..] Imprimer fichier txt au format A5
Posté : jeu. 30 oct. 2014 15:10
par Hugues
Avec Excel OK, mais NotePad...
► Afficher le texte
Code : Tout sélectionner
; Constantes VBA pour Autoit (forcement ils en manquent)
const $xlPrintNoComments=-4142
const $xlLandscape=1
const $xlPaperA4=11
const $xlDownThenOver=1
; Création d'un WoorkBook dans Excel
Local $excel = ObjCreate("Excel.Application")
With $excel
.Visible = 1
.WorkBooks.Add()
.ActiveSheet.Name = "PRINT"
EndWith
; Mise en page pour l'impression
With $excel.Sheets("PRINT").PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = 0
.RightMargin = 0
.TopMargin = 0
.BottomMargin = 0
.HeaderMargin = 0
.FooterMargin = 0
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = $xlPrintNoComments
.PrintQuality = 1200
.CenterHorizontally = True
.CenterVertically = False
.Orientation = $xlLandscape
.Draft = False
.PaperSize = $xlPaperA4
.Order = $xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
EndWith
Re: [..] Imprimer fichier txt au format A5
Posté : mar. 04 nov. 2014 13:53
par Hugues
Personne pour m'aiguiller un peu plus (ou me donner un gros coup de main) ^^
Merki
Re: [..] Imprimer fichier txt au format A5
Posté : mar. 04 nov. 2014 14:57
par jguinch
Perso, tout ce que je peux te dire, c'est que j'ai déjà passé pas mal de temps à essayer d'envoyer des impressions sur des bacs différents sans y arriver.
Un de mes collègues a bricolé un truc avec Windev et ça marche impec.
Edit :
Pour ce qui est d'AutoIt, ça devra forcément passer par les API, d'où la complexité.
Comme l'a très justement dit Tommy, DEVMODE est la bonne piste. Regarde sur le forum US si tu trouves quelque chose avec les termes suivants : DeviceCapabilities, OpenPrinter, DocumentProperties, CreateDC, StartDoc.
Tu peux essayer de poster sur forum US, tu auras peut-être plus de chance.
Re: [..] Imprimer fichier txt au format A5
Posté : mar. 04 nov. 2014 15:46
par Hugues
Ok, merci quand même. Je vais me tourner vers une autre solution.
Re: [..] Imprimer fichier txt au format A5
Posté : mar. 04 nov. 2014 16:06
par jguinch
Si tu trouves un solution, ça m'intéresserais bien de la connaître

Re: [..] Imprimer fichier txt au format A5
Posté : mer. 05 nov. 2014 10:36
par Chris
Bonjour,
j'avais un peu le même problème impression recto ou recto/verso avec une identification dans le nom du fichier.
je me suis fait 2 profils imprimantes un Recto.dat et un autre RectoVerso.dat et selon ce que je dois imprimer je charge les paramètres sur l'imprimante.
je m'en suis sortis avec :
Restore all printer settings from a file
RUNDLL32 PRINTUI.DLL,PrintUI /Sr /n "printer" /a "file.dat"
Store printer information on level 2 into a file
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Ss /n "printer" /a "file.dat" 2
des info sur les commandes :
http://www.robvanderwoude.com/2kprintcontrol.php
Voici le code que j'avais réalisé pour commencé si cela peux aider (je précise je débute il y a peut être moyen d'amélioré ou de simplifier.)
► Afficher le texte
Code : Tout sélectionner
#include <WinAPISys.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ColorConstants.au3>
Global $Printer_def,$Adr_Printer,$IP_Printer,$PrinterList[1][3]
#Region interface imprimante
;Création de la fenêtre
$GUI1=GUICreate("Imprimante(s)",250,150,-1,-1,-1,$WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "FermeGUI")
$Titre2=GUICtrlCreateLabel("Imprimante(s)",20,5,210,40,$SS_CENTER)
GUICtrlSetFont($Titre2,18,400,0,"Comic sans MS")
GUICtrlSetColor($Titre2,$COLOR_BLUE)
;Combo list des printers
Global $CB_Printer = GUICtrlCreateCombo("", 10, 45, 230, 20)
GUICtrlSetData($CB_Printer,"",$Printer_def)
GUICtrlSetOnEvent($CB_Printer, "Config_Printer")
;Labe du modele
$L_srv_printer=GUICtrlCreateLabel($Adr_Printer,10,75,160,40)
;label de l'adresse IP
local $L_IP_printer=GUICtrlCreateLabel($IP_Printer,10,90,160,40)
;Bouton Quitter
$B_Printer=GUICtrlCreateButton("Quitter", 130, 115, 70)
GUICtrlSetOnEvent($B_Printer, "Quitter")
;Cacher de la fenêtre
GUISetState(@SW_HIDE, $GUI1)
#EndRegion
List_Printers()
;Affiche la Gui
GUISetState(@SW_SHOW, $GUI1)
; Activation du mode événementiel
Opt("GUIOnEventMode", 1)
While 1 ; Début de la boucle infinie
Sleep(1000) ; Pause du script
WEnd ; Fin de la boucle infinie
Func List_Printers()
$Printer_def=_WinAPI_GetDefaultPrinter ( )
local $PrinterCount
Local $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
; Imprimantes réseau
;Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Printer where Network=True")
; Imprimantes Local
;Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Printer where Network=false")
; Imprimantes Local/reseau
Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Printer")
For $objItem In $colItems
ReDim $PrinterList[$PrinterCount + 1][4]
;https://gallery.technet.microsoft.com/scriptcenter/012dca6b-946a-4a68-bb2f-3704dc80b618
$PrinterList[$PrinterCount][0] = $objItem.DeviceID
$PrinterList[$PrinterCount][1] = $objItem.DriverName
$PrinterList[$PrinterCount][2] = $objItem.PortName
$PrinterList[$PrinterCount][3] = $objItem.ShareName
$PrinterCount += 1
Next
;Affiche le tableau des imprimantes
;_ArrayDisplay($PrinterList)
For $i=0 to UBound($PrinterList)-1
GUICtrlSetData($CB_Printer,$PrinterList[$I][0],$Printer_def)
Next
$i=_ArraySearch($PrinterList,GUICtrlRead($CB_Printer))
GUICtrlSetData ($L_IP_printer, $PrinterList[$i][2])
GUICtrlSetData ($L_srv_printer, $PrinterList[$i][1])
EndFunc ;==> End List_printer
Func Config_Printer()
Local $Printer=GUICtrlRead($CB_printer)
$i=_ArraySearch($PrinterList,GUICtrlRead($CB_Printer))
;sauvegarde des paramètre par default
RunWait('rundll32 printui.dll,PrintUIEntry /Ss /n"'& $PrinterList[$i][0] &'" /a "' & "C:\TEMP\" & $PrinterList[$i][3] & "_Defaut.dat")
;test présence configuration perso
If FileExists("C:\TEMP\" & $PrinterList[$i][3] & "_ConfigPerso.dat")<> 1 Then
GUISetState(@SW_HIDE, $GUI1)
;Permet d'afficher les propriétés de l'imprimante
ProcessWaitClose(RunWait('rundll32 printui.dll,PrintUIEntry /e /n"'& $Printer))
;-------------------------------------------------> /Ss sauvegarde les Données ------> Dans c:\Temp\ & $objItem.ShareName &
RunWait('rundll32 printui.dll,PrintUIEntry /Ss /n"'& $PrinterList[$i][0] &'" /a "' & "C:\TEMP\" & $PrinterList[$i][3] & "_ConfigPerso.dat")
GUISetState(@SW_HIDE, $GUI1)
;-------------------------------------------------> /Sr restore/charge les Données ---> Depuis c:\Temp\ & $objItem.ShareName &
RunWait('rundll32 printui.dll,PrintUIEntry /Sr /n"'& $PrinterList[$i][0] &'" /a "' & "C:\TEMP\" & $PrinterList[$i][3] & "_ConfigPerso.dat")
EndIf
;-------------------------------------------------> /Sr restore/charge les Données par défaut c:\Temp\ & $objItem.ShareName &
RunWait('rundll32 printui.dll,PrintUIEntry /Sr /n"'& $PrinterList[$i][0] &'" /a "' & "C:\TEMP\" & $PrinterList[$i][3] & "_Defaut.dat")
GUISetState(@SW_SHOW, $GUI1)
EndFunc ;==> End Config_Printer
Func FermeGUI()
Select
Case $GUI_EVENT_CLOSE
If @GUI_WinHandle = $GUI1 Then Quitter()
EndSelect
EndFunc
Func Quitter()
GUIDelete($GUI1)
Exit
EndFunc ;==> End Quitter
Christophe
Re: [..] Imprimer fichier txt au format A5
Posté : mer. 05 nov. 2014 15:24
par Hugues
Merci pour ton aide, je vais étudier ça de près!