Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SourceFile and SourceRdl mutually exclusivity during PrintClicked() #157

Open
Daaell opened this issue May 8, 2017 · 0 comments
Open

SourceFile and SourceRdl mutually exclusivity during PrintClicked() #157

Daaell opened this issue May 8, 2017 · 0 comments

Comments

@Daaell
Copy link

Daaell commented May 8, 2017

I try to embed the *.rdl file into the compiled *.exe.

First i tried to use the SourceFile property, but i gave up on it, because i couldn't get a Uri for the resource file. Instead i used SourceRdl, which worked:

viewer.SourceRdl = System.Text.Encoding.UTF8.GetString(Properties.Resources.report_file)

This works, the report shows up correctly in the viewer, i'm able to use the ViewerToolstrip's Save, to save out a pdf, etc.

But when i tried to Print() it, i got a NullReferenceException because i'm using SourceRdl. And if SourceRdl is set, SourceFile is null, but Print() tries to access 'SourceFile.LocalPath'

    private void PrintClicked(object sender, System.EventArgs e)
    {
        if (Viewer == null)
        {
            return;
        }

        PrintDocument pd = new PrintDocument();
        pd.DocumentName = Viewer.SourceFile.LocalPath; <- NullReferenceException
        pd.PrinterSettings.FromPage = 1;
        pd.PrinterSettings.ToPage = Viewer.PageCount;
        pd.PrinterSettings.MaximumPage = Viewer.PageCount;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants