How to change printer's physical print margins thru VB coding?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark

    How to change printer's physical print margins thru VB coding?

    Hi,
    I am creating application in VB 2005. and when I print report it adds extra
    0.45 cm margin on left and top, and the reason for this is physical margins
    of printer.

    Is it possible to change printer's physical margins using VB coding?

    Cheers
    --
    Osmotion Blue
  • tommaso.gastaldi@uniroma1.it

    #2
    Re: How to change printer's physical print margins thru VB coding?

    You can use the margin property of

    PrintDocument.D efaultPageSetti ngs

    PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
    (hundredths of an inch)
    PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
    PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
    PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...


    (Imports System.Drawing. Printing)



    -tom

    Mark ha scritto:
    Hi,
    I am creating application in VB 2005. and when I print report it adds extra
    0.45 cm margin on left and top, and the reason for this is physical margins
    of printer.
    >
    Is it possible to change printer's physical margins using VB coding?
    >
    Cheers
    --
    Osmotion Blue

    Comment

    • Mark

      #3
      Re: How to change printer's physical print margins thru VB coding?

      Hi Tom,
      Thanks for reply
      Using the code u sent sets the margins that we can see in print preview but
      the physical margins of printer will be added to this margins. So I need to
      change printer's physical margins by VB coding.

      Another problem is that I am creating PrintDocument object but I am using
      report viewer's print button to display print dialogue. I do not have any
      idea how to handle this type of situation.

      Any idea?

      --
      Osmotion Blue


      "tommaso.gastal di@uniroma1.it" wrote:
      You can use the margin property of
      >
      PrintDocument.D efaultPageSetti ngs
      >
      PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
      (hundredths of an inch)
      PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
      PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
      PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...
      >
      >
      (Imports System.Drawing. Printing)
      >

      >
      -tom
      >
      Mark ha scritto:
      >
      Hi,
      I am creating application in VB 2005. and when I print report it adds extra
      0.45 cm margin on left and top, and the reason for this is physical margins
      of printer.

      Is it possible to change printer's physical margins using VB coding?

      Cheers
      --
      Osmotion Blue
      >
      >

      Comment

      • tommaso.gastaldi@uniroma1.it

        #4
        Re: How to change printer's physical print margins thru VB coding?


        Mark ha scritto:
        Hi Tom,
        Thanks for reply
        Using the code u sent sets the margins that we can see in print preview but
        the physical margins of printer will be added to this margins. So I need to
        change printer's physical margins by VB coding.
        make sure to set the also the right page size. There is no such a thing
        like
        "margins are added".
        >
        Another problem is that I am creating PrintDocument object but I am using
        report viewer's print button to display print dialogue. I do not have any
        idea how to handle this type of situation.
        Never used report viewer. Be more specific: someone else may help you
        >
        Any idea?
        >
        --
        Osmotion Blue
        >
        >
        "tommaso.gastal di@uniroma1.it" wrote:
        >
        You can use the margin property of

        PrintDocument.D efaultPageSetti ngs

        PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
        (hundredths of an inch)
        PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
        PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
        PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...


        (Imports System.Drawing. Printing)



        -tom

        Mark ha scritto:
        Hi,
        I am creating application in VB 2005. and when I print report it adds extra
        0.45 cm margin on left and top, and the reason for this is physical margins
        of printer.
        >
        Is it possible to change printer's physical margins using VB coding?
        >
        Cheers
        --
        Osmotion Blue

        Comment

        • Mark

          #5
          Re: How to change printer's physical print margins thru VB coding?

          Hi Tom,
          If we use this code
          Dim p As New PrinterSettings ()
          For Each s As String In PrinterSettings .InstalledPrint ers
          p.PrinterName = s
          MsgBox(p.Defaul tPageSettings.P rintableArea.To String)
          Next
          we will get each printer's default settings.

          and if use
          p.DefaultPageSe ttings.Margins. ToString
          then this will give margins we can see in the print preview.

          So if printer's default physical margin is 0 then we will not get any
          difference between print preview and the printed page.

          But if printer's default left physical margin is 17 (hundredth of inch) then
          it will add extra 0.17 inch (0.43 cm) in addition to the left margin that we
          set for the report.

          --
          Osmotion Blue


          "tommaso.gastal di@uniroma1.it" wrote:
          >
          Mark ha scritto:
          >
          Hi Tom,
          Thanks for reply
          Using the code u sent sets the margins that we can see in print preview but
          the physical margins of printer will be added to this margins. So I need to
          change printer's physical margins by VB coding.
          >
          make sure to set the also the right page size. There is no such a thing
          like
          "margins are added".
          >

          Another problem is that I am creating PrintDocument object but I am using
          report viewer's print button to display print dialogue. I do not have any
          idea how to handle this type of situation.
          >
          Never used report viewer. Be more specific: someone else may help you
          >

          Any idea?

          --
          Osmotion Blue


          "tommaso.gastal di@uniroma1.it" wrote:
          You can use the margin property of
          >
          PrintDocument.D efaultPageSetti ngs
          >
          PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
          (hundredths of an inch)
          PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
          PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
          PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...
          >
          >
          (Imports System.Drawing. Printing)
          >

          >
          -tom
          >
          Mark ha scritto:
          >
          Hi,
          I am creating application in VB 2005. and when I print report it adds extra
          0.45 cm margin on left and top, and the reason for this is physical margins
          of printer.

          Is it possible to change printer's physical margins using VB coding?

          Cheers
          --
          Osmotion Blue
          >
          >
          >
          >

          Comment

          • tommaso.gastaldi@uniroma1.it

            #6
            Re: How to change printer's physical print margins thru VB coding?

            Use a PaperSize which matches *exactly* your paper (e.g. A4 or
            whatever)
            then set the margin to a value that includes (that is >=) the
            "physical" margin
            of the printer. Usually normal printers are not capable to use the
            entire surface of the sheet
            and leave some small margin, which I am calling "physical". Your margin
            must be equal or greater than that in order not to have your drawing
            clipped.

            PrintDocument.D efaultPageSetti ngs.PaperSize = New
            Printing.PaperS ize("Custom", 827, 1169) 'A4
            'set margin so that they are at least equal to the "physical"
            margins of the printer

            [The PrintableArea property is not so important, unless you want to
            make an attempt
            to establish the size "physical" margins are. For you purposes you
            might disregard this detail.
            You can set it later, after you are already able to print fine with
            arbitrary margins (anyway greater than the "physical" ones)]

            -tom


            Mark ha scritto:
            Hi Tom,
            If we use this code
            Dim p As New PrinterSettings ()
            For Each s As String In PrinterSettings .InstalledPrint ers
            p.PrinterName = s
            MsgBox(p.Defaul tPageSettings.P rintableArea.To String)
            Next
            we will get each printer's default settings.
            >
            and if use
            p.DefaultPageSe ttings.Margins. ToString
            then this will give margins we can see in the print preview.
            >
            So if printer's default physical margin is 0 then we will not get any
            difference between print preview and the printed page.
            >
            But if printer's default left physical margin is 17 (hundredth of inch) then
            it will add extra 0.17 inch (0.43 cm) in addition to the left margin that we
            set for the report.
            >
            --
            Osmotion Blue
            >
            >
            "tommaso.gastal di@uniroma1.it" wrote:
            >

            Mark ha scritto:
            Hi Tom,
            Thanks for reply
            Using the code u sent sets the margins that we can see in print preview but
            the physical margins of printer will be added to this margins. So I need to
            change printer's physical margins by VB coding.
            make sure to set the also the right page size. There is no such a thing
            like
            "margins are added".
            >
            Another problem is that I am creating PrintDocument object but I am using
            report viewer's print button to display print dialogue. I do not have any
            idea how to handle this type of situation.
            Never used report viewer. Be more specific: someone else may help you
            >
            Any idea?
            >
            --
            Osmotion Blue
            >
            >
            "tommaso.gastal di@uniroma1.it" wrote:
            >
            You can use the margin property of

            PrintDocument.D efaultPageSetti ngs

            PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
            (hundredths of an inch)
            PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
            PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
            PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...


            (Imports System.Drawing. Printing)



            -tom

            Mark ha scritto:

            Hi,
            I am creating application in VB 2005. and when I print report it adds extra
            0.45 cm margin on left and top, and the reason for this is physical margins
            of printer.
            >
            Is it possible to change printer's physical margins using VB coding?
            >
            Cheers
            --
            Osmotion Blue

            Comment

            • Hinesh

              #7
              Re: How to change printer's physical print margins thru VB coding?

              Margins that I have set are greater than physical margins, but physical
              margins are added to the margins that I have set.

              And other issue is that I can not use PrintDocumnet object because I am
              using report viewer.

              Any idea?

              "tommaso.gastal di@uniroma1.it" wrote:
              Use a PaperSize which matches *exactly* your paper (e.g. A4 or
              whatever)
              then set the margin to a value that includes (that is >=) the
              "physical" margin
              of the printer. Usually normal printers are not capable to use the
              entire surface of the sheet
              and leave some small margin, which I am calling "physical". Your margin
              must be equal or greater than that in order not to have your drawing
              clipped.
              >
              PrintDocument.D efaultPageSetti ngs.PaperSize = New
              Printing.PaperS ize("Custom", 827, 1169) 'A4
              'set margin so that they are at least equal to the "physical"
              margins of the printer
              >
              [The PrintableArea property is not so important, unless you want to
              make an attempt
              to establish the size "physical" margins are. For you purposes you
              might disregard this detail.
              You can set it later, after you are already able to print fine with
              arbitrary margins (anyway greater than the "physical" ones)]
              >
              -tom
              >
              >
              Mark ha scritto:
              >
              Hi Tom,
              If we use this code
              Dim p As New PrinterSettings ()
              For Each s As String In PrinterSettings .InstalledPrint ers
              p.PrinterName = s
              MsgBox(p.Defaul tPageSettings.P rintableArea.To String)
              Next
              we will get each printer's default settings.

              and if use
              p.DefaultPageSe ttings.Margins. ToString
              then this will give margins we can see in the print preview.

              So if printer's default physical margin is 0 then we will not get any
              difference between print preview and the printed page.

              But if printer's default left physical margin is 17 (hundredth of inch) then
              it will add extra 0.17 inch (0.43 cm) in addition to the left margin that we
              set for the report.

              --
              Osmotion Blue


              "tommaso.gastal di@uniroma1.it" wrote:
              >
              Mark ha scritto:
              >
              Hi Tom,
              Thanks for reply
              Using the code u sent sets the margins that we can see in print preview but
              the physical margins of printer will be added to this margins. So I need to
              change printer's physical margins by VB coding.
              >
              make sure to set the also the right page size. There is no such a thing
              like
              "margins are added".
              >

              Another problem is that I am creating PrintDocument object but I am using
              report viewer's print button to display print dialogue. I do not have any
              idea how to handle this type of situation.
              >
              Never used report viewer. Be more specific: someone else may help you
              >

              Any idea?

              --
              Osmotion Blue


              "tommaso.gastal di@uniroma1.it" wrote:

              You can use the margin property of
              >
              PrintDocument.D efaultPageSetti ngs
              >
              PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
              (hundredths of an inch)
              PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
              PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
              PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...
              >
              >
              (Imports System.Drawing. Printing)
              >

              >
              -tom
              >
              Mark ha scritto:
              >
              Hi,
              I am creating application in VB 2005. and when I print report it adds extra
              0.45 cm margin on left and top, and the reason for this is physical margins
              of printer.

              Is it possible to change printer's physical margins using VB coding?

              Cheers
              --
              Osmotion Blue
              >
              >
              >
              >
              >
              >

              Comment

              • tommaso.gastaldi@uniroma1.it

                #8
                Re: How to change printer's physical print margins thru VB coding?

                Ah, that's all another story. I thought you were using a standard
                PrintDocument.

                About report viewer I know nothing (I prefer to code the report myself:
                these tools are too primitive :).

                -tom

                Hinesh ha scritto:
                Margins that I have set are greater than physical margins, but physical
                margins are added to the margins that I have set.
                >
                And other issue is that I can not use PrintDocumnet object because I am
                using report viewer.
                >
                Any idea?
                >
                "tommaso.gastal di@uniroma1.it" wrote:
                >
                Use a PaperSize which matches *exactly* your paper (e.g. A4 or
                whatever)
                then set the margin to a value that includes (that is >=) the
                "physical" margin
                of the printer. Usually normal printers are not capable to use the
                entire surface of the sheet
                and leave some small margin, which I am calling "physical". Your margin
                must be equal or greater than that in order not to have your drawing
                clipped.

                PrintDocument.D efaultPageSetti ngs.PaperSize = New
                Printing.PaperS ize("Custom", 827, 1169) 'A4
                'set margin so that they are at least equal to the "physical"
                margins of the printer

                [The PrintableArea property is not so important, unless you want to
                make an attempt
                to establish the size "physical" margins are. For you purposes you
                might disregard this detail.
                You can set it later, after you are already able to print fine with
                arbitrary margins (anyway greater than the "physical" ones)]

                -tom


                Mark ha scritto:
                Hi Tom,
                If we use this code
                Dim p As New PrinterSettings ()
                For Each s As String In PrinterSettings .InstalledPrint ers
                p.PrinterName = s
                MsgBox(p.Defaul tPageSettings.P rintableArea.To String)
                Next
                we will get each printer's default settings.
                >
                and if use
                p.DefaultPageSe ttings.Margins. ToString
                then this will give margins we can see in the print preview.
                >
                So if printer's default physical margin is 0 then we will not get any
                difference between print preview and the printed page.
                >
                But if printer's default left physical margin is 17 (hundredth of inch) then
                it will add extra 0.17 inch (0.43 cm) in addition to the left margin that we
                set for the report.
                >
                --
                Osmotion Blue
                >
                >
                "tommaso.gastal di@uniroma1.it" wrote:
                >

                Mark ha scritto:

                Hi Tom,
                Thanks for reply
                Using the code u sent sets the margins that we can see in print preview but
                the physical margins of printer will be added to this margins. So I need to
                change printer's physical margins by VB coding.

                make sure to set the also the right page size. There is no such a thing
                like
                "margins are added".

                >
                Another problem is that I am creating PrintDocument object but I am using
                report viewer's print button to display print dialogue. I do not have any
                idea how to handle this type of situation.

                Never used report viewer. Be more specific: someone else may help you

                >
                Any idea?
                >
                --
                Osmotion Blue
                >
                >
                "tommaso.gastal di@uniroma1.it" wrote:
                >
                You can use the margin property of

                PrintDocument.D efaultPageSetti ngs

                PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
                (hundredths of an inch)
                PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
                PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
                PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...


                (Imports System.Drawing. Printing)



                -tom

                Mark ha scritto:

                Hi,
                I am creating application in VB 2005. and when I print report it adds extra
                0.45 cm margin on left and top, and the reason for this is physical margins
                of printer.
                >
                Is it possible to change printer's physical margins using VB coding?
                >
                Cheers
                --
                Osmotion Blue


                Comment

                Working...