Link to home
Start Free TrialLog in
Avatar of dan henderson
dan hendersonFlag for United States of America

asked on

specify report name when saving as pdf file

when saving a report created with ssrs as a pdf file, is there any way to specify the name of the pdf file?
Avatar of Misha
Misha
Flag of Russian Federation image

Do you want do it porgrammatically (with C# for example) or not?
You can click
Run or Preview the report, then click Export  on the ribbon, select PDF fromat and the Save As dialog will open. By default, the file name is that of the report that you exported. Optionally, you can change the file name.
Avatar of dan henderson

ASKER

yes, that's what I'm doing at the moment.  This is a web application.  When the user saves the report as a pdf, I want to supply a name programmatically .
BTW, I'm NOT using the control, just the report web url.
If you are using the ReportViewer control, you can set the DisplayName property.
YourReportView.LocalReport.DisplayName = "YourName"

Open in new window

I am not using the ReportViewer control.  This is strictly web delivery.
Ok, there is answer in Expert Exchange about save pdf report.
https://www.experts-exchange.com/questions/27581973/Programmatically-export-an-SSRS-report-to-pdf-file.html
Can you set your file name of pdf report while you write file with FileStream ?
 FileStream stream = File.OpenWrite("D:\\YourFileName.pdf");

Open in new window

I have not tried that ... currently I use the download button on the report to download a pdf file.  How would I use a filestream object instead of this?  Here is the code on my view:

<h2>Patrol Monthly Summary</h2>
<br /><br />
<div>
    <iframe src="@ViewBag.Url" width="900" height="900"></iframe>
</div>

Open in new window


The URL for the report is passed in the ViewBag, which uses the "&rs:embed=true" parameter to view on cshtml page.
You can not change file name from the client side (HTML or javascript). You need to change it from the server.
ASKER CERTIFIED SOLUTION
Avatar of Misha
Misha
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I was trying to pre-set the file name, since using "save as" seems a bit to complex for my client ;)
guess that's the only way to do it.  thanks.