Did you set the Copy Local property as ture with PdfBox.dll? If not, please set it. If this issue still exist, please post the error details to us, and tell us which line occurs the orror.
Regards
Young Yang
Please mark the replies as answers if they help or unmark if not.
Feedback to us
M.Ehtesham.S...
Member
16 Points
25 Posts
IIS Hosted application giving error while reading a word document.
Apr 25, 2012 05:13 AM|LINK
Hi,
My application is in asp.net mvc3 coded in C#.Net.Im using Microsoft.Office.Interop.Word.ApplicationClass to read the word document and
PdfBox dll's to read the .Pdf to display in a textbox using ViewBag.
Below is my code to read word document.
foreach (string inputTagName in Request.Files) { HttpPostedFileBase Infile = Request.Files[inputTagName]; if (Infile.ContentLength > 0 && (Path.GetExtension(Infile.FileName) == ".doc") || (Path.GetExtension(Infile.FileName) == ".docx") || (Path.GetExtension(Infile.FileName) == ".rtf")) { filePath = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, Path.GetFileName(Infile.FileName)); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } Infile.SaveAs(filePath); Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass(); string filePath1 = filePath; object file = filePath1; object nullobj = System.Reflection.Missing.Value; object objReadonly = false; Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref file, ref nullobj, ref objReadonly, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj); Microsoft.Office.Interop.Word.Document doc1 = wordApp.ActiveDocument; string m_Content = doc1.Content.Text; Resumes = m_Content; ViewBag.test = m_Content; doc.Close(ref nullobj, ref nullobj, ref nullobj); }///My code to read .Pdf else if (Infile.ContentLength > 0 && (Path.GetExtension(Infile.FileName) == ".pdf")) { filePath = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, Path.GetFileName(Infile.FileName)); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } Infile.SaveAs(filePath); PDDocument doc = PDDocument.load(filePath); PDFTextStripper stripper = new PDFTextStripper(); string Pdftext = stripper.getText(doc); Resumes = Pdftext; ViewBag.test = Pdftext; } else { ViewBag.test = "Format Not Supported"; } }But when i Host my application on IIS and Test it.Its giving me error while reading the word document.
The Error is Sorry, an error occurred while processing your request.im getting error while reading .Pdf as well as .docx/.doc
Please suggest.
somnathmali
Contributor
2816 Points
450 Posts
Re: IIS Hosted application giving error while reading a word document.
Apr 25, 2012 05:24 AM|LINK
Please check Word is insatlled on sever.
.NET Developer , Pune INDIA.
Please Mark As Answer If my reply helped you.
M.Ehtesham.S...
Member
16 Points
25 Posts
Re: IIS Hosted application giving error while reading a word document.
Apr 25, 2012 05:34 AM|LINK
Thanks for the reply.
yes ofcourse.The word and Acrobat reader is installed on the machine that hosts my application.
Regards.
ignatandrei
All-Star
135194 Points
21682 Posts
Moderator
MVP
Re: IIS Hosted application giving error while reading a word document.
Apr 25, 2012 10:02 AM|LINK
What do you mean? Word is reading a .pdf file ?
M.Ehtesham.S...
Member
16 Points
25 Posts
Re: IIS Hosted application giving error while reading a word document.
Apr 25, 2012 11:07 AM|LINK
My application reads two file formats.Word(.doc/.docx) and Pdf (.Pdf).
When i run the source of my application then there is no issue.Its reading both the formats.
But when i host the application on IIS then i get the error Sorry, an error occurred while processing your request.
And there is MS-Office as well as Adobe Reader Installed on the hosted machine
ignatandrei
All-Star
135194 Points
21682 Posts
Moderator
MVP
Re: IIS Hosted application giving error while reading a word document.
Apr 25, 2012 12:46 PM|LINK
make a try/catch and on catch write the error stack trace ( return Content( ex.stacktrace))
Be sure to compile and deploy on debug.
Young Yang -...
All-Star
21332 Points
1818 Posts
Microsoft
Re: IIS Hosted application giving error while reading a word document.
Apr 27, 2012 07:40 AM|LINK
Hi
Did you set the Copy Local property as ture with PdfBox.dll? If not, please set it. If this issue still exist, please post the error details to us, and tell us which line occurs the orror.
Regards
Young Yang
Feedback to us
Develop and promote your apps in Windows Store