c# - Opening a document in PDF as opposed to Word with code on a button click -


i have copied code used throughout system working on. code opens content in word document. looking opened in pdf.

i have tried changing string declaration 'filename' end in (.pdf) opposed (.doc) when attempting open it says "could not open document because either not spported file type or because file has been damaged....".

what changes need made code in order open adope pdf. wouldnt imagine alot.

string content = sw.getstringbuilder().tostring(); string filename = "irpbestpracticearticle.doc";  response.appendheader("content-type", "application/msword; charset=utf-8"); response.appendheader("content-disposition", "attachment; filename=" + filename); response.charset = "utf-8"; response.write(content); 

i cannot certain, going assume you're trying save data pdf , have open in whatever application system uses read pdf files?

//note change application/msword application/pdf response.appendheader("content-type", "application/pdf; charset=utf-8"); 

make sure change mime type doc ending (see here full list of mime types): being said, cant guarantee open in pdf reader


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -