### Install Vue Print Next via Package Manager Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Commands to install the library using common Node.js package managers. ```bash npm install vue-print-next --save # or yarn add vue-print-next # or pnpm add vue-print-next ``` -------------------------------- ### Install Vue Print Next via Package Manager Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md Commands to add the vue-print-next dependency to your project using common JavaScript package managers. ```bash npm install vue-print-next --save yarn add vue-print-next pnpm add vue-print-next ``` -------------------------------- ### Print Entire Page with Vue-Print-Next Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md This example demonstrates how to print the entire current web page using the v-print directive without any parameters. ```html ``` -------------------------------- ### Print Partial Content using Ref with Vue-Print-Next Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md This example demonstrates how to print a specific DOM element by obtaining a reference to it using Vue's `ref` and passing it to the VuePrintNext constructor. It requires importing `ref` and `VuePrintNext`. ```vue ``` -------------------------------- ### Print with Object Parameters using Vue-Print-Next Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md This example shows how to configure printing options by passing an object to the v-print directive. It includes parameters like `el`, `preview`, `extraCss`, `openCallback`, and `closeCallback`. ```vue ``` -------------------------------- ### Utilize Complete Callback Lifecycle for Print Events (Vue) Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt This example demonstrates how to use all available lifecycle callbacks provided by VuePrintNext. These callbacks allow you to hook into various stages of the print process, such as before and after the preview iframe loads, before the print dialog opens, when it opens, and when it closes. ```vue ``` -------------------------------- ### VuePrintNext Class - Programmatic API Example Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Demonstrates using the VuePrintNext class directly to control printing logic. It allows for dynamic configurations and callback functions for print events. This method requires a CSS selector for the element to be printed. ```vue ``` -------------------------------- ### Print Content from a URL with Vue-Print-Next Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md This example demonstrates how to print content from a specified URL by passing the URL string within an object to the v-print directive. Note that the URL must comply with the same-origin policy. ```vue ``` -------------------------------- ### Print Partial Content using CSS Selector with Vue-Print-Next Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md This example shows how to print only a specific part of the page by providing a CSS selector (e.g., an element's ID) to the v-print directive. ```html

This is the content to be printed

``` -------------------------------- ### Set Paper Size and Orientation for Printing in Vue Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md Explains how to configure the paper size and orientation for printing using the `paperSize` and `orientation` parameters. This example sets the paper to 'A4' and orientation to 'landscape', also enabling the preview mode. ```html ``` -------------------------------- ### Customize Print Preview Toolbar in Vue Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md Shows how to customize the buttons displayed in the print preview toolbar. The `previewTools` object allows enabling or disabling specific tools like zoom, theme toggle, and fullscreen. In this example, only zoom and theme are enabled. ```html ``` -------------------------------- ### Manual Printing with VuePrintNext Class Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md Programmatically trigger print operations by instantiating the VuePrintNext class, useful for complex logic or event-driven requirements. ```javascript import {VuePrintNext} from 'vue-print-next'; function handlePrint() { new VuePrintNext({el: '#printMe'}); } ``` -------------------------------- ### Configure Advanced Print Options Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Passing a configuration object to v-print to enable print previews, define lifecycle callbacks, and exclude specific elements from the print output. ```vue ``` -------------------------------- ### Register Vue Print Next Globally Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md How to register the print plugin globally within a Vue 3 application using the createApp instance. ```typescript import {createApp} from 'vue'; import App from './App.vue'; import {printPlugin} from 'vue-print-next'; const app = createApp(App); app.use(printPlugin); app.mount('#app'); ``` -------------------------------- ### Implement Full Page Printing with v-print Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Using the v-print directive without arguments to trigger a print dialog for the entire page content. ```vue ``` -------------------------------- ### Dark Mode and Window Mode for Print Preview in Vue Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md Illustrates how to enable dark mode and specify the window mode for the print preview interface. `darkMode: true` activates dark mode, and `windowMode: true` uses a non-fullscreen popup window for the preview. `defaultScale` sets the initial zoom level. ```html ``` -------------------------------- ### Configure Paper Size and Orientation for Printing in Vue Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Demonstrates how to configure paper size and orientation for printing using VuePrintNext. It covers standard sizes like A4 in portrait or landscape, as well as custom dimensions with specified units. ```vue ``` -------------------------------- ### Asynchronously Load URL Content for Printing in Vue Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md Shows how to print content from a URL that needs to be loaded asynchronously. The `asyncUrl` function is provided, which resolves with the URL after a delay. This is useful for dynamic content or content fetched from an API. ```html ``` -------------------------------- ### Configure Preview Appearance with Dark Mode and Window Mode Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Control the appearance of the print preview by enabling dark mode or window (non-fullscreen) mode. These options can be used independently or combined for custom preview settings. The 'el' option specifies the content to be printed, and 'preview' must be true to activate preview mode. ```vue ``` -------------------------------- ### Load Print Content Asynchronously from a URL Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Dynamically load content for printing from a URL that is resolved asynchronously. The 'asyncUrl' callback function receives a 'resolve' function which should be called with the URL string once it's available. This is useful for fetching content based on user actions or data retrieval. ```vue ``` -------------------------------- ### Print Using DOM Element Reference with Vue Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Shows how to print content by passing a direct DOM element reference obtained via Vue's `ref` attribute. This provides a more direct way to target elements for printing compared to CSS selectors. ```vue ``` -------------------------------- ### Use v-print Directive in Vue Components Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md Demonstrates applying the v-print directive to trigger full-page or partial-element printing in both Vue 3 and Vue 2 environments. ```html ``` ```javascript ``` -------------------------------- ### Register Print Plugin Globally Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Instructions for registering the print plugin in both Vue 3 and Vue 2 environments to enable the v-print directive. ```typescript // main.ts import { createApp } from 'vue'; import App from './App.vue'; import { printPlugin } from 'vue-print-next'; const app = createApp(App); app.use(printPlugin); app.mount('#app'); ``` ```javascript // main.js import Vue from 'vue'; import App from './App.vue'; import { printPlugin } from 'vue-print-next'; Vue.use(printPlugin); new Vue({ render: h => h(App), }).$mount('#app'); ``` -------------------------------- ### Print Content from an External URL Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Print content directly from an external URL using the 'url' option. This functionality is subject to the same-origin policy, meaning the URL must be on the same domain as your application or have appropriate CORS headers configured. ```vue ``` -------------------------------- ### Print Multiple Sections Simultaneously with Vue Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Illustrates printing multiple DOM elements at once by providing a comma-separated string of CSS selectors to the `el` option. This is useful for combining content from different parts of the page into a single print job. ```vue ``` -------------------------------- ### TypeScript Interface for PrintAreaOption in Vue Print Next Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Defines the complete TypeScript interface for all available configuration options for printing in Vue Print Next. This includes settings for paper size, orientation, custom dimensions, preview options, and various callback functions. ```typescript import type { PrintAreaOption, PaperSize, Orientation, CustomSize, PreviewToolsOption } from 'vue-print-next'; // Paper size options type PaperSize = 'A0' | 'A1' | 'A2' | 'A3' | 'A4' | 'A5' | 'A6' | 'A7' | 'A8' | 'Letter' | 'Legal' | 'Tabloid' | 'custom'; // Orientation options type Orientation = 'portrait' | 'landscape'; // Custom size interface interface CustomSize { width: string | number; height: string | number; unit?: 'mm' | 'cm' | 'in' | 'px'; } // Preview toolbar options interface PreviewToolsOption { zoom?: boolean; theme?: boolean; fullscreen?: boolean; } // Complete configuration interface interface PrintAreaOption { el?: string | HTMLElement; // CSS selector or DOM element standard?: 'strict' | 'loose' | 'html5'; // Document type (default: 'html5') noPrintSelector?: string[] | string; // Elements to exclude url?: string; // URL to print asyncUrl?: (resolve: (url: string) => void, vue: any) => void; preview?: boolean; // Enable preview (default: false) extraHead?: string; // Extra content extraCss?: string; // Extra CSS file URLs popTitle?: string; // Print window title previewTitle?: string; // Preview title (default: '打印预览') previewPrintBtnLabel?: string; // Print button label (default: '打印') zIndex?: number; // Preview z-index (default: 20002) paperSize?: PaperSize; // Paper size orientation?: Orientation; // Paper orientation customSize?: CustomSize; // Custom paper dimensions previewSize?: PaperSize | CustomSize; // Preview-specific size darkMode?: boolean; // Dark mode (default: false) windowMode?: boolean; // Window mode (default: false) defaultScale?: number; // Default zoom (default: 1) previewTools?: PreviewToolsOption | false; // Toolbar config previewBeforeOpenCallback?: (vue?: any) => void; previewOpenCallback?: (vue?: any) => void; beforeOpenCallback?: (vue?: any) => void; openCallback?: (vue?: any) => void; closeCallback?: (vue?: any) => void; } ``` -------------------------------- ### Add Extra CSS and Head Content for Printing (Vue) Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt This snippet shows how to include external CSS files and custom HTML content within the head section for print styling. It utilizes the `extraCss` and `extraHead` options of VuePrintNext to customize the print output. ```vue ``` -------------------------------- ### Vue 2 Component Usage with v-print Directive Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt This snippet illustrates how to use the `v-print` directive within Vue 2 components for printing. It shows how to print the entire page, a specific section by its ID, or with custom print options defined in a data property. ```vue ``` -------------------------------- ### Implement Partial Printing with CSS Selectors Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Passing a CSS selector string to the v-print directive to restrict the printed output to a specific DOM element. ```vue ``` -------------------------------- ### Custom Paper Size for Printing in Vue Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md Details how to set a custom paper size for printing when standard sizes are not sufficient. The `paperSize` is set to 'custom', and `customSize` object defines the width, height, and unit (e.g., 'mm', 'cm', 'in', 'px'). Preview mode is also enabled. ```html ``` -------------------------------- ### Customize Print Preview Toolbar Buttons Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Customize the visibility of toolbar buttons in the print preview interface using the 'previewTools' option. You can enable or disable specific tools like zoom, theme toggle, and fullscreen. Setting 'previewTools' to false will hide all toolbar buttons. ```vue ``` -------------------------------- ### Ignore Elements for Printing in Vue Source: https://github.com/alessandro-pang/vue-print-next/blob/master/README.en.md Demonstrates how to exclude specific HTML elements from printing by using the `noPrintSelector` option. This is useful for hiding elements like buttons or navigation bars that are not intended for the printed output. The `noPrintSelector` can accept a CSS selector string or an array of selectors. ```html ``` -------------------------------- ### Exclude Elements from Printing using CSS Selectors Source: https://context7.com/alessandro-pang/vue-print-next/llms.txt Prevent specific elements from being included in the printed output by providing an array of CSS selectors to the 'noPrintSelector' option. This is useful for hiding elements like internal notes, draft watermarks, or other non-essential content. ```vue ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.