This is a migrated thread and some comments may be shown as answers.

PDF file fails to process

3 Answers 1557 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 22 Aug 2019, 08:51 PM

I am using the example from: https://demos.telerik.com/aspnet-core/pdfviewer/index

No matter what PDF file I put in the code I get the message "PDF file fails to process".  If I use the dialog on the PDF Viewer and go to the exact same PDF file it opens correctly.  Any idea what I am missing?

From Layout.cshtml:

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - TestPDFApp</title>
    <script src="~/js/site.js"></script>
    <script src="https://kendo.cdn.telerik.com/2019.2.619/js/jquery.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2019.2.619/js/jszip.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2019.2.619/js/kendo.all.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2019.2.619/js/kendo.aspnetmvc.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
    <link rel="stylesheet" href="~/lib/kendo-ui/styles/kendo.common.min.css" />
    <link rel="stylesheet" href="~/lib/kendo-ui/styles/kendo.rtl.min.css" />
    <link rel="stylesheet" href="~/lib/kendo-ui/styles/kendo.bootstrap.min.css" />
    <link href="~/css/site.css" rel="stylesheet" />
</head>

 

From my View:

<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.2/pdf.js"></script>
<script>
    window.pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.2/pdf.worker.js';
</script>
<div id="example">
    @(Html.Kendo().PDFViewer().Name("pdfviewer")
                //.PdfjsProcessing(pdf => pdf.File(Url.Content("~/wwwroot/PDF/Issue Definitions.pdf")))
                .PdfjsProcessing(pdf => pdf.File(Url.Content("https://demos.telerik.com/kendo-ui/content/web/pdfViewer/sample.pdf")))
                .Height(1200)
    )
</div>
<style>
    html body #pdfviewer {
        width: 100% !important;
    }
</style>

3 Answers, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 27 Aug 2019, 01:58 PM

Hello Richard,

Based on the provided information I would assume that the reason for the reported behavior is the path used for accessing the PDF file. Try accessing the desired PDF file without the wwwroot prefix in its path. I’ve prepared a small example project based on the one you sent me. The definition of the PDFViewer in the attached project is as follows:

    @(Html.Kendo().PDFViewer().Name("pdfviewer")
                .PdfjsProcessing(pdf => pdf.File(Url.Content("~/PDF/test.pdf")))
                .Height(1200)
    )

The "test.pdf" file that is being loaded in the PDFViewer is located in the wwwroot/PDF folder

If the above assumption doesn't fix the issue, please modify the attached project in a way the reported case could be reproduced and send the modified project back to me.

Looking forward to your reply.

Regards,
Petar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Richard
Top achievements
Rank 1
answered on 27 Aug 2019, 03:05 PM

Thank you Petar!  Removing the '/wwwroot' was all it took to fix my problem. 

Rich

0
Petar
Telerik team
answered on 27 Aug 2019, 03:49 PM

Hi Richard,

Great! I'm happy the provided solution resolved the case! 

Regards,
Petar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
PDFViewer
Asked by
Richard
Top achievements
Rank 1
Answers by
Petar
Telerik team
Richard
Top achievements
Rank 1
Share this question
or