Problem ActiveReport.Run(): Printer does not support a4 papersize

Posted by: jeroen-dd on 28 September 2017, 4:14 am EST

    • Post Options:
    • Link

    Posted 28 September 2017, 4:14 am EST

    [activereports_archive]

    Dear AR lovers,



    I got myself stuck with the following problem:



    At the moment of report creation ActiveReports throws:

    Printer does not support A4 papersize. Please use PaperKind.Custom in your PageSettings or specify a papersize supported by the current printer



    this is the code:



    //assume we have a table with data:

    DataTable table = GetData();





    DataDynamics.ActiveReports.ActiveReport rpt = new DataDynamics.ActiveReports.ActiveReport();

    strm = new System.IO.MemoryStream(report.TemplateData);

    strm.Position = 0;

    rpt.LoadLayout(strm);

    strm.Close();



    rpt.DataSource = table;

    rpt.Run();//blocked mode







    Does anyone know why AR is complaining about a printer at this point?

    Is there any way to circumvent this behavior?



    Choosing another default printer on the machine in question doesn’t solve the problem.

    Choosing another paper size (eg Letter) doesn’t solve the problem.

    I am obsolutely sure that the printers selected were capable of printing at the sizes specified.





    Thanks in advance,

    Jeroen

    [/activereports_archive]

  • Posted 28 September 2017, 4:14 am EST

    [activereports_archive]

    If you set at designtime A4 as the paper size, the report engine looks at the default printer for the machine (if it’s a windows environment) or the default printer that is setup for the ASPNET account, which usually is nothing if this is a web environment.  You can set the Printer’s name to a null string (“”) to tell ActiveReports to not look for a printer and it will figure out proper page settings on its own.

    [/activereports_archive]

  • Posted 28 September 2017, 4:14 am EST

    [activereports_archive]Hi there,

    I have what I think is a similar problem that I’m hoping will have the same solution. I have a report writing “wizard” dll that uses Active Reports. One of my collegues who is using the dll overseas gets an error when previewing any report:



    Inner Exception: Failed to open the \xxxxxx\KONICA MINOLTA Di2510 PCL6 printer, System error number: 5

     

    at DataDynamics.ActiveReports.Document.DDPaperSize.-1(String printerName, String paperName, Single width, Single height)

       at DataDynamics.ActiveReports.Document.DDPaperSize…ctor(String printerName, String paperName, Single width, Single height)

       at DataDynamics.ActiveReports.ActiveReport.-dfd()

       at DataDynamics.ActiveReports.ActiveReport.-dbf(Boolean bDelayedInit)

       at DataDynamics.ActiveReports.ActiveReport.Run(Boolean syncDocument)

       at DataDynamics.ActiveReports.ActiveReport.Run()



    Do you think this is caused by an invalid paper size for his printer or some other problem with the printer that is connected to his machine?

    As my tool will be used across multiple countries would you recommend disabling the report printer by setting the PrinterName to an empty string so a report designed in A4 in Australia will be able to be viewed (but not printed) in America without throwing an exception?



    Thanks in advance.

    [/activereports_archive]

  • Posted 28 September 2017, 4:14 am EST

    [activereports_archive]

    I’ve done the following to my existing code;



       ActiveReport rpt = new ActiveReport();

       …

       rpt.Document.Printer.PrinterName = “”;

       rpt.Run();



    But when it gets to rpt.Run() I get the following error;



       An unhandled exception of type ‘System.NullReferenceException’ occurred in activereports.dll

       Additional information: Object reference not set to an instance of an object.



    At the point just before this error the ((DataDynamics.ActiveReports.Document.Printer)((rpt.Document.Printer))).VisibleBounds value is;

       <error: an exception of type: {System.Drawing.Printing.InvalidPrinterException} occurred>



    Is this related to my error? Am I setting the PrinterName property of the wrong control? When I remove the line that sets this to an empty string the report runs fine on my machine but a colleague overseas has the error described in the previous post.

    [/activereports_archive]

  • Posted 28 September 2017, 4:14 am EST

    [activereports_archive]The error 2 posts above sounds like a connection issue with the printer.  Setting the printer name to a null string will not cause this error that you are recieving in the above post, I would need to take a closer look at your code to determine why this is happening.  Make sure you are using the latest build of ActiveReports for .NET (Build 2009 I believe is the most current at the moment) and you might try putting the code in a try catch block and write out the stack trace somewhere for review.  This should give us a better idea of where exactly the error is being thrown and if it’s within the ActiveReports object or elseware.[/activereports_archive]

  • Posted 28 September 2017, 4:14 am EST

    [activereports_archive]

    I’ve found the problem!

    I have been setting some of the PageSettings of the report including the PageSettings.PaperName attribute in a derived class. When I comment out the PaperName assign the preview report runs fine after setting the PrinterName to a null string.

    So now I can release a new version to my overseas colleague. Just to make sure that I am on the right track with this do you think setting the PrinterName attribute to a null string before running a report will bypass the connection issue with the printer which is giving him his error?



    Cheers

    [/activereports_archive]

  • Posted 28 September 2017, 4:14 am EST

    [activereports_archive]It should as it shouldn’t attempt to look for the printer at all now.[/activereports_archive]

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels