Solved

browser issue

Posted on 2009-07-16
15
169 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
 

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
DevOps Toolchain Recommendations

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

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now