the ever-changing dimensions of a PDF document

I'm attempting to display a PDF using an iframe, but I want the height of the viewer to match the document's height, meaning that all 3 pages should be visible without scrolling. How can I achieve this?

Here's a simple example I created on CodePen.

Just to note, I am working with Vue and looking to integrate this feature into a Vue project.

Answer №1

One potential approach, although not very "dynamic," is to adjust the height to accommodate the three given pages. In this case, I set it to 1970px, roughly based on A4 dimensions at 500px wide = 706px high, totaling about 2118px in height. However, in practice, 1970px seems sufficient for the three assigned pages (you can fine-tune this on a case-by-case basis).

<h1>Hello world</h1>
<div class="box">
  <iframe id="iframe1" src="https://ana.mareca.es/wp-content/plugins/algori-pdf-viewer/dist/web/viewer.html?file=https%3A%2F%2Fana.mareca.es%2Fwp-content%2Fuploads%2F2020%2F05%2FPdf-de-prueba-con-varias-paginas.pdf#view=fit"
      width="100%" height="1970px"></iframe>
</div>

<h3>I acknowledge that I have reviewed all three pages</h3>

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

Ensure you are focusing on elements exclusively contained within the parent table and not any child tables nested within its cells

Looking for some help with a unique situation here. I'm struggling to find the right selector for this task. For reference, you can check out the jsfiddle at this link: http://jsfiddle.net/NZf6r/1/ The scenario is that I have a parent table containin ...

Learn how to efficiently process a data queue with AngularJS using Promises

Within my AngularJS application, I have a Service and multiple controllers running simultaneously. The app receives data updates from the server in JSON format through the Angular Service. To manage the vast amount of data, I need to queue it within the se ...

Is there a specific regex pattern available to identify CSS and JavaScript links within an HTML file?

Currently, I am using a straightforward gulp task to compress my CSS and JS files. The task appends a .min extension to the names of the compacted files. Now, I want to make changes in the HTML to direct to these new compressed files, like so: Replace thi ...

After loading the ajax content, remember to include the JavaScript files

Here's the situation: I am importing some php files, one of which includes a slider that requires .js files. However, when I make an ajax call, the file is imported but the js files are not. Is this normal behavior? I attempted the following: var s ...

The Jest mock for dates is completely ineffective and always ends up returning the constructor

beforeAll(() => { ... const mockedData = '2020-11-26T00:00:00.000Z' jest.spyOn(global, 'Date').mockImplementation(() => mockedData) Date.now = () => 1606348800 }) describe('getIventory', () => { ...

differences between using form's get method and sending an angular $http.get request

When trying to make a GET request to a specific URL from my Angular frontend to an ExpressJS backend, I encountered some interesting behavior. In the frontend code snippet below: <li> <a ng-click="givequiz()">GiveQuiz</a> </l ...

A variety of negative () DOM Selectors

I've been trying to select a specific node using two not clauses, but so far I haven't had any luck. What I'm attempting to achieve is selecting an element whose div contains the string 0008, but it's not 10008 and also does not contain ...

Utilizing Django to determine the appropriate view based on whether it is a GET request or an AJAX POST method

In my Django project, I have a view that serves different purposes depending on whether the request method is GET or POST. When it's a GET request, the view simply renders the page for the user. On the other hand, when it's a POST request, I use ...

Host an Angular app with views using Express.js - reloading is disabled

I'm currently working with an expressjs configuration that looks like this: app.use(express.static(path.join(__dirname,"../../site"))); app.use("/src", express.static(path.join(__dirname,"../cms/src"))); app.get('/', function(req, res){ ...

Managing browser back button functionality

I've been struggling to find a solution for handling the browser back button event. I would like to prompt the user with a "confirm box" if they click on the browser back button. If they choose 'ok', I need to allow the back button action, ...

Deleting the HTML element

Can someone assist me with my script issue? I am facing a problem: when I open my file on fullscreen (over 768px), and move my pointer around the logo div, nothing happens. However, if I resize my browser to below 768px, then back again above 768px, the ...

Error encountered when attempting to display a particular user with a specific _id in MongoDB, Node, and React: Failed to convert value "undefined" to ObjectId in the "user" model

I am experiencing an issue on my page where multiple users are displayed. Whenever I click on a user, it should redirect me to their individual page, but instead, I encounter the following error: Cast to ObjectId failed for value "undefined" at path "_id" ...

I am interested in setting up a flickr gallery where clicking on an image will display a pop-up showing the image along with its relevant tags, title, and photo ID

Page´s photo Hello there, I am currently working on creating a Flickr API using JavaScript and HTML. My goal is to search for photos and display them in an HTML page, but I'm struggling with implementing a pop-up feature that includes the photo' ...

Steps for including a new script in package.json

Is there a way to add the script dev to my package.json from the terminal? I attempted to manually add it using a text editor, but when I try to run: npm run dev I encounter some errors. Is there a way to include this script through the command line? E ...

When printing a PDF, a div that is set to 100vh only takes up

After setting the div to be 100vh, I realized that when printing it only takes up half of the page. Adding media print did not make a difference, and even trying to set the height to 100% instead didn't work for PDFs. html, body { height: 100%; ...

Issue with AngularJS: Controller unable to access property of ng-model object

I am looking to create a reusable controller that can be used by multiple views. This controller will essentially serve as a template. The issue I'm facing is with setting up simple validation. The problem lies in the fact that the properties set in ...

Using PHP and JavaScript to keep track of file modifications

Being a beginner in PHP and Javascript, I recently created a basic Clock application using Javascript which worked out successfully. Now, I have a file that will automatically change its content. For example, it might look something like this: "12h15: eat ...

There seems to be a lack of definition for Angular within the angular

Currently, I am in the process of developing an Angular application. The modules I have created contain services and controllers that are all working as intended. Recently, I added angular-animate to my list of scripts, which are loaded from a cshtml file ...

The rectangular component fails to refresh

I am currently utilizing the l-rectangle feature within a Vue leaflet project. Below is how I am constructing the rectangle: <l-rectangle :bounds="rectangle"></l-rectangle> By including the code snippet above in my .js-file, I can successfull ...

"The webpack-dev-server seems to be failing to forward requests to an external domain using the proxy

I'm currently facing an issue with setting up the webpack-dev-server proxy configuration to route api requests to an external domain. Despite my efforts, I am unable to get it to function properly. Below is my configuration: var path = require(&apos ...