Hi,
How can I print a long page (width and length more than an A4 paper) fitting in a A4 paper?
Anybody with some ideas is welcome.
Thanks in advance.
Regards,
Abhishek SenGupta.
Hi,
How can I print a long page (width and length more than an A4 paper) fitting in a A4 paper?
Anybody with some ideas is welcome.
Thanks in advance.
Regards,
Abhishek SenGupta.
Subject: How to print a long page in A4 paper?
Here is code that I found some time ago
Here is code for the Notes Client
Printing landscape
’ Use GetPrinterOrientation and SetPrinterOrientation(mOrientation) where mOrientation = “Portrait” or “Landscape”
’ unfortuately the code works only with Windows 95
Public Const CCHDEVICENAME = 32
Public Const CCHFORMNAME = 32
Public Const PRINTER_ACCESS_ADMINISTER = &H4
Public Const DM_ORIENTATION = &H1&
Public Const DM_PAPERSIZE = &H2&
Public Const DM_PAPERLENGTH = &H4&
Public Const DM_PAPERWIDTH = &H8&
Public Const DM_SCALE = &H10&
Public Const DM_COPIES = &H100&
Public Const DM_DEFAULTSOURCE = &H200&
Public Const DM_PRINTQUALITY = &H400&
Public Const DM_COLOR = &H800&
Public Const DM_DUPLEX = &H1000&
Public Const DM_YRESOLUTION = &H2000&
Public Const DM_TTOPTION = &H4000&
Public Const DMORIENT_PORTRAIT = 1
Public Const DMORIENT_LANDSCAPE = 2
Public Const DM_UPDATE = 1
Public Const DM_COPY = 2
Public Const DM_PROMPT = 4
Public Const DM_MODIFY = 8
Public Const DM_IN_BUFFER = 8
Public Const DM_IN_PROMPT = 4
Public Const DM_OUT_BUFFER = 2
Public Const DM_OUT_DEFAULT = 1
Public Const HWND_BROADCAST = &HFFFF&
Public Const WM_DEVMODECHANGE = &H1B
Public Const WM_WININICHANGE = &H1A
Public Const DMPAPER_LETTER = 1 'Letter 8 1/2 x 11 in
Public Const DMPAPER_LEGAL = 5 ’ Legal 8 1/2 x 14 in
Public Const DMPAPER_A4 = 9 ’ A4 210 x 297 mm
Type DEVMODE
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
Type PRINTER_DEFAULTS
pDatatype As String
pDevMode As Long
DesiredAccess As Long
End Type
Declare Function DocumentProperties Lib “winspool.drv” Alias “DocumentPropertiesA” _
(Byval hwnd As Long, Byval hPrinter As Long, Byval pDeviceName As String, pDevModeOutput As DEVMODE, _
pDevModeInput As DEVMODE, Byval fMode As Long) As Long
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 Long
Declare Function OpenPrinter Lib “winspool.drv” Alias “OpenPrinterA” (Byval pPrinterName As String, phPrinter As Long, _
pDefault As PRINTER_DEFAULTS) As Long
Declare Function ClosePrinter Lib “winspool.drv” (Byval hPrinter As Long) As Long
Declare Function SendMessage Lib “user32” _
Alias “SendMessageA” _
(Byval hwnd As Long, _
Byval wMsg As Long, _
Byval wParam As Long, _
lParam As Long) As Long
Function OpenDefaultPrinter(DeviceName) As Long
Dim hPrinter&
Dim pdefs As PRINTER_DEFAULTS
pdefs.pDatatype = “”
pdefs.pDevMode = 0
pdefs.DesiredAccess = PRINTER_ACCESS_ADMINISTER
dev = GetDefPrinter()
If dev = “” Then Exit Function
devname = GetDeviceName(dev)
devoutput = GetDeviceOutput(dev)
DeviceName = devname
res = OpenPrinter(devname, hPrinter, pdefs)
If res <> 0 Then
OpenDefaultPrinter = hPrinter
End If
End Function
Function GetDeviceName(dev)
npos = Instr(dev, “,”)
GetDeviceName = Left(dev, npos - 1)
End Function
Function GetDeviceOutput(dev)
firstpos = Instr(dev, “,”)
nextpos = Instr(firstpos + 1, dev, “,”)
GetDeviceOutput = Mid(dev, nextpos + 1)
End Function
Function GetDefPrinter
def$ = String(128, 0)
di = GetProfileString(“WINDOWS”, “DEVICE”, “”, def$, 127)
GetDefPrinter = Trim(def$)
End Function
Function GetPrinterOrientation
’ NOTE: This function returns what you would see if you clicked Start, Printer Settings, and clicked properties for the default printer.
’ If the user has changed the printer settings in Notes, those changes will not be reflected by this function.
’ Returns string value indicating Printer Orientation (“Landscape” or “Portrait”)
Dim dmIn As DEVMODE, dmOut As DEVMODE
Dim dm As DEVMODE
hPrinter = OpenDefaultPrinter(DeviceName$)
If hPrinter = 0 Then
Msgbox “Unable to open default printer”
Exit Function
End If
bufsize = DocumentProperties(hwnd, hPrinter, DeviceName$, dm, dm, 0)
res = DocumentProperties(0, hPrinter, DeviceName$, dmOut, dm, DM_OUT_BUFFER)
If dmOut.dmOrientation = DMORIENT_LANDSCAPE Then
GetPrinterOrientation = “Landscape”
Else
GetPrinterOrientation = “Portrait”
End If
ClosePrinter(hPrinter)
End Function
Sub SetPrinterOrientation(mOrientation)
’ This sub will change the printer orientation. If you have a script that both calls this sub, the printer modification does not take place until
’ the calling script ends.
’ Usage - SetPrinterOrientation(mOrientation)
’ Where mOrientation = “Landscape” Or “Portrait”
Dim dmIn As DEVMODE, dmOut As DEVMODE
Dim dm As DEVMODE
hPrinter = OpenDefaultPrinter(DeviceName$)
If hPrinter = 0 Then
Msgbox “Unable to open default printer”
Exit Sub
End If
bufsize = DocumentProperties(hwnd, hPrinter, DeviceName$, dm, dm, 0)
res = DocumentProperties(0, hPrinter, DeviceName$, dmOut, dm, DM_OUT_BUFFER)
If mOrientation = “Landscape” Then
mNewOrientation = DMORIENT_LANDSCAPE
Else
mNewOrientation = DMORIENT_PORTRAIT
End If
dmOut.dmOrientation = mNewOrientation
dmOut.dmFields = DM_ORIENTATION
res = DocumentProperties(0, hPrinter, DeviceName$, dm, dmOut, DM_UPDATE Or DM_IN_BUFFER)
ClosePrinter(hPrinter)
lReturnValue = SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, 0)
lReturnValue = SendMessage(HWND_BROADCAST, WM_DEVMODECHANGE, 0, 0)
End Sub
Sub SetPaperSize(mSize)
’ This sub will change the printer paper size. If you have a script that calls this sub, the printer modification does not take place until
’ the calling script ends.
’ Usage - SetPaperSize(mSize)
’ Where mSize = “Letter”, “Legal”, or “A4”
Dim dmIn As DEVMODE, dmOut As DEVMODE
Dim dm As DEVMODE
hPrinter = OpenDefaultPrinter(DeviceName$)
If hPrinter = 0 Then
Msgbox “Unable to open default printer”
Exit Sub
End If
bufsize = DocumentProperties(hwnd, hPrinter, DeviceName$, dm, dm, 0)
res = DocumentProperties(0, hPrinter, DeviceName$, dmOut, dm, DM_OUT_BUFFER)
Select Case Ucase(mSize)
Case “LETTER”
mNewSize = DMPAPER_LETTER
Case “LEGAL”
mNewSize = DMPAPER_LEGAL
Case “A4”
mNewSize = DMPAPER_A4
End Select
dmOut.dmPaperSize = mNewSize
dmOut.dmFields = DM_PAPERSIZE
res = DocumentProperties(0, hPrinter, DeviceName$, dm, dmOut, DM_UPDATE Or DM_IN_BUFFER)
ClosePrinter(hPrinter)
lReturnValue = SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, 0)
lReturnValue = SendMessage(HWND_BROADCAST, WM_DEVMODECHANGE, 0, 0)
End Sub