Asp.net Change File Name at Runtime?

Hello,

I have a page a that you select a company on -> click Submit -> this takes you to the report.aspx page.  
The report.aspx page has over 300 lines of data in a table.  The table is highly stylized.

What I need to do is either make a PDF with the company name as the filename OR
Produce an .aspx page with the company name as the filename and the user can print it to PDF.  

To create a pdf I've tried using
<%Response.AddHeader("content-disposition", "Attachment;Filename=" & thisCompanyName & ".pdf")
    Response.ContentType = "application/pdf"%>
The file doesn't generate

I've looked at iTextSharp and it looks like it will take a bunch of coding to create the table with all the stylings in it.

To produce a new file
I took the report.aspx and change the page title to the company name then print it physically to pdf - the file comes out with Report.aspx file name.  Tab at the top of the browser displays the correct company name.  (Thought I used this before) No good.

Any ideas?

JS
LVL 2
jshesekAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ArkCommented:
0
ArkCommented:
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim url = "http://www.htm2pdf.co.uk/convert_url.php"
        Using client = New Net.WebClient
            Dim data As New Specialized.NameValueCollection
            Dim targetUrl = ""http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_28669582.html"
            data.Add("url", targetUrl)
            client.Proxy = Nothing
            Dim bytes = client.UploadValues(url, data)
            Dim response = ""
            Using stm As New IO.MemoryStream(bytes)
                Using reader As New IO.StreamReader(stm)
                    response = reader.ReadToEnd
                End Using
            End Using
            Dim regex = New System.Text.RegularExpressions.Regex("(file=[^>]*)>")
            Dim fileUrl = "http://www.htm2pdf.co.uk/download.php?" & regex.Match(response).Groups(1).Value
            client.DownloadFile(fileUrl, "c:\temp.pdf")
        End Using
    End Sub

Open in new window

here is a windowsapp sample which use html2pdf service. fileUrl is an address to download pdf file. In your web app you can simply add a link with this url. You can do this either from server side using WebClient/WebHTTPRequest or from client side via xmlhttprequest or ajax.
0
jshesekAuthor Commented:
The data can't be uploaded anywhere.
0
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

jshesekAuthor Commented:
Is there anyway you can use add header and change the filename when the page is created?  
If the page is called report.aspx -> can I change it to AcmeCo.aspx in the coding?
0
jshesekAuthor Commented:
Is it possible for this to happen?
Start out on SelectCompany.aspx    select the company from a drop down
This sends you to report.aspx - Report.aspx is loaded with the data
Can I Copy and rename the report.aspx to newCompanyName.aspx   and transfer to it?
0
jshesekAuthor Commented:
Ok solved the problem with
https://myworkcodes.wordpress.com/2011/07/02/creating-asp-net-page-dynamically-using-dotnet-programe/

Generate the Report.aspx page
 File.Copy(Server.MapPath("") + "\\Report.aspx", (Server.MapPath("") + "\\" & thisReportName & ".aspx"))
File.Copy(Server.MapPath("") + "\\Report.aspx.vb", (Server.MapPath("") + "\\" & thisReportName & ".aspx.vb"))

Closed the report.aspx page and set a link on the select the company page.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jshesekAuthor Commented:
Solved the problem
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.