Print RDLC is zoomed!?

Hey all!

I have a little problem, I am using a modification of some code I found on the MSDN forums to print a RDLC! It works great and does not require the Report Viewer. But for some reason a 4 page report is coming out about 1000 pages because everything is zoomed very large.!!! About 5 word per page!

using System;
using System.IO;
using System.Data;
using System.Text;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using System.Collections.Generic;
using Microsoft.Reporting.WinForms;
// Thanks to the MSDN Community
// Printing solution for RDLC Student Reporting
namespace KazooSoft
    public class PrintReport
        public static int m_currentPageIndex;
        public static IList<Stream> m_streams;

        public static Stream CreateStream(string name, string fileNameExtension, Encoding encoding,
                                  string mimeType, bool willSeek)
            //Stream stream = new FileStream(name + "." + fileNameExtension, FileMode.Create);
            Stream stream = new MemoryStream();
            return stream;
        public static void Export(LocalReport report)
            string deviceInfo =
              "<DeviceInfo>" +
              "  <OutputFormat>EMF</OutputFormat>" +
              "  <PageWidth>8.5in</PageWidth>" +
              "  <PageHeight>11in</PageHeight>" +
              "  <MarginTop>0.25in</MarginTop>" +
              "  <MarginLeft>0.25in</MarginLeft>" +
              "  <MarginRight>0.25in</MarginRight>" +
              "  <MarginBottom>0.25in</MarginBottom>" +
            Warning[] warnings;
            m_streams = new List<Stream>();
            report.Render("Image", deviceInfo, CreateStream, out warnings);
            foreach (Stream stream in m_streams)
                stream.Position = 0;
        public static void PrintPage(object sender, PrintPageEventArgs ev)
            Metafile pageImage = new Metafile(m_streams[m_currentPageIndex]);

            ev.Graphics.DrawImage(pageImage, 0, 0, System.Convert.ToInt32(pageImage.Width * 1.04), System.Convert.ToInt32(pageImage.Height * 1.04)); // Try to fix zoom problem

            ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
        public static void Print()
            const string printerName = "\\\\NCS-SRV10\\PoolGroupMono";
            if (m_streams == null || m_streams.Count == 0)
            PrintDocument printDoc = new PrintDocument();
            printDoc.PrinterSettings.PrinterName = printerName;
            if (!printDoc.PrinterSettings.IsValid)
                string msg = String.Format("Can't find printer \"{0}\".", printerName);
            printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
        public static void Run(string ReportName, ReportDataSource rDataScource, string courseCode, string personCode)
            LocalReport STUreport = new LocalReport();

            STUreport.ReportPath = ReportName; // Report name (KazooReports.StudentReport.rdlc)

            STUreport.DataSources.Add(rDataScource); // Data source

             * Set report parameters
             * --------------------------------------------*/
            // Set the students ID for the report
            ReportParameter pStudentID = new ReportParameter();
            pStudentID.Name = "pStudentID";
            STUreport.SetParameters(new ReportParameter[] { pStudentID });

            // Set the Course title for the report         
            ReportParameter pCourseID = new ReportParameter();
            pCourseID.Name = "pCourseID";
            STUreport.SetParameters(new ReportParameter[] { pCourseID });

            m_currentPageIndex = 0;


Open in new window

any ideas anyone!?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
Try to change the printPage method to:
public static void PrintPage(object sender, PrintPageEventArgs ev)
            Metafile pageImage = new Metafile(m_streams[m_currentPageIndex]);


            ev.HasMorePages = (m_currentPageIndex < m_streams.Count);

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KazooSoftAuthor Commented:
I will let you knw if this works tomorrow. Having further issues with a loop somewhere!!

I had the same problem and it worked perfectly!! Thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.