An introduction to integrating Paged.js with Vue.js3

index.html

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <link rel="icon" type="image/svg+xml" href="/vite.svg" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title></title>
      </head>
      <body>
        <div id="app"></div>
        <script type="module" src="/src/main.ts"></script>
        <script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
      </body>
    </html>

App.vue

<script setup lang="ts">
   import { Previewer } from 'pagedjs';
</script>
<template>
  <div class="pagedjs_pages">
     Lorem ipsum dolor, sit amet consec.......
     hellllloooooo!!!!!
  </div>
  <!-- hellllloooooo!!! disappeared  -->

css in App.vue

@page {
  size: A4 landscape;
 // tried size: 297mm 210mm;
}

result:

what I expected is an A4 landscape page, but it seems like, the "page" is landscape, which is correct, but the content is like vertical A4, and not showing my full content, cut the rest content at bottom, which part did I miss? https://i.sstatic.net/Id59q.jpg https://i.sstatic.net/1SuZh.png

Answer №1

If you're looking for more information, I came across another resource that might be useful.

// App.vue

<script lang="ts">
  import { onMounted } from 'vue';
  
  onMounted(()=>{
    let paged = new Previewer();
  
    let flow = paged.preview().then((flow) => {
      console.log("Rendered", flow.total, "pages.");
    })
  });
</script>

<template ref="template">
  <div>hello</div>
</template>

<style lang="scss">
  @import 'pagedjs.scss';
</style>
// pagedjs.scss

@page {
  size: A4 landscape !important;

  @top-left {
    content: "should be shown on the top-left";
    font-size: 15px;
    color: #979797;
    text-align: left;
  }
}
// styling....

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

Avoiding the selection of HTML canvas objects

I am currently working on customizing my homepage with an interactive animation. However, I am facing some challenges in integrating it seamlessly into the page. You can view the progress at . My main issue is preventing the canvas object from being select ...

What is the method for accessing the AG-Grid Grid API beyond the Vue component?

In my application, I have a component called Home and another one called AgGrid. The AgGrid component is displayed within the Home component, containing the actual AG-Grid. Here's how the Home component is structured: <template> <AgGrid :ro ...

I'm struggling with developing react applications due to problems with canvas elements

I am currently using an M1 MacBook Pro, with Node version 15.4.1 and npm version 7.0.15. When I ran the command npx create-react-app my-app, it gave me this output: https://i.sstatic.net/OKKnA.jpg I have attempted various solutions but keep encountering ...

V-Treeview enables both activation and opening on click simultaneously

Is there a way to make the item name clickable with two functionalities: Expand it Select it I noticed that this is not possible by default as discussed here: https://github.com/vuetifyjs/vuetify/issues/5947 Does anyone have a workaround for this limitat ...

Start a development server within the continuous integration pipeline

I've set up a CI pipeline using Github Action/Workflows to run Cypress Automated tests, but I'm facing some issues with running my dev server. Below is my pipeline: name: Nuxt CI Pipeline on: push: branches: [ CI-pipeline ] # pull_reques ...

What is the best way to swap the values of options between two input select elements?

I am trying to create a feature where I have two select dropdowns with the same options, and when a trigger is clicked, the option values are inverted between the two selects. Here is an example: <select id="source_currency"> <option value="BRL" ...

Establishing the httppostedfilebase variable when validation is unsuccessful in an ASP.Net MVC view

I'm currently facing an issue with handling validation errors in my application. I have implemented uploading and downloading images successfully, but when there are validation errors and the controller redirects back to the page, the HttpPostedFileBa ...

JavaScript's "for of" loop is not supported in IE 11, causing it to fail

Here is a piece of code I'm using to select and remove a d3.js node: if (d.children) { for (var child of d.children) { if (child == node) { d.children = _.without(d.children, child); update(root); ...

Displaying the combined total for each date

My goal is to calculate the total for each department without duplicates ( which is currently working ) and display all results based on the selected date. I intend to select a date using md-datepicker and then only display the total task time where the d ...

What is the best way to dismiss the ant-design-vue select option when the mouse moves away?

<a-select showSearch placeholder="Select a person" optionFilterProp="children" style="width: 200px" :open="isOpen" @mouseenter="handleOpenSelect" @mouseleave="handleCloseSelect" > <a-select-option value="jack"> ...

reconfigure keyboard shortcuts in web browser

In the popular web browser Google Chrome, users can quickly jump to the next tab by pressing CTRL + TAB. Is there a way to change or disable this shortcut? The provided code snippet does not seem to work as intended. $(document).keydown(function(e){ ...

Threejs: Illuminating the spotlight with visibility

For my current project, I am attempting to create a visible spotlight similar to the one used by Batman. I want that cone of light that pierces through the night sky. Unfortunately, I do not have any experience with graphics or 3D design, so I am strugglin ...

How can I create a dropdown menu that is dependent on another dropdown menu using Ajax in my Laravel application?

I have two dropdown fields that are dependent on each other - Class & Section. I am trying to Select * from sections where class_id=selected Class Id. Although I attempted to achieve this using java script, it doesn't seem to work for me. Here are ...

Execute the SQL "function" (or stored procedure?) whenever a database column is queried

Running on MySQL 5.6, I encounter a situation where various "name" columns in the database lack formatting and sanitization upon importation through CSV data dumps by customers each year. This results in names such as Phil Eaton, PHIL EATON, Phil EATON bei ...

The challenge of populating information within a Datalist

In my code snippet, I have a JavaScript function that is used to populate a Datalist: function PopulateDropDown(facility) { $.ajax({ url: '/Rentals/Base/GetContactsForFacility?selectedFacility=' + facility, data: { facility: ...

Using the JSON parameter in C# with MVC 3

I'm facing an issue with sending JSON data from a JavaScript function to a C# method using Ajax. When I receive the data in C#, it's not being recognized as JSON. How can I resolve this issue? If I try to output the received data using Response.W ...

IIFE and the Twitter share button are a powerful duo

As I experiment with this quick creation of mine, two questions have arisen. The first one is, how can I encapsulate all the JS code within an IIFE without breaking it? The second question is about finishing the twitter button to enable sharing the act ...

Issues with Await and Async functionality in Angular and Ionic 4 causing unexpected behavior

Struggling to show error messages during the sign-up process? Constantly encountering the same issue in your code? The error TS1308 is throwing you off: 'await' expression is only allowed within an async function. Take a look at this problemati ...

Angular - Manipulating the selected option in a select box from the controller

My issue involves a select box that is defined in the following manner: <select ng-model="selectedSupplier" ng-options="supplier.name for supplier in suppliers"> </select> Within my controller, there is a button that doesn't have any r ...