Not able to view pdf

Hi,

While running our project through code(localhost) pdf viewer is working properly.But,Once we publish it and test our appplication on server ,we are not able to view any page of pdf and getting an error not able to find ‘GetResourceForHtml’ page .This page is inside my published folder but it is pointing to wrong location.
For Example,our page is inside url: http://mycompany/Mainfolder/GetResourceForHtml.aspx but,it is showing our page inside http://mycompany/GetResourceForHtml.aspx.

Please provide a solution for the same.

@Francis.Devar,

Thanks for using GroupDocs.Viewer. Would you please share with us the source code of your application so that we can investigate the issue? We shall be looking forward to your response.

Hi,
We are using the same code of your group docs.viewer of .Net .In that demo we are using web form UI of showcase .As we told before it is working properly in localhost but while in server it is not able to render PDF page because of URL issue .

@Francis.Devar,

Thanks for providing the information. Would you please confirm whether are you using GroupDocs.Viewer-for-.NET-WebForm-Modern-UI or ASP.NET_WebForm_Front_End as both of these front ends are developed using ASP.NET Web Forms. We shall be looking forward to your response.

Hi,

We had used demo code of ASP.NET_WebForm_Front_End of your groupdocs.viewer

@Francis.Devar,

Thanks for providing the required information. In order to fix this issue, you will have to modify the value of HtmlResourcePrefix property for each instance of HtmlOptions in default.aspx.cs. For example, in your case, the value of HtmlResourcePrefix property would be

HtmlResourcePrefix = string.Format("/Mainfolder/GetResourceForHtml.aspx?documentPath={0}", parameters.Path) + "&pageNumber={page-number}&resourceName=",

Furthermore, you will also have to prepend /Mainfolder in the URLs used in List < PageHtml > GetHtmlPages function in default.aspx.cs. Hope it helps.

Hi,
I had appened the ‘Mainfolder’ name in HtmlResourcePrefix but where and who to prepend ‘MainFolder’ name in List < PageHtml > GetHtmlPages function.The ‘mainfolder’ name is retrieved from webconfig key value .The below code is of block GetHtmlPages function,where Group_Url is refering to Mainfolder name in web.config.

if (text.IndexOf("url(\"", StringComparison.Ordinal) >= 0 &&
                    text.IndexOf("url(\"/" + Group_Url + "/GetResourceForHtml.aspx?documentPath=", StringComparison.Ordinal) < 0)
                 {
                     needResave = true;
                     text = text.Replace("url(\"",
                    // string.Format("url(\"/GetResourceForHtml.aspx?documentPath={0}&pageNumber={1}&resourceName=",
                      string.Format("url(\"/" + Group_Url + "/GetResourceForHtml.aspx?documentPath={0}&pageNumber={1}&resourceName=",
                     HttpUtility.UrlEncode(filePath), page.PageNumber));
                 }

                 //if (text.IndexOf("url('", StringComparison.Ordinal) >= 0 &&
                 //    text.IndexOf("url('/GetResourceForHtml.aspx?documentPath=", StringComparison.Ordinal) < 0)

                 if (text.IndexOf("url('", StringComparison.Ordinal) >= 0 &&
             text.IndexOf("url('/GetResourceForHtml.aspx?documentPath=", StringComparison.Ordinal) < 0)
                 {
                     needResave = true;
                     text = text.Replace("url('",
                         string.Format(
                             "url('/GetResourceForHtml.aspx?documentPath={0}&pageNumber={1}&resourceName=",
                             HttpUtility.UrlEncode(filePath), page.PageNumber));
                 }

@Francis.Devar,

Yes, you got it correctly. You will prepend the value of Group_Url before every occurrence of GetResourceForHtml.aspx in GetHtmlPages function as shown in following code snippet.

Group_Url = "/" + Group_Url;

var needResave = false;
if (text.IndexOf("url(\"", StringComparison.Ordinal) >= 0 &&
                        text.IndexOf("url(\""+Group_Url+"/GetResourceForHtml.aspx?documentPath=", StringComparison.Ordinal) < 0)
{
       needResave = true;
       text = text.Replace("url(\"", string.Format("url(\"" + Group_Url + "/Viewer-Webforms_Old/GetResourceForHtml.aspx?documentPath={0}&pageNumber={1}&resourceName=",
                        HttpUtility.UrlEncode(filePath), page.PageNumber));
}
if (text.IndexOf("url('", StringComparison.Ordinal) >= 0 &&
       text.IndexOf("url('"+ Group_Url + "/GetResourceForHtml.aspx?documentPath=", StringComparison.Ordinal) < 0)
{
         needResave = true;
         text = text.Replace("url('",
         string.Format("url('" + Group_Url + "/GetResourceForHtml.aspx?documentPath={0}&pageNumber={1}&resourceName=",
                                HttpUtility.UrlEncode(filePath), page.PageNumber));
}

Hi,

We had merged the above code in our project ,but now if we have 40 pages of pdf file ,it is rendering 5 pages working but the remaining pages is not opening.While debugging ,we found that now it is not taking the I.P address after 5 pages but it is getting the main folder name and the remaining url correctly.We shall be looking forward to your response.

@Francis.Devar,

Thanks for coming back to us. We have checked to load the documents with more than 5 pages but could not reproduce your reported issue. Please try to remove the cache files of the documents from the temp folder and view the document again. Furthermore, please also check the console of the browser for any errors. We shall be looking forward to your response.

It is important to inform you that we are discontinuing the support of old front ends including ASP.NET_MVC_Front_End and ASP.NET_WebForm_Front_End. Therefore, we recommend you to migrate to the Modern UI front ends (listed below).

Hi,

We had already merged the code of ASP.NET_WebForm_Front_End demo with our project and have license version of groupdocs.viewer .Now the issue with groupdocs.viewer is that ,it is showing 500 (Internal Server Error) Error .It is not able to get ViewDocument function in my page which is your default page in demo.But,when i am hard coding the main folder name within the code
‘text = text.Replace(“url(”", string.Format(“url(”" + Group_Url + “/Viewer-Webforms_Old/GetResourceForHtml.aspx?documentPath={0}&pageNumber={1}&resourceName=”’ pdf is working fine and there is no issue when we append the string which in our case is 'Group_Url ’ ’ to the code we find issue in pdf and now pdf is not opening

@Francis.Devar,

Thanks for your response. What I understood from your reply is when you hardcode the value of main folder in which the GetResourceForHtml.aspx page is located, the PDF is loaded without any issue. However, if you use Group_Url in the URL string then you get the error “500 (Internal Server Error) Error”. In that case, would you please give us the access to your application so that we can check the issue?

I have marked this topic as Private, therefore any information or data shared here will be only accessible to you and the GroupDocs staff members.

Hi,

I have attached one pdf document which contain the code of PDF link button which on click redirects to next page that is to ShowPDFFile1.aspx page which is default.aspx page in demo of groupdocs.viewer in .net.Please so through the document and do the needful .We shall be looking forward to your response.GroupdocsIssue.pdf (329.2 KB)

@Francis.Devar,

Thanks for providing the details. We were able to reproduce the issue using your provided details. We have created a sample demo application for you by following your provided details and fixed the issue in that. You can download the application from here. Hope it helps.
.