Hello,
i try to show a pdf file with the PdfjsProcessingSettings, but i get the message "file fails to process."
What have i made wrong?
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager"
/>
<
telerik:RadSkinManager
ID
=
"RadSkinManager1"
runat
=
"server"
ShowChooser
=
"true"
/>
<
script
type
=
"text/javascript"
>
window.pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.2/pdf.worker.js';
</
script
>
<
telerik:RadPdfViewer
runat
=
"server"
ID
=
"RadPdfViewer1"
RenderMode
=
"Lightweight"
Height
=
"550px"
Width
=
"900px"
Scale
=
"1.5"
ActivePage
=
"1"
>
<
PdfjsProcessingSettings
File
=
"unterlagen.pdf"
>
</
PdfjsProcessingSettings
>
</
telerik:RadPdfViewer
>
<
script
>
kendo.pdfviewer.pdfjs.processor.fn._updateDocument = function (file) {
if (this.pdf) {
this.pdf.loadingTask.destroy();
}
this.file = file;
};
</
script
>
Best regards
Jens
17 Answers, 1 is accepted
Hi Jens,
Do you get this error in IE only or in all browsers? If it is IE specific, please disable the compatibility mode and test again.
Regards,
Rumen
Progress Telerik

Hello Rumen,
i get the error with firefox too.
if i open a pdf with the open-dialog there is no problem.
Best regards
Jens
Hi Jens,
Thank you for the extra info.
Can you please rename the pdf file to png and attach it here so that I can test it?
If the upload control validation errors ou and the file didn't make it attached, please upload it to some cloud hosting and provide a download link.
Regards,
Rumen
Progress Telerik

Hello Rumen,
here is the file.
Best regards
Jens

Hello Rumen,
i find the solution.
There was an httpredirect in the web.config. i disabled it and then i see the pdf when the pas is load.
Best regards
Jens
Good news! I am glad that you managed to find out what is causing the problem and resolved it!
If it is not something secret, can you please share the redirect so that the community gets an example of what might cause the error.
Thank you!
Regards,
Rumen
Progress Telerik

I have the same issue "PDF file fails to process". However, i can load a PDF that is on the disk, but not on the internet.
I took your demo and tried the local document
<
telerik:RadPdfViewer
runat
=
"server"
ID
=
"RadPdfViewer1"
Height
=
"550px"
Width
=
"100%"
Scale
=
"0.9"
>
<
PdfjsProcessingSettings
File
=
"Document.pdf"
/>
</
telerik:RadPdfViewer
>
... the i replaced with a internet file..
<
telerik:RadPdfViewer
runat
=
"server"
ID
=
"RadPdfViewer2"
Height
=
"550px"
Width
=
"100%"
Scale
=
"0.9"
>
<
PdfjsProcessingSettings
File
=
"http://www.africau.edu/images/default/sample.pdf"
/>
</
telerik:RadPdfViewer
>
So i downloaded the "sample.pdf" to the local drive and it worked opening it with the PDFViewer. If the viewer FAILS with the error above it can not open the file, as it just states "Loading...". To wrap this issue up. If the PDFViewer fails with the "PDF file fails to process", it can never open any PDF after it fails. The same file on the internet could not be opened with the PDFViewer, but once it is local it can open fine.
BTW, I see you fixed the file upload, however, i am trying to attach the sample.pdf which is 3kb, but it fails as it states its larger than 2MB.
Hi Brian,
It looks like that the file does not have the needed permissions and access to be loaded by the browser and pdf.js library because I get this error in the DevTools console:
Access to fetch at 'http://www.africau.edu/images/default/sample.pdf' from origin 'http://localhost:57873' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
www.africau.edu/images/default/sample.pdf:1 Failed to load resource: net::ERR_FAILED
Do you get the same error in your DevTools console:
If the files is accessible or the PdfViewer app is hosted on the same server, the file should be loaded properly with the provided URL.
Otherwise, you can use the Telerik Document Processing library to convert it to a stream and to load it in the PdfViewer - as shown in the following demo:
PdfViewer - Convert, View and Download Different Formats:
protected void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
{
byte[] renderedBytes = null;
string extention = Path.GetExtension(e.File.FileName);
// RadFlow Documents
if (Regex.IsMatch(extention, ".docx|.rtf|.html|.txt"))
{
IFormatProvider<RadFlowDocument> provider = null;
RadFlowDocument document = null;
switch (extention)
{
case ".docx": provider = new DocxFormatProvider(); break;
case ".rtf": provider = new RtfFormatProvider(); break;
case ".html": provider = new HtmlFormatProvider(); break;
case ".txt": provider = new TxtFormatProvider(); break;
default: provider = null; break;
}
document = provider.Import(e.File.InputStream);
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider pdfProvider = new
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
using (MemoryStream ms = new MemoryStream())
{
pdfProvider.Export(document, ms);
renderedBytes = ms.ToArray();
}
}
// Workbook Documents
else if (Regex.IsMatch(extention, ".xlsx|.csv"))
{
IWorkbookFormatProvider provider = null;
Workbook document = null;
switch (extention)
{
case ".xlsx": provider = new XlsxFormatProvider(); break;
case ".csv": provider = new CsvFormatProvider(); break;
default: provider = null; break;
}
document = provider.Import(e.File.InputStream);
Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider pdfProvider = new
Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider();
using (MemoryStream ms = new MemoryStream())
{
pdfProvider.Export(document, ms);
renderedBytes = ms.ToArray();
}
}
RadLabel1.Text = "Displayed Document: <b>" + e.File.FileName + "</b>";
RadPdfViewer1.PdfjsProcessingSettings.FileSettings.Data = Convert.ToBase64String(renderedBytes);
}
Regards,
Rumen
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.

Hi Rumen,
Yes, your right i get the same result as you, the origin policy. I am able to access on the same domain, so we are okay using this control. The concern was if it fails, it can never open another doc unless you refresh the page. But its seems ajaxifying the control work for this, as below. I can swap back and forth and the PDF is loaded.
<
telerik:RadAjaxPanel
runat
=
"server"
>
<
telerik:RadButton
runat
=
"server"
ID
=
"RadButtonLoadGood"
RenderMode
=
"Lightweight"
Text
=
"Load Good Doc"
OnClick
=
"RadButtonLoadGood_Click"
/>
<
telerik:RadButton
runat
=
"server"
ID
=
"RadButtonLoadBad"
RenderMode
=
"Lightweight"
Text
=
"Load Bad Doc"
OnClick
=
"RadButtonLoadBad_Click"
/>
<
telerik:RadPdfViewer
runat
=
"server"
ID
=
"RadPdfViewer2"
Height
=
"550px"
Width
=
"100%"
Scale
=
"0.9"
>
<
PdfjsProcessingSettings
>
</
PdfjsProcessingSettings
>
</
telerik:RadPdfViewer
>
</
telerik:RadAjaxPanel
>
Hi Brian,
The ajaxification of the PdfViewer is a perfect solution for solving the file open issue without refreshing the whole page.
Thank you for sharing it with the community!
Regards,
Rumen
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.

Hello jens,
Can you please share the code of your web.config before changing and after changed.
Best regards
sarthkee
Hi Sarthkee,
I am afraid that Jens has not yet shared information about the httpredirect in the web.config file and the applied changes to it.
If you experience such a problem look for redirects concerning the *.pdf extension and also provide information about the problem and how to replicate it.
Regards,
Rumen
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Yahhh...sure Rumen..
But in my web.config there is no httpredirect.
Regards,
Sarthkee
Basically, you can have redirects defined in different parts of the project, e.g. Global.asax. Check points 2, 3, and 4 in this KB article on the matter: Error: Web.config registration missing! The Telerik dialogs require a HttpHandler registration in the web.config file.
Once again, if you experience any troubles please explain what the problem is and provide instructions on how to replicate them.
Regards,
Rumen
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.


I am finding this control frustrating. Seems to me that 20 years ago there was a control you could put in your sites / forms that had an OPEN command and that was it. I am not even sure what I am supposed to do with this control. Set the Name and wait for things to happen? When I hard code the address to a known HTML address it sits with LOADING... on the page forever.
Why was such a simple concept made difficult? I gather the functionality has been moved client side but what is the point of showing people PDF files they have on their own computer or could access without my web page anyways?
But more frustrating is that it does not give any useful errors and your demo's which are usually very good, do not seem to include what HAS TO BE the most common use case: showing someone a file contained on your server that they can only access on our server?
Hello Brett,
Thanks a lot for the shared feedback. We will update our documentation right away with detailed information regarding the paths accepted by RadPdfViewer.
The control uses Pdf.js framework for file processing, which currently allows two type of paths:
- Relative paths to PDF files plaved inside the application root directory. You can either hardcode it or use the Select Project item dialog of Visual studio for easier navigation: video.
<telerik:RadPdfViewer runat="server" ID="RadPdfViewer1" RenderMode="Lightweight" Height="550px" Width="900px"> <PdfjsProcessingSettings File="./documents/PdfDocument.pdf"> </PdfjsProcessingSettings> </telerik:RadPdfViewer>
- or url paths prointing to accessible PDF files stored in the same domain. You can find detailed explanation regarding the PDF.js path validation in the following github item: https://github.com/mozilla/pdf.js/pull/6916
<telerik:RadPdfViewer runat="server" ID="RadPdfViewer2" RenderMode="Lightweight" Height="550px" Width="900px"> <PdfjsProcessingSettings File="http://yourdomainname.com/documents/PdfDocument.pdf"> </PdfjsProcessingSettings> </telerik:RadPdfViewer>
I hope that this information will be helpful for you.
Regards,
Vessy
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.