从VB.Net 2010在打印机中设置自定义纸张尺寸

时间:2014-10-16 09:08:25

标签: vb.net

我想在180毫米* 90毫米的自定义纸张上打印,我正在使用vb.net 2010和打印文档,我试图改变纸张尺寸使用此代码

 document.DefaultPageSettings.PaperSize = New PaperSize("custom", TextBox21.Text, TextBox22.Text)

它在打印预览中工作正常,但是当我在纸张尺寸上打印时#34;信" ,我也尝试使用此代码的ComboPaperSize和PageSetupDialog,我选择" custom_paper1_size"在compoPaerSize中,我也使用此代码检查pagesetupdialog中的纸张大小,将pagesetupdialog中的纸张大小更改为"信"高度= 1100,宽度= 850 这是纸张尺寸的组合框

    comboPaperSize.SelectedIndex = -1
     `enter code here`   comboPaperSize.DisplayMember = "PaperName"

        Dim pkSize As PaperSize
        For i = 0 To PrintDocument1.PrinterSettings.PaperSizes.Count - 1
            pkSize = PrintDocument1.PrinterSettings.PaperSizes.Item(i)
            comboPaperSize.Items.Add(pkSize)
        Next

        ' Create a PaperSize and specify the custom paper size through the constructor and add to combobox. 

        Dim pkCustomSize1 As New PaperSize("Custom_Paper1_Size", TextBox21.Text, TextBox22.Text)

        comboPaperSize.Items.Add(pkCustomSize1)

这是针对页面设置对话框

 PageSetupDialog1.PageSettings = _
            New System.Drawing.Printing.PageSettings
        PageSetupDialog1.PageSettings.PaperSize = comboPaperSize.SelectedItem
        PageSetupDialog1.PageSettings.Landscape = True

        ' Initialize dialog's PrinterSettings property to hold user 
        ' set printer settings.
        PageSetupDialog1.PrinterSettings = _
            New System.Drawing.Printing.PrinterSettings

        'Do not show the network in the printer dialog.
        PageSetupDialog1.ShowNetwork = False

        'Show the dialog storing the result. 
        Dim result As DialogResult = PageSetupDialog1.ShowDialog()

我现在失去了一周寻找解决这个问题。 任何人都可以告诉我如何在没有页边距的纸张自定义纸张尺寸上打印挡板。 感谢

0 个答案:

没有答案