Solved

browser issue

Posted on 2009-07-16
15
170 Views
Last Modified: 2012-05-07
I have created pdf using itextsharp and it works good on IE7 but it is displaying weird characters with firefox and google chrome, any idea what can I do? Please help!
0
Comment
Question by:1jaws
  • 9
  • 6
15 Comments
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24871767
What's the content-type/encoding you used? What reader software you use? Adobe?
0
 

Author Comment

by:1jaws
ID: 24871783
yes Adobe, it is ok with IE
0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24871865
What's the content-type/encoding you used?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:1jaws
ID: 24871876
how can I check tha I am not sure..
0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24871884
how do you push the PDF to the browser? Is it a link on your page? Do you do response.writefile?
0
 

Author Comment

by:1jaws
ID: 24871927
ok, I think I know why this is happening, what I am doing is, I am using template and PDFStamper, and it creates the pdf perfectly on the server, then I add this code to actually for user to get prompt of saving, byte[] byteArray = File.ReadAllBytes(created path);
                Response.BinaryWrite(byteArray);

it is doing good on IE but, obviously not working on the the other browser, I need to see how can I make user the see created pdf from the server..
0
 

Author Comment

by:1jaws
ID: 24871980
with the other browsers it is opening the binary content of the actual file, not showing the prompt to save the pdf.. what can I do?
0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24871994
Just add these two statements before calling BinaryWrite

Response.AddHeader("content-disposition", "attachment;")
Response.AddHeader("Content-Type", "application/pdf")
0
 

Author Comment

by:1jaws
ID: 24871998
ok, let me try it..
0
 

Author Comment

by:1jaws
ID: 24872186
yes, it did worked! when user asked to save it is saving as a name of the my aspx page, but actually I  string createPDFonthislocation = System.AppDomain.CurrentDomain.BaseDirectory.ToString() + @"pdf\mypdf\" + id + "_test.pdf";      

so it saves to server as a 44_test.pdf but when it prompts to user to save it is saying pdfcreation.aspx  which is my name of the application..      
0
 

Author Comment

by:1jaws
ID: 24872210

do i need to put something else to instead of this (createPDFfromthislocation)
byte[] byteArray = File.ReadAllBytes(createPDFromthislocation);
                Response.BinaryWrite(byteArray);
0
 

Author Comment

by:1jaws
ID: 24872344
is this something to do with Response.AddHeader("Content-Type", "application/pdf");   because it is application that's why it is giving the name of the pdf as a application name? I want is the my createdpdf name from server, not applicaiton name because I use number at the begining of the each pdf
0
 
LVL 15

Accepted Solution

by:
mohan_sekar earned 500 total points
ID: 24872390
Response.AddHeader("content-disposition", "attachment;filename=" + id + "_test.pdf")


Note: for different browsers you may need to try different formats - check this for more info  http://classicasp.aspfaq.com/files/directories-fso/how-do-i-send-the-correct-filename-with-binarywrite.html
0
 

Author Closing Comment

by:1jaws
ID: 31604341
thank you sooo much!!
0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24873300
Glad I could help
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question