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 www.Kazoosoft.eu 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();
            m_streams.Add(stream);
            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>" +
              "</DeviceInfo>";
            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


            m_currentPageIndex++;
            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)
                return;
            PrintDocument printDoc = new PrintDocument();
            printDoc.PrinterSettings.PrinterName = printerName;
            
            if (!printDoc.PrinterSettings.IsValid)
            {
                string msg = String.Format("Can't find printer \"{0}\".", printerName);
                Console.WriteLine(msg);
                return;
            }
            printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
            printDoc.Print();
        }
        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";
            pStudentID.Values.Add(personCode);
            STUreport.SetParameters(new ReportParameter[] { pStudentID });

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


            Export(STUreport);
            m_currentPageIndex = 0;
            Print();
        }

    }
}

Open in new window


any ideas anyone!?
LVL 4
KazooSoftAsked:
Who is Participating?
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.Graphics.DrawImage(pageImage,ev.PageBounds); 

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

Open in new window

0

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!!

Ahh!!!
0
KUMON2004Commented:
I had the same problem and it worked perfectly!! Thanks!
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.