Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Set Default Printer Paper Size

1 REPLY 1
Reply
Message 1 of 2
isocam
1162 Views, 1 Reply

Set Default Printer Paper Size

Can anybody answer the following question???

 

I need to "Programatically", using Visual Studio, set the default printers paper size to either "A4" or "A3".

 

I have the following code that gets the required paper size ("A4" or "A3") from the registry and checks that the default printer supports "A3". If it does I want to set the paper size to "A3".

 

Can this be done????

 

Here is my code so far....

 

Imports Microsoft.Win32

 

Public Class Form1
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim SetPaperSize As String

        Dim PrinterPaperSize As String

        SetPaperSize = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\MechTools\", "Printer Paper Size", "0")

        For Counter = 0 To PrintDialog1.PrinterSettings.PaperSizes.Count
            PrinterPaperSize = PrintDialog1.PrinterSettings.PaperSizes.Item(Counter).PaperName

            If PrinterPaperSize = SetPaperSize Then
                ' MsgBox(SetPaperSize) HERE IS WHERE I NEED THE CODE TO SET THE PAPER SIZE

                Exit For
            End If
        Next

        End
    End Sub
End Class

 

Many thanks in advance!!!

1 REPLY 1
Message 2 of 2
xiaodong_liang
in reply to: isocam

Hi,

 

Frankly, I did not understand what is your problem. I just copied the API sample here, where you can see how to set the paper size. Hope it helps.

 

Public Sub PrintDrawing()
    ' Set a reference to the print manager object of the active document.
    ' This will fail if a drawing document is not active.
    Dim oPrintMgr As DrawingPrintManager
    Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager
    
    ' Get the name of the printer that will be used.
    If MsgBox("Using printer """ & oPrintMgr.Printer & """  Do you want to continue?", vbYesNo + vbQuestion) = vbNo Then
        ' Change to another printer.
        Dim sPrinterName As String
        sPrinterName = InputBox("Enter name of new printer:", "New Printer")
        If sPrinterName = "" Then
            Exit Sub
        Else
            oPrintMgr.Printer = sPrinterName
        End If
    End If
    
    ' Set to print in color.
    oPrintMgr.ColorMode = kPrintColorPalette
    
    ' Set to print two copies.
    oPrintMgr.NumberOfCopies = 2
    
    ' Set to print using portrait orientation.
    oPrintMgr.Orientation = kPortraitOrientation
    
    ' Set the paper size.
    oPrintMgr.PaperSize = kPaperSize11x17
        
    ' Set to print all sheets.
    oPrintMgr.PrintRange = kPrintAllSheets
    
    ' Set to print full scale.
    oPrintMgr.ScaleMode = kPrintFullScale
    
    ' Submit the print.
    oPrintMgr.SubmitPrint
    
    ' Change the number of copies to 1.
    oPrintMgr.NumberOfCopies = 1
    
    ' Change the paper size to a custom size.  The units are in centimeters.
    oPrintMgr.PaperSize = kPaperSizeCustom
    oPrintMgr.PaperHeight = 15
    oPrintMgr.PaperWidth = 10
    
    ' Get and set the current sheet range.
    Dim iFromSheet As Long
    Dim iToSheet As Long
    Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)

    MsgBox "Current sheet range is " & iFromSheet & " to " & iToSheet & Chr(13) & _
            "Setting to print sheets 1-2."
        
    ' Change the print range to print sheets 1 through 2.
    oPrintMgr.PrintRange = kPrintSheetRange
    Call oPrintMgr.SetSheetRange(1, 2)
    
    ' Submit the print.
    oPrintMgr.SubmitPrint
End Sub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report