Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Limitless printing

Limitless printing

Scheduled Pinned Locked Moved C#
csharpwinformsgraphicshelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_14192216
    wrote on last edited by
    #1

    Hello, I have a problem with my application at the time of printing. When I print with the print button of the report viewer in the viewer my printing works fine. And when I run printing without previewing the report limit is limited to where the rectangle is limited. I specify well I use a thermal printer in roll paper Here is my code

    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Drawing.Printing;
    using System.IO;
    using System.Windows.Forms;
    using System.Data.SqlClient;
    using Microsoft.Reporting.WinForms;

    namespace POS_System_Inventory
    {
    public static class LocalReportExtensions
    {
    public static void PrintToPrinter(this LocalReport report)
    {
    PageSettings pageSettings = new PageSettings();
    pageSettings.PaperSize = report.GetDefaultPageSettings().PaperSize;
    pageSettings.Landscape = report.GetDefaultPageSettings().IsLandscape;
    pageSettings.Margins = report.GetDefaultPageSettings().Margins;
    Print(report, pageSettings);
    }

        public static void Print(this LocalReport report, PageSettings pageSettings)
        {
            string deviceInfo =
                @"
                    EMF
                    {pageSettings.PaperSize.Width \* 100}in
                    {pageSettings.PaperSize.Height \* 100}in
                    {pageSettings.Margins.Top \* 100}in
                    {pageSettings.Margins.Left \* 100}in
                    {pageSettings.Margins.Right \* 100}in
                    {pageSettings.Margins.Bottom \* 100}in
                ";
            Warning\[\] warnings;
            var streams = new List();
            var pageIndex = 0;
            report.Render("Image", deviceInfo,
                (name, fileNameExtension, encoding, mimeType, willSeek) =>
                {
                    MemoryStream stream = new MemoryStream();
                    streams.Add(stream);
                    return stream;
                }, out warnings);
            foreach (Stream stream in streams)
                stream.Position = 0;
            if (streams == null || streams.Count == 0)
                throw new Exception("Aucun flux à imprimer.");
            usin
    
    OriginalGriffO J L 3 Replies Last reply
    0
    • M Member_14192216

      Hello, I have a problem with my application at the time of printing. When I print with the print button of the report viewer in the viewer my printing works fine. And when I run printing without previewing the report limit is limited to where the rectangle is limited. I specify well I use a thermal printer in roll paper Here is my code

      using System;
      using System.Collections.Generic;
      using System.Drawing;
      using System.Drawing.Imaging;
      using System.Drawing.Printing;
      using System.IO;
      using System.Windows.Forms;
      using System.Data.SqlClient;
      using Microsoft.Reporting.WinForms;

      namespace POS_System_Inventory
      {
      public static class LocalReportExtensions
      {
      public static void PrintToPrinter(this LocalReport report)
      {
      PageSettings pageSettings = new PageSettings();
      pageSettings.PaperSize = report.GetDefaultPageSettings().PaperSize;
      pageSettings.Landscape = report.GetDefaultPageSettings().IsLandscape;
      pageSettings.Margins = report.GetDefaultPageSettings().Margins;
      Print(report, pageSettings);
      }

          public static void Print(this LocalReport report, PageSettings pageSettings)
          {
              string deviceInfo =
                  @"
                      EMF
                      {pageSettings.PaperSize.Width \* 100}in
                      {pageSettings.PaperSize.Height \* 100}in
                      {pageSettings.Margins.Top \* 100}in
                      {pageSettings.Margins.Left \* 100}in
                      {pageSettings.Margins.Right \* 100}in
                      {pageSettings.Margins.Bottom \* 100}in
                  ";
              Warning\[\] warnings;
              var streams = new List();
              var pageIndex = 0;
              report.Render("Image", deviceInfo,
                  (name, fileNameExtension, encoding, mimeType, willSeek) =>
                  {
                      MemoryStream stream = new MemoryStream();
                      streams.Add(stream);
                      return stream;
                  }, out warnings);
              foreach (Stream stream in streams)
                  stream.Position = 0;
              if (streams == null || streams.Count == 0)
                  throw new Exception("Aucun flux à imprimer.");
              usin
      
      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Repost: this is the same problem you asked about 3 days ago: Printe page limit - C# Discussion Boards[^] Don't repost the same question repeatedly - it just wastes time and effort!

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • M Member_14192216

        Hello, I have a problem with my application at the time of printing. When I print with the print button of the report viewer in the viewer my printing works fine. And when I run printing without previewing the report limit is limited to where the rectangle is limited. I specify well I use a thermal printer in roll paper Here is my code

        using System;
        using System.Collections.Generic;
        using System.Drawing;
        using System.Drawing.Imaging;
        using System.Drawing.Printing;
        using System.IO;
        using System.Windows.Forms;
        using System.Data.SqlClient;
        using Microsoft.Reporting.WinForms;

        namespace POS_System_Inventory
        {
        public static class LocalReportExtensions
        {
        public static void PrintToPrinter(this LocalReport report)
        {
        PageSettings pageSettings = new PageSettings();
        pageSettings.PaperSize = report.GetDefaultPageSettings().PaperSize;
        pageSettings.Landscape = report.GetDefaultPageSettings().IsLandscape;
        pageSettings.Margins = report.GetDefaultPageSettings().Margins;
        Print(report, pageSettings);
        }

            public static void Print(this LocalReport report, PageSettings pageSettings)
            {
                string deviceInfo =
                    @"
                        EMF
                        {pageSettings.PaperSize.Width \* 100}in
                        {pageSettings.PaperSize.Height \* 100}in
                        {pageSettings.Margins.Top \* 100}in
                        {pageSettings.Margins.Left \* 100}in
                        {pageSettings.Margins.Right \* 100}in
                        {pageSettings.Margins.Bottom \* 100}in
                    ";
                Warning\[\] warnings;
                var streams = new List();
                var pageIndex = 0;
                report.Render("Image", deviceInfo,
                    (name, fileNameExtension, encoding, mimeType, willSeek) =>
                    {
                        MemoryStream stream = new MemoryStream();
                        streams.Add(stream);
                        return stream;
                    }, out warnings);
                foreach (Stream stream in streams)
                    stream.Position = 0;
                if (streams == null || streams.Count == 0)
                    throw new Exception("Aucun flux à imprimer.");
                usin
        
        J Offline
        J Offline
        jsc42
        wrote on last edited by
        #3

        Looking at your code with a very limited understanding of the domain, I am wondering if

        Member 14192216 wrote:

        string deviceInfo =
        @"<DeviceInfo>
        <OutputFormat>EMF</OutputFormat>
        <PageWidth>{pageSettings.PaperSize.Width * 100}in</PageWidth>
        <PageHeight>{pageSettings.PaperSize.Height * 100}in</PageHeight>
        <MarginTop>{pageSettings.Margins.Top * 100}in</MarginTop>
        <MarginLeft>{pageSettings.Margins.Left * 100}in</MarginLeft>
        <MarginRight>{pageSettings.Margins.Right * 100}in</MarginRight>
        <MarginBottom>{pageSettings.Margins.Bottom * 100}in</MarginBottom>
        </DeviceInfo>";

        is meant to be an interpolated string. If so, try changing the @"..." to $@"..." so that the expressions inside {...} sections are evaluated. It may be that the uninterpolated values are being treated as invalid number, which are treated a undefined items so the defaults for the geometry are used.

        1 Reply Last reply
        0
        • M Member_14192216

          Hello, I have a problem with my application at the time of printing. When I print with the print button of the report viewer in the viewer my printing works fine. And when I run printing without previewing the report limit is limited to where the rectangle is limited. I specify well I use a thermal printer in roll paper Here is my code

          using System;
          using System.Collections.Generic;
          using System.Drawing;
          using System.Drawing.Imaging;
          using System.Drawing.Printing;
          using System.IO;
          using System.Windows.Forms;
          using System.Data.SqlClient;
          using Microsoft.Reporting.WinForms;

          namespace POS_System_Inventory
          {
          public static class LocalReportExtensions
          {
          public static void PrintToPrinter(this LocalReport report)
          {
          PageSettings pageSettings = new PageSettings();
          pageSettings.PaperSize = report.GetDefaultPageSettings().PaperSize;
          pageSettings.Landscape = report.GetDefaultPageSettings().IsLandscape;
          pageSettings.Margins = report.GetDefaultPageSettings().Margins;
          Print(report, pageSettings);
          }

              public static void Print(this LocalReport report, PageSettings pageSettings)
              {
                  string deviceInfo =
                      @"
                          EMF
                          {pageSettings.PaperSize.Width \* 100}in
                          {pageSettings.PaperSize.Height \* 100}in
                          {pageSettings.Margins.Top \* 100}in
                          {pageSettings.Margins.Left \* 100}in
                          {pageSettings.Margins.Right \* 100}in
                          {pageSettings.Margins.Bottom \* 100}in
                      ";
                  Warning\[\] warnings;
                  var streams = new List();
                  var pageIndex = 0;
                  report.Render("Image", deviceInfo,
                      (name, fileNameExtension, encoding, mimeType, willSeek) =>
                      {
                          MemoryStream stream = new MemoryStream();
                          streams.Add(stream);
                          return stream;
                      }, out warnings);
                  foreach (Stream stream in streams)
                      stream.Position = 0;
                  if (streams == null || streams.Count == 0)
                      throw new Exception("Aucun flux à imprimer.");
                  usin
          
          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You're confusing "logical" printing and "physical" printing. There is no evidence that the "thermal printer" understands what you're sending it. (thermal printers can have their own "language") You start by sending "one line" / chaeacter to the printer. When that works, you'll have some confidence you're on the right track; otherwise, you're just grasping.

          It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups