印刷プラグイン (Print Plugin)

@dayflow-pro/plugin-print は、DayFlow に組み込みの印刷ダイアログとマルチフォーマットエクスポート機能を追加します。インタラクティブなページプレビュー、用紙サイズと向きの制御、トラックパッドのピンチズーム、スプレッドシートのリアルタイムデータプレビュー、およびヘッドレスエクスポートAPIを提供します。

フォーマット出力
printブラウザの印刷ダイアログ。選択した用紙に合わせてサイズ設定され、印刷または PDF 保存が可能
png高解像度画像(ページごと)。複数ページは ZIP アーカイブとしてダウンロード
xlsxExcel ワークブック:Events シート(イベント一覧)と Summary シート(カレンダー集計)
icsGoogle カレンダー、Apple カレンダー、Outlook 向けの標準 iCalendar ファイル

ライブデモを試す。

インストール

npm install @dayflow-pro/plugin-print
pnpm add @dayflow-pro/plugin-print
yarn add @dayflow-pro/plugin-print
bun add @dayflow-pro/plugin-print

ライセンス設定の詳細については、Pro のインストールを参照してください。

コンポーネントのスタイルをインポートしてください:

import '@dayflow-pro/plugin-print/dist/styles.components.css';

基本的な使い方

import { DayFlowCalendar, useCalendarApp } from '@dayflow/react';
import { createPrintPlugin } from '@dayflow-pro/plugin-print';
import '@dayflow-pro/plugin-print/dist/styles.components.css';

function App() {
  const printPlugin = createPrintPlugin({
    defaultOptions: {
      miniCalendar: true,
      calendarKeys: true,
      textSize: 'medium',
    },
  });

  const calendar = useCalendarApp({
    views: [
      /* ビュー設定 */
    ],
    plugins: [printPlugin],
  });

  return (
    <>
      <button onClick={() => calendar.app.openPrintDialog()}>印刷</button>
      <button onClick={() => calendar.app.openPrintDialog({ format: 'xlsx' })}>
        Excel エクスポート
      </button>
      <DayFlowCalendar calendar={calendar} />
    </>
  );
}
<template>
  <div>
    <button @click="calendar.app.openPrintDialog()">印刷</button>
    <button @click="calendar.app.openPrintDialog({ format: 'xlsx' })">
      Excel エクスポート
    </button>
    <DayFlowCalendar :calendar="calendar" />
  </div>
</template>

<script setup>
import { DayFlowCalendar, useCalendarApp } from '@dayflow/vue';
import { createPrintPlugin } from '@dayflow-pro/plugin-print';
import '@dayflow-pro/plugin-print/dist/styles.components.css';

const printPlugin = createPrintPlugin({
  defaultOptions: {
    miniCalendar: true,
    calendarKeys: true,
    textSize: 'medium',
  },
});

const calendar = useCalendarApp({
  views: [
    /* ビュー設定 */
  ],
  plugins: [printPlugin],
});
</script>
import { Component } from '@angular/core';
import { DayFlowCalendarModule } from '@dayflow/angular';
import { createPrintPlugin } from '@dayflow-pro/plugin-print';
import '@dayflow-pro/plugin-print/dist/styles.components.css';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [DayFlowCalendarModule],
  template: `
    <button (click)="calendar.app.openPrintDialog()">印刷</button>
    <button (click)="calendar.app.openPrintDialog({ format: 'xlsx' })">Excel エクスポート</button>
    <dayflow-calendar [calendar]="calendar"></dayflow-calendar>
  `
})
export class AppComponent {
  printPlugin = createPrintPlugin({
    defaultOptions: {
      miniCalendar: true,
      calendarKeys: true,
      textSize: 'medium',
    },
  });

  calendar = {
    views: [
      /* ビュー設定 */
    ],
    plugins: [this.printPlugin]
  };
}
<script>
  import { DayFlowCalendar, useCalendarApp } from '@dayflow/svelte';
  import { createPrintPlugin } from '@dayflow-pro/plugin-print';
  import '@dayflow-pro/plugin-print/dist/styles.components.css';

  const printPlugin = createPrintPlugin({
    defaultOptions: {
      miniCalendar: true,
      calendarKeys: true,
      textSize: 'medium',
    },
  });

  const calendar = useCalendarApp({
    views: [
      /* ビュー設定 */
    ],
    plugins: [printPlugin],
  });
</script>

<button onclick={() => calendar.app.openPrintDialog()}>印刷</button>
<button onclick={() => calendar.app.openPrintDialog({ format: 'xlsx' })}>
  Excel エクスポート
</button>
<DayFlowCalendar {calendar} />

プラグインはカレンダーインスタンスに直接ヘルパーメソッドを登録します:

// デフォルトの印刷ダイアログを開く
await calendar.app.openPrintDialog();

// フォーマットやビューを指定して開く
await calendar.app.openPrintDialog({ format: 'xlsx', view: 'month' });

// ネイティブ印刷をトリガー
await calendar.app.print();

// UI ダイアログを開かずにコードからエクスポート
const result = await calendar.app.exportCalendar({
  format: 'png',
  view: 'week',
});

機能一覧

  • 4つのエクスポート形式:Print/PDF、PNG(単一または複数ページの ZIP)、Excel (.xlsx)、および iCalendar (.ics)。
  • 9種類の用紙サイズ:A3、A4、A5、B3、B4、B5、Letter、Legal、Tabloid。
  • インタラクティブプレビュー:用紙サイズ調整プレビュー、トラックパッドピンチズーム、ドラッグパン移動。
  • リアルタイムデータプレビュー:xlsx や ics に切り替えると、ダイアログ内にテーブル形式のデータプレビューを表示。
  • ヘッドレスエクスポート:calendar.app.exportCalendar() や printPlugin.api.export() を直接呼び出してファイルや Blob を取得。
  • フィルタリング:カレンダーごとの絞り込み、終日イベント/時間指定イベントの表示切り替え。
  • ショートカット:Cmd + P または Ctrl + P で印刷ダイアログを起動。

サポートされている印刷ビュー

ビュー説明
day選択した1日または複数日を印刷。
week週間カレンダーレイアウトを印刷。
month月間グリッドレイアウトを印刷。
year-fixed-week固定週行を使用した年間概要。デフォルトは横向き(landscape)。
year-canvas縦向き(portrait)に最適化された高密度な年間概要。

コードからのエクスポート (Headless Export)

ダイアログを開かずに直接エクスポートを実行できます:

const result = await calendar.app.exportCalendar({
  format: 'xlsx',
  view: 'month',
  startDate: new Date(2026, 8, 1),
  endDate: new Date(2026, 11, 1),
  calendarIds: ['work', 'personal'],
  download: true, // false に設定するとブラウザダウンロードを行わず result.blob を返します
  pixelRatio: 3, // PNG 出力解像度倍率(1 = 96 DPI)
  onProgress: ({ completed, total }) => {
    console.log(`${total} ページ中 ${completed} ページをレンダリング`);
  },
});

console.log(result.filename); // 'calendar-2026-09_2026-12.xlsx'
console.log(result.eventCount); // エクスポートされたイベント数
console.log(result.pageCount); // レンダリングされたページ数(xlsx, ics は 0)
console.log(result.blob); // download: false 時の Blob オブジェクト

CalendarExportRequest オプション

オプション型デフォルト値説明
format'print' | 'png' | 'xlsx' | 'ics'必須エクスポート形式。
viewPrintView現在のビューレンダリングレイアウト(day, week, month, year-fixed-week, year-canvas)。
paperPaperSize現在の用紙設定用紙サイズ(A3, A4, A5, B3, B4, B5, Letter, Legal, Tabloid)。
orientation'portrait' | 'landscape'ビューの初期設定ページの向き。
startDateDate現在の日付エクスポート範囲の開始日。
endDateDate自動計算エクスポート範囲の終了日。
calendarIdsstring[]すべてのカレンダー対象のカレンダー ID 配列。
optionsPartial<CalendarPrintOptions>プラグインの初期値タイポグラフィ、凡例、イベントフィルタリングオプション。
filenamestring範囲から自動生成拡張子なしのカスタムファイル名。
downloadbooleantruefalse の場合、ブラウザ保存を行わず result.blob を返します。
pixelRationumber3PNG 解像度倍率(1 = 96 DPI)。
onProgress(progress: { completed: number; total: number }) => void—PNG ページごとの進行状況コールバック。
signalAbortSignal—処理を途中でキャンセルするためのシグナル。

プラグイン設定 (PrintPluginConfig)

const printPlugin = createPrintPlugin({
  formats: ['print', 'png', 'xlsx', 'ics'],
  filename: ({ format, view, rangeStart, rangeEnd }) => `schedule-${view}`,
  pixelRatio: 3,
  defaultOptions: {
    miniCalendar: true,
    calendarKeys: true,
    textSize: 'medium',
  },
});
プロパティ型デフォルト値説明
enabledbooleantruefalse に設定するとプラグインを無効化。
formatsCalendarExportFormat[]['print', 'png', 'xlsx', 'ics']ダイアログに表示するフォーマットと順序。
filenamestring | ((context: CalendarExportFilenameContext) => string)—カスタムファイル名または生成関数。
pixelRationumber3PNG のデフォルト解像度倍率。
defaultOptionsPartial<CalendarPrintOptions>—初期オプション設定。
licensePackageLicenseConfig—個別ライセンス設定。

CalendarPrintOptions

プロパティ型デフォルト値説明
allDayEventsbooleantrue終日イベントを含める。
timedEventsbooleantrue時間指定イベントを含める。
miniCalendarbooleantrue印刷ヘッダーにミニカレンダーを表示。
calendarKeysbooleantrueカレンダー凡例を表示。
blackAndWhitebooleanfalseモノクロ印刷モード。
textSize'small' | 'medium' | 'large'mediumプレビューおよび印刷のタイポグラフィ密度。

プラグイン API

type PrintPluginApi = {
  open: (options?: PrintDialogOpenOptions) => void;
  close: () => void;
  print: (config?: CalendarPrintConfigInput) => void;
  export: (request: CalendarExportRequest) => Promise<CalendarExportResult>;
};

目次