Skip to content
On this page

Basic Usage

Print
Test NameTest
Canvass Your browser does not support the HTML5 canvas tag.
Dynamic Content From Propold boring text
Fonts
Some Cool Font Text
Image: Local ImportA test
Image: URLGoogle logo
Input
Input: Checkbox
Input: Date
Input: Radio Blue Red
Select
TextArea
SVG
Video
Video: With Poster
Click to view code
html
<template>
  <ion-button @click="handlePrint">Print</ion-button>
  <div ref="componentRef">
    <component-to-print :text="state.text" />
  </div>
</template>

<style scoped></style>
typescript
import { useVueToPrint } from "vue-to-print";
import { reactive, ref } from "vue";
import ComponentToPrint from "./ComponentToPrint.vue";

const componentRef = ref();
const state = reactive({ text: "old boring text" });

const { handlePrint } = useVueToPrint({
  content: componentRef,
  documentTitle: "AwesomeFileName",
  removeAfterPrint: true
});
vue
<script setup lang="ts">
// #region script
import { useVueToPrint } from "vue-to-print";
import { reactive, ref } from "vue";
import ComponentToPrint from "./ComponentToPrint.vue";

const componentRef = ref();
const state = reactive({ text: "old boring text" });

const { handlePrint } = useVueToPrint({
  content: componentRef,
  documentTitle: "AwesomeFileName",
  removeAfterPrint: true
});
// #endregion script
</script>

// #region template
<template>
  <ion-button @click="handlePrint">Print</ion-button>
  <div ref="componentRef">
    <component-to-print :text="state.text" />
  </div>
</template>

<style scoped></style>
// #endregion template
Print
Test NameTest
Canvass Your browser does not support the HTML5 canvas tag.
Dynamic Content From Propold boring text
Fonts
Some Cool Font Text
Image: Local ImportA test
Image: URLGoogle logo
Input
Input: Checkbox
Input: Date
Input: Radio Blue Red
Select
TextArea
SVG
Video
Video: With Poster
Click to view code
html
<template>
  <vue-to-print
    :content="componentRef"
    document-title="AwesomeFileName"
    remove-after-print
  >
    <template #trigger>
      <ion-button>Print</ion-button>
    </template>
  </vue-to-print>
  <div ref="componentRef">
    <component-to-print :text="state.text" />
  </div>
</template>

<style scoped></style>
typescript
import { VueToPrint } from "vue-to-print";
import { reactive, ref } from "vue";
import ComponentToPrint from "./ComponentToPrint.vue";

const componentRef = ref();
const state = reactive({ text: "old boring text" });
vue
<script setup lang="ts">
// #region script
import { VueToPrint } from "vue-to-print";
import { reactive, ref } from "vue";
import ComponentToPrint from "./ComponentToPrint.vue";

const componentRef = ref();
const state = reactive({ text: "old boring text" });

// #endregion script
</script>

// #region template
<template>
  <vue-to-print
    :content="componentRef"
    document-title="AwesomeFileName"
    remove-after-print
  >
    <template #trigger>
      <ion-button>Print</ion-button>
    </template>
  </vue-to-print>
  <div ref="componentRef">
    <component-to-print :text="state.text" />
  </div>
</template>

<style scoped></style>
// #endregion template

This example will print Web Components components from Ionic.

Print
Test NameTest
Canvass Your browser does not support the HTML5 canvas tag.
Dynamic Content From Propold boring text
Fonts
Some Cool Font Text
Image: Local Import(with ion-img)
Image: URL(with ion-img)
Input(with ion-input)
Input: Checkbox(with ion-checkbox) I agree to the terms and conditions
Input: Date(with ion-datetime-button)
Input: Radio(with ion-radio) BlueRed
Select(with ion-select)AppleBananaOrange
TextArea(with ion-textarea)
SVG
Video
Video: With Poster
Click to view code
html
<template>
  <ion-button @click="handlePrint">Print</ion-button>
  <div ref="componentRef">
    <shadow-dom-to-print :text="state.text" />
  </div>
</template>

<style scoped></style>
typescript
import { useVueToPrint } from "vue-to-print";
import { reactive, ref } from "vue";
import ShadowDomToPrint from "./ShadowDomToPrint.vue";

const componentRef = ref();
const state = reactive({ text: "old boring text" });

const { handlePrint } = useVueToPrint({
  content: componentRef,
  documentTitle: "AwesomeFileName",
  removeAfterPrint: true
});
vue
<script setup lang="ts">
// #region script
import { useVueToPrint } from "vue-to-print";
import { reactive, ref } from "vue";
import ShadowDomToPrint from "./ShadowDomToPrint.vue";

const componentRef = ref();
const state = reactive({ text: "old boring text" });

const { handlePrint } = useVueToPrint({
  content: componentRef,
  documentTitle: "AwesomeFileName",
  removeAfterPrint: true
});
// #endregion script
</script>

// #region template
<template>
  <ion-button @click="handlePrint">Print</ion-button>
  <div ref="componentRef">
    <shadow-dom-to-print :text="state.text" />
  </div>
</template>

<style scoped></style>
// #endregion template