Angular app with built-in PDF viewer

Are there any reliable PDF viewer components available for viewing PDF files within my Angular application? I've attempted using angular-pdfjs-viewer, but unfortunately, it did not function as expected. Currently, all I have is a link to the PDF file on the server.

Thank you in advance.

Answer №1

To incorporate a pdf viewer in your application, you can utilize an iframe with the PDF's URL stored in a variable within your $scope like so:

$scope.pdfViewerURL = "pdfFileUrl";

After defining the variable, insert the following code snippet:

<iframe src="{{pdfViewerURL | trustResourceUrl}}"></iframe>

Don't forget to implement the provided filter below:

.filter('trustResourceUrl', ['$sce', function($sce) {
    return function(value) {
        return $sce.trustAsResourceUrl(value);
    };
}])

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a chat interface with chat bubbles in React JS can be done by implementing components such as Message

Having some JSON data stored in dummyData, I am seeking guidance on how to position chat bubbles on the left and right based on the direction. My framework of choice is Material UI along with the context API. The attached image serves as a visual reference ...

Ways to retrieve data from various MongoDB collections in state with Express?

MongoDB Relationship Dilemma Trying to implement a many-to-many relationship in MongoDB, I am faced with the challenge of reading documents from multiple collections within the same database. Within my backend script server.js, I am fetching data from col ...

Guidance for Modifying Fixed Position Menus

Looking for help to transform a simple stick nav into a sliding menu that collapses into an icon like those found on website templates. I've been researching online but haven't found the right solution yet. Any suggestions would be appreciated! ...

Clicking on the button will advance to the next tab rather than selecting the tab

I have this code snippet in HTML: $(document).ready(function() { $("div.bhoechie-tab-menu>div.list-group>a").click(function(e) { e.preventDefault(); $(this).siblings('a.active').removeClass("active"); $(th ...

Refresh the content with an embedded iframe

I am attempting to update the body content by removing all existing content and inserting an iframe: function create_custom_iframe(target){ var iframe = document.createElement('iframe'); iframe.setAttribute('id', 'target_u ...

Develop a specialized function to eliminate every instance of a specific element from an array

Below is a function I've crafted to remove a specified custom element from an array: Array.prototype.removeElement=function(x){ var index = this.indexOf(x); if (index !== -1) { this.splice(index, 1); } }; This function works well w ...

Assign the returned auth2 value to an Angular variable

I've been searching for a solution to my issue without much success, even though it seems like it should be an easy fix. Currently, I am using AngularJS and Google auth2 for authentication to fetch the logged in user's information. My goal is to ...

Display a message with `console.log` when a button is clicked in

I would like the console.log to display the coin.id of the element when I click on the row element. import React, { useState, useEffect } from "react"; import { Col, Image, Row } from "react-bootstrap"; import "./Company.scss" ...

Prevent scrolling through a fixed, scrollable div using the mousewheel

I am encountering an issue on my webpage where I have a fixed y scrollable sidenav and a main body. The problem arises when scrolling with the mouse wheel while the pointer is inside the side nav, causing the body to scroll depending on the element's ...

Click on the sort icon in React JS to change its state

I need to update the sort icon in my table header when a user sorts a column. Here is the current implementation of my sorting function: var headerColumns = []; var IconType = 'triangle'; var IconSort = 'top'; var onToggleO ...

Having difficulty understanding the sequence of the JavaScript AJAX demonstration

Understanding the concept of AJAX seems relatively easy, however, I am struggling to grasp the logic. While exploring how AJAX works, I came across the following example on w3schools.com, which is quite similar to examples on other sites as well. <!DOC ...

"Troubleshooting why the jQuery Click Function is malfunctioning specifically in

Can someone help me troubleshoot this animate out script? It works fine on chrome, but not on Firefox and I can't seem to figure out why. Any suggestions? The script is designed to animate certain elements when a specific link is clicked. <scrip ...

Obtain the YouTube video identifier from a YouTube embedded link

Is there a way to extract just the YouTube ID from a given URL? https://www.youtube.com/embed/cqyziA30whE?controls=1&showinfo=0&rel=0&autoplay=0&loop=0 $(".youtube").click(function () { console.log(this.href.replace(new RegExp("em ...

There was a TypeError that was not caught in the promise, stating that the function window.showOpenFilePicker is not valid

Encountering TypeError with File System Web API While experimenting with the File System Web API, I keep receiving a TypeError stating Uncaught (in promise) TypeError: window.showOpenFilePicker is not a function. I am unsure of what is causing this issue. ...

Issues arise with jQuery while working with an array of promises

function bar() { var promiseArray = []; $.each(options, function (index, option) { promiseArray.push( someAjaxFunction(option) ); }); return $.when.apply($, promiseArray); } In my code, there is a function called bar() This funct ...

Is it possible to conceal the search button when there is an invalid entry in any field?

I have a task to hide the search button if any field has a type other than Number. Here is what I implemented in Computed: filterValid () { return ( (this.tkType !== null) && (typeof this.tkType.value === 'number') || (this.archiveTk !== null) && ...

What are the mechanisms involved in the change detection process of Angular 2?

When it comes to change detection in Angular 1, the method used is dirty checking of the $scope hierarchy. It involved creating watchers either implicitly or explicitly in templates, controllers, or components. Angular 2, on the other hand, no longer reli ...

Unable to simultaneously execute TypeScript and nodemon

Currently, I am in the process of developing a RESTful API using Node.js, Express, and TypeScript. To facilitate this, I have already installed all the necessary dependencies, including nodemon. In my TypeScript configuration file, I made a modification to ...

Updating an object within an array of objects with a replacement

Having trouble updating an object in an array of objects. Here is the initial array: myArray = [ {id: 0, description: "some description", status: "initial status", function: someFunction()}, {id: 1, description: "some descripti ...

I am experiencing some unwanted movement of divs when I hide one element and show another. Is there a way to prevent this from happening

My webpage features a dynamic div that transforms into another div upon clicking a button. Although both divs share similar properties, clicking the button causes some elements to shift unexpectedly. Strangely enough, when the height of the replacing div i ...