How to set Borderless Property on Printer?
Howdy People,
I want to be able to read/write the borderless property on a printer using code. My app has a printer dialog (the dialog that ships with the printer) allowing users to change the printer preferences. Of course this only a dialog, it only records the users choices it DOES NOT implement the changes, I must do that in code. I can implement all the user choices in the printer object EXCEPT the borderless property. Does something like SetDeviceCaps as opposed to GetDeviceCaps exist where I can change the PHYSICALOFFSETX or HORZREZ value of the printer?
Doe's anybody know how this can be done? Or some kind of hack to achieve the same result?
Thanks in advance!:)
Re: How to set Borderless Property on Printer?
how do you mean borderless?
do you mean margins?
Re: How to set Borderless Property on Printer?
By borderless I mean the property that some printers have that eanbles you to print to the edge of the paper. Like photo printers for example. So yes, I guess you could call it the margins. The printer object only lets you read margins not set them though (to the best of knowledge!).
Re: How to set Borderless Property on Printer?
that is margins. i'll need to see your code. it looks like you're using some sort of custom print component?
Re: How to set Borderless Property on Printer?
My code is simply using the printer object. There is nothing unique here. All I want is to be able to read/write the borderless property of a printer, its a boolean value. I need to be able to do that exactly the same as I can with the Duplex property, or copies property etc etc.
Below are two functions. One too show the printer dialog where the user can select a printer AND set preferences. The second function applies the users choices.
Cheers
Code:
Public Function ShowPrinterDialog(FormName As Form) As Boolean
'an example call would be DialogOpened = ShowPrinterDialog(Me)
'or simply ShowPrinterDialog Me for no return value
Dim NewPrinterName As String
Dim objPrinter As Printer
Dim OrigPrinter As String, OrigPaper
On Error GoTo Cancel
'remember our original printer & paper
OrigPrinter = Printer.DeviceName
OrigPaper = Printer.PaperSize
'Set the starting information for the dialog box based on the current printer settings
printDlg.PrinterName = Printer.DeviceName
printDlg.DriverName = Printer.DriverName
printDlg.Port = Printer.Port
printDlg.Copies = Printer.Copies
printDlg.Orientation = Printer.Orientation
printDlg.ColorMode = Printer.ColorMode
printDlg.Duplex = Printer.Duplex
printDlg.PaperBin = Printer.PaperBin
printDlg.PaperSize = Printer.PaperSize
printDlg.PrintQuality = Printer.PrintQuality
'Set the flags for the PrinterDlg object in the Print style
printDlg.flags = VBPrinterConstants.cdlPDNoSelection Or VBPrinterConstants.cdlPDNoPageNums Or VBPrinterConstants.cdlPDReturnDC
Printer.TrackDefault = False
printDlg.CancelError = True
'show dialog
If Not printDlg.ShowPrinter(FormName.hWnd) Then Exit Function
' Locate the printer that the user selected in the Printers collection and set properties.
SetNewPrinter printDlg.PrinterName
ShowPrinterDialog = True
Exit Function
Cancel:
If Err.Number = 32755 Then
'the user cancelled, add xtra code here if you wish
Else
MsgBox "A Printer Dialog Error Occured" & vbCrLf & vbCrLf & Err.Number & vbCrLf & Err.Description, vbCritical, "Error"
End If
End Function
Public Function SetNewPrinter(strPrinterName As String) As Boolean
'sets the printer by name
Dim P As Printer
Dim S As String
strPrinterName = LCase(strPrinterName)
For Each P In Printers
S = LCase(P.DeviceName)
If InStr(1, S, strPrinterName) > 0 Then
'if its already the loaded printer then no need to set it
If P.DeviceName = Printer.DeviceName Then Exit For
'change the printer to selection
Set Printer = P
Exit For
End If
Next
'not all printers support all properties (pdf printers for example) so...
On Error Resume Next
'Apply any changes to the printer
Printer.Copies = printDlg.Copies
Printer.Orientation = printDlg.Orientation
Printer.ColorMode = printDlg.ColorMode
Printer.Duplex = printDlg.Duplex
Printer.PaperBin = printDlg.PaperBin
Printer.PaperSize = printDlg.PaperSize
Printer.PrintQuality = printDlg.PrintQuality
'reset the paper props
EnumPaperSizes
SetNewPrinter = True
End Function
Re: How to set Borderless Property on Printer?
This thread was supposed to have been in the VB6 or earlier section. I obviously failed!
Does anyone know how to move it?
Thanks
Re: How to set Borderless Property on Printer?
i've informed a moderator for you
Re: How to set Borderless Property on Printer?
If this is VB6 question...
Then this is probably your answer
http://www.vbforums.com/showthread.p...ight=printarea
Re: How to set Borderless Property on Printer?
Quote:
Originally Posted by
szlamany
Thanks but I already have all of that. I can GET my printer margins no problem using GetDeviceCaps. I need to SET them! That's why I was wondering if there was an API similar to GetDeviceCaps that sets the values rather than gets them.
Any other ideas anyone?
Really appreciate help on this.:thumb:
Re: How to set Borderless Property on Printer?
Quote:
Originally Posted by
.paul.
i've informed a moderator for you
Thanks .paul:blush:
Re: How to set Borderless Property on Printer?
As far as I know that unprintable area of the printer is real and not changeable.
I was under the impression it was a hardware restriction.
Re: How to set Borderless Property on Printer?
Thread moved from the 'VB.Net' forum to the 'VB6 and Earlier' forum thanks .paul. :thumb:
Quote:
Originally Posted by
FromDownUnder
Does anyone know how to move it?
Only moderators/admins can move threads, and the best way to let us know about something is to click the "Report" triangle icon on the left of a post - as .paul. did for you.
Re: How to set Borderless Property on Printer?
OK thanks Si. And thanks again .paul.
Re: How to set Borderless Property on Printer?
Quote:
Originally Posted by
szlamany
As far as I know that unprintable area of the printer is real and not changeable.
I was under the impression it was a hardware restriction.
Hi szlamany.
Yes, I guess you are right. The borderless property can be changed easily enough through the control panel/printers/printer preferences and I assume the printer driver handles that? Do you think there may be a way to emulate that procedure?
The idea was for me to allow the user to set ALL preferences from my app rather than have to seperately go to the control panel for some of them.
Any bright ideas anybody?:confused: