locked
Set Custom paper size RRS feed

  • Question

  • I  want to print on the custom paper size 180 mm * 90 mm , i am using vb.net 2010 and print document, i tried to change the paper size use this code

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

    its working fine in print preview but when i am printing its printing on paper size " letter " , i checked it by using your codes on this site 

    comboPaperSize.SelectedIndex = -1
            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)
            

    i chose " custom_paper1_size " in compoPaerSize and i used this code also for check the paper size in pagesetupdialog

      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()
    
            ' If the result is OK, display selected settings in 
            ' ListBox1. These values can be used when printing the 
            ' document. 
            If (result = DialogResult.OK) Then
                Dim results() As Object = New Object() _
                    {PageSetupDialog1.PageSettings.Margins, _
                     PageSetupDialog1.PageSettings.PaperSize, _
                     PageSetupDialog1.PageSettings.Landscape, _
                     PageSetupDialog1.PrinterSettings.PrinterName, _
                     PageSetupDialog1.PrinterSettings.PrintRange}
                ListBox1.Items.AddRange(results)
            End If

    the paper size changed in pagesetupdialog to " letter " height = 1100 , width = 850 

    I lost one week now searching for solve this problem .

    can anyone please tell me how to print landscope on paper custom paper size without page margins .

    Thanks

    Thursday, October 16, 2014 8:16 AM

Answers

All replies

  • Hi eskandrany,

    According to your description, you'd like to know that how to print landscope on paper custom paper size without page margins .

    I suggest you setting the margin property of the PageSetupDialog1 like below.

    Dim margins As New Margins(0, 0, 0, 0)
    PageSetupDialog1.PageSettings.Margins = margins

    #PageSettings.Margins Property
    http://msdn.microsoft.com/en-us/library/system.drawing.printing.pagesettings.margins(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

    If you have any other concern regarding this issue, please feel free to let me know.

    Best regards,
    Youjun Tang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 17, 2014 5:28 AM
  • Hi Youjun, The problem with the paper size i set it to custom 180 mm * 190 mm , the paper size in print preview is ok but the problem when i printing its print on the bottom left on the paper A4 and when i open pagesetupdialog the paper size is letter not custom , so why the printing different than the print preview and how i can change the paper size to 180 mm *90 mm
    Friday, October 17, 2014 3:33 PM
  • Hi eskandrany,

    As you said, the paper size in print preview is ok, but when printing ites print the problem will appear.

    I suggest you contacting your IT and checking if the Printer works well.

    If the problem is stil existing, you could contact the official site of the Printer for supports.

    Best regards,
    Youjun Tang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 20, 2014 2:44 AM
  • I have contacted Hp printer support and them asked me if the printer can print custom paper size from ms Word or Excel i said yes it can, then them said the problem not with the printer and i have to change the code for creat custom paper size.
    Wednesday, October 22, 2014 7:22 AM
  • how about adding that pagesize to your printer, then select that size to print?

    Adding custom paper sizes to named printers


    remember make the reply as answer and vote the reply as helpful if it helps.

    Thursday, October 23, 2014 10:00 AM
  • Risa that's mean i will tell every user to creat a custom paper size in his printer ?? not good idea

    Friday, October 24, 2014 6:57 PM
  • Risa that's mean i will tell every user to creat a custom paper size in his printer ?? not good idea


    No, we could temply added that size and delete it after we print that page, that link should have shared the way to delete size.

    remember make the reply as answer and vote the reply as helpful if it helps.

    Friday, October 24, 2014 7:01 PM
  • I tried to creat custom paper size with the above tutorial but also no custom paper size created, maybe the problem with print document and if i try to print report with custom paper size it will work , but i never use reports , so have i ask you if i can control of the text in report by code ( text color, text font, text location ) ?

    Sunday, October 26, 2014 8:19 AM
  • Hi eskandrany,

    As you said, you'd like to try to use the reports.

    Here is a forum specifically for the reporter, you could post it in it for supports. Thanks.

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=vsreportcontrols&filter=alltypes&sort=lastpostdesc

    Best regards,
    Youjun


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Carl Cai Monday, November 3, 2014 11:02 AM
    Monday, October 27, 2014 6:59 AM