Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display pdf inside an ionic app

Im developing an app with ionic framework and I need to display a pdf.

I've read a lot on the internet and found this directive to use

https://github.com/winkerVSbecks/angular-pdf-viewer

The problem is that I'm having problems to integrate the directive with my ionic app.

I've done the indicated steps:

  1. bower install angular-pdf-viewer

  2. Include the path to the lib, AngularJS and PDFJS: (here I changed the paths)

      <script src="lib/pdfjs-dist/build/pdf.js"></script>
      <script src="lib/angular/angular.js"></script>
      <script src="lib/angular-pdf-viewer/dist/angular-pdf-viewer.min.js"></script>
    
  3. Include the lib as a dependency in your angular app:

      var app = angular.module('App', ['pdf']);
    

Then I put this in the template

<pdf-viewer    delegate-handle="my-pdf-container"    url="www.publishers.org.uk/_resources/assets/attachment/full/0/2091.pdf" scale="1"    show-toolbar="true"    ></pdf-viewer>

But I get this error

[$parse:syntax] Syntax Error: Token 'pdf' is an unexpected token at column 64 of the expression

What am I doing wrong?

Thanks in advance!

like image 732
joacoleza Avatar asked Feb 25 '26 09:02

joacoleza


1 Answers

I believe the url value is meant to point to your scope. So given that you have $scope.pdf = "the url you want", you would do url="pdf" in the tag.

like image 198
Raymond Camden Avatar answered Feb 27 '26 01:02

Raymond Camden



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!