CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2011
    Posts
    73

    [RESOLVED] Convert From c# - For Report Viewer Report save as PDF

    Hi Iam using the below codes to save the report as PDF in c#...Is it possible to convert it in C++/Cli

    Thanks

    My Codes

    byte[] Bytes = Reportviewer1.LocalReport.Render(format:"PDF",deviceInfo:"");
    using (FileStream stream = new FileStream("C:\MyFolder", FileMode.Create))
    {
    stream.Write(Bytes, 0, Bytes.Length);
    }
    Last edited by MAHEY; June 17th, 2015 at 01:33 AM. Reason: Edited as ReportViewer1

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Convert From c# - For Report Viewer Report save as PDF

    Doesn't look complicated. What's the problem?
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Dec 2011
    Posts
    73

    Re: Convert From c# - For Report Viewer Report save as PDF

    Hi ERI, Thanks for the helps ERI. Still Iam keeping my Boolean Variable Names as ERI, to remember your helps...

    I tried like the below manner, but showing the "error C2143: syntax error : missing ';' before '[' "

    System::Byte[]^ Bytes = reportViewer1->LocalReport->Render("PDF", "");
    System::IO::FileStream^ stream = gcnew System::IO::FileStream("C:\\", System::IO::FileMode::Create){
    stream->Write(Bytes, 0, Bytes->Length);
    }

    Thanks ERI

  4. #4
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Convert From c# - For Report Viewer Report save as PDF

    array<System::Byte>^ Bytes = reportViewer1->LocalReport->Render("PDF", "");

  5. #5
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Convert From c# - For Report Viewer Report save as PDF

    Yes, you got the array syntax wrong, and Alex already posted the correction.

    Also, there's no direct equivalent to the C# using construct in C++/CLI, and what you posted doesn't syntactically make sense in C++/CLI. What comes closest to the using construct in C++/CLI would be the use of an implicitly dereferenced variable. (You can use forum search to find a few threads discussing this, and perhaps find a bit more details about what it does.) This is what it would look like:

    Code:
    {
      System::IO::FileStream stream("C:\\MyFolder", System::IO::FileMode::Create);
      stream.Write(Bytes, 0, Bytes->Length);
    }
    Note that the omission of the ^ in the second line and use of the dot operator instead of -> in the third line are no mistakes: Implictitly dereferenced variables of reference types use value type syntax.

    Though it may seem so on first look, the uncontrolled brace pair surrounding the code snippet is not redundant. It limits the scope of the variable stream so that the stream gets implicitly closed when execution reaches the closing brace.
    Last edited by Eri523; June 18th, 2015 at 09:25 AM.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  6. #6
    Join Date
    Dec 2011
    Posts
    73

    Re: [RESOLVED] Convert From c# - For Report Viewer Report save as PDF

    Thanks to those kindness.....I get very clear...
    Thanks Again

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured