Name in pdf export dialog

G

glbdev

I have code in C# to create a pdf file without a Crystal Report Viewer.
Works great except when the user attempts to save the file. In the
"Save a copy ..." dialog box the filename defaults to the aspx page. I
need it to default to a custom report name. How can I specify the new
file name in C# and pass it to the new PDF page?

Thanks,
Gary
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

What are you using to generate it but CR ?

In case you are creating a report, exporting it to disk and then serve it
back to the client you will have to modify the headers, I do not remember
right now the correct header that indicate the name of the file being serve,
but a quick search in the archives will get you it.

Btw, when I needed to do this I found the answer in the aspnet NG archive,
so that would be a good stop for you to further info.


--
Ignacio Machin
machin AT laceupsolutions com


|I have code in C# to create a pdf file without a Crystal Report Viewer.
| Works great except when the user attempts to save the file. In the
| "Save a copy ..." dialog box the filename defaults to the aspx page. I
| need it to default to a custom report name. How can I specify the new
| file name in C# and pass it to the new PDF page?
|
| Thanks,
| Gary
|
 
M

Mythran

I have code in C# to create a pdf file without a Crystal Report Viewer.
Works great except when the user attempts to save the file. In the
"Save a copy ..." dialog box the filename defaults to the aspx page. I
need it to default to a custom report name. How can I specify the new
file name in C# and pass it to the new PDF page?

Thanks,
Gary

Try the header content-disposition with a value of
attachment;filename=saveasfilename.pdf

so :

Response.AddHeader(
"content-disposition",
"attachment; filename=\"YourFileNameHere.pdf\""
)


HTH :)

Mythran
 
G

glbdev

Yes! That worked. Thanks.

- Gary
------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top