Hi All
I would like to implement the functionality offered by SQL Server 2005 Reporting Services that
exports the report to PDF, but I want to do it in my C# 2005 application.
Can I do this? How?
Please help.
khuzwayom
Sure. See code here. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1715591&SiteID=1
>L<
|||Thank you so much Lisa, Iwill try your code tomorrow.
Don't you import anything or add any references?
Thank You
khuzwayom
|||>>
Don't you import anything or add any references?
<<
I've fully-namespaced all the instancing of objects in that sample, I'm pretty sure -- so you will probably have no problem figuring out what references are required. If you do, holler...
>L<
|||Lisa,
I have a question with this particular line and not sure how to use it my project.
http://localhost/reportserver/?/Report+Project1/TestCity&rs:Command=Render&rs:format=EXCEL)
In my project based on the values sent by a ddl i am displaying 2 kinds of reports. and they are being stored in the report server. and when clicks on the Export link button in the report viewer control, i want to save that file as an PDF. So how should i do it?
Dim ox As System.Net.HttpWebRequest = _
System.Net.HttpWebRequest.Create _
(http://192.168.0235/Statements/StatementMain&rs:Command=Render&rs:format=PDF)
i tried using ur code snipet and got the following error
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Source Error:
Line 123: ' the line above may not work for you, you may have to provide credential information with more work Line 124: Line 125: Dim oy As System.Net.HttpWebResponse = ox.GetResponse() Line 126: Dim raw As System.IO.FileStream = New System.IO.FileStream("c:\Documents and Settings\Karen\Desktop\p.pdf", IO.FileMode.Create) Line 127: ' for a PDF, change the extension in the line above, along with changing its
any help will be appreciated.
Regards
Karen
|||I think your problem is simply figuring out the right URL, Karen.
I don't think you should be using http://192.168.0235/Statements, although it is hard for me to say exactly what the right URL is for you.
Here is what I think you should do:
1) check your Reporting Services configuration. There are two web server applications set up for RS. One is the Report Manager site, one is the Report Server site.
By default, the former is http://<server>/Reports, and the other is http://<server>/ReportServer. The latter is the one we want to use.
OK so far? I don't know the web site aliases or virtual directories on your box, but the web application we want to talk to is the Report Server.
2) "Visit" that site interactively in your browser. It does not look like Report Manager. You should see browable directories, instead.
3) In your browser, drill down to the report that you want to use from the ReportServer root. You can actually run the report interactively this way. This should give you most of the URL that you need.
4) Finish off the URL with parameters as shown in my sample code for your programmatic pull.
If this doesn't help, then please check the RS docs -- search using the term "URL access". You will find this described in detail.
HTH,
>L<
|||Lisa,
Is there is a way i can capture the event when the user clicks on the export button?
Regards,
Karen
|||Karen, this might be capturable in the ReportRefresh event, but just in case you're trying to do this to find out what the URL is... that is really the wrong way to go about the task... I hope the instructions I wrote earlier make sense to you, if not where are you stuck?
>L<
|||Lisa, thanks a lot for your answer, what i am really trying to do is let the user view the report using the report viewer control and after he checks whether the data is correct on the reports, then i wanted to capture the export button event and save the report link to the database instead of letting the user save it somewhere else. Any ways i will try looking into the reportrefresh event to see if i can do it.
Regards
Karen
|||Sorry, Karen, we've been having this discussion on another thread and it looks likeReportRefresh will *not* work. I suggested a couple of other events that might solve the other guy's need to capture this event, but I'm not going to refer you there because I really don't think that this is pertinent to what *you* are "really trying to do".
You are using the reportviewer as a preview and then capturing the PDF after user validation, fine. My point is that capturing the export event is not the right way to go about the second action. Having a separate button on the form that indicates "yes, go ahead and save the PDF, the results are correct", *outside* the reportviewer control is the way to go about it.
When your server receives that user response it can then save the PDF whereever you want it to go, using the code discussed here previously, and the proper URL access.
Anyway, that's my opinion...
>L<
|||Hi Lisa,
We are using the Render method to generate report in pdf format.
Currently around 2 documents (2 pdf files are being generated).
How can we merge the files generated into just 1 pdf file?
I tried merging the byte[] returned. The output displays only the last pdf eventhough the size of the new document equals sum of the size of the other 2 documents.
|||Hi AS2007,
The short answer to your question is "a PDF document has a specialized format, which includes a prolog or header that describes the whole document. So you can not just put two of them together like that. But it is possible to do it, certainly from a C# app. You just need to go back to first principles. (Think about : What is a PDF, really?)"
Here's the long answer:
The right way would be to take the output of the two reports, whether as EMFs or a PDF or whatever, and push them out to postscript, from whence they can be converted to a PDF using freely-available tools.
I am going to quote myself from another forum <sigh> because I've answered this question a whole bunch of times for programmers in different environments.
There is other stuff that I don't say in this particular post about how to dynamically check for a PostScript driver setup, and dynamically add such a setup if necessary, brand it to your app, etc. But all that is standard Windows stuff. There is nothing specific about RS in any of it.
HTH,
>L<
-
Is this using the ReportViewer control (client-side) or server side?IAC -- here is what I know on this issue,which is not particular Reporting
Services specific:1) It is easy to move multiple source files into a PDF file if the source
files are in postscript.2) Most printing engines can write postscript files simply by specifying a
postscript print driver3) postscript drivers come with the OS.
4) It is easier to manage this type of activity client-side than
server-side, for many reasons.Here is some advice for you:
You can find a demo app with code for printing reports without UI, using the
ReportViewer control, on this page. http://www.gotreportviewer.com/I expect it can be adapted to go to a ps printer driver and given target
file information (or the ps driver setup can be set to go to a file target
explicitly -- but that doesn't seem thread safe to me).Then you can use standard postscript to PDF capabilites to convert the
string of files you just wrote out. I use Ghostscript to do this, you don't
need Adobe and you don't need any UI for this step either.You can learn about Ghostscript here http://www.ghostscript.com/awki There
is a overview of command-line switches here
http://ghostscript.com/doc/8.54/Use.htm#Options -- for your purposes, pay
particular attention to the ability to create a commandfile listing all the
switches as well as all the files you wish to process in this run (more
flexible than listing the files directly on the command line if your list
may be long). You may prefer to use the API directly (DLLs rather than
command-line). It's quite extensive.>L<
"Rob" <Rob@.discussions.microsoft.com> wrote in message
news:BB990321-62C2-4EEC-9535-9C870DE7BC6A@.microsoft.com...
> Is it possible to render multiple reports and then export them to 1 PDF
> file?
> If so, how can this be accomplished?
No comments:
Post a Comment