作成日: 2025/06/26 最終更新日: 2025/06/26
文書種別
使用方法
詳細
コードを用いて、指定したPDFのページがビューワに表示されるようにスクロールさせるには、C1FlexViewerのPageIndexプロパティを使用します。
まず、C1FlexViewer.ContinuousをTrue に設定して連続閲覧モードにします。
次いでC1FlexViewer.PageIndexに任意の値を設定します。
これにより、指定したページがビューワの左上隅にくるように、スクロールして表示されます。
以下に、テキストボックスの入力値に応じて、該当するページを表示するための簡単な設定例を記載します。
◎サンプルコード(VB)
Imports C1.Win.Document
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' PDF ドキュメントを読み込んで FlexViewer に設定
Dim pds As New C1PdfDocumentSource()
pds.DocumentLocation = "..\..\..\componentone-license.pdf"
C1FlexViewer1.DocumentSource = pds
' ビューワを連続スクロール モードにします
C1FlexViewer1.Continuous = True
End Sub
Private Sub textBox1_TextChanged(sender As Object, e As EventArgs) Handles textBox1.TextChanged
Dim n As Integer
If Integer.TryParse(textBox1.Text, n) Then
' 1 から始まる入力を 0 ベースの PageIndex に変換します
C1FlexViewer1.PageIndex = n - 1
End If
End Sub
End Class◎サンプルコード(C#)
using C1.Win.Document;
namespace prj_FlexViewer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
C1PdfDocumentSource pds = new C1PdfDocumentSource();
pds.DocumentLocation = @"..\..\..\componentone-license.pdf";
c1FlexViewer1.DocumentSource = pds;
// ビューワを連続スクロール モードにします
c1FlexViewer1.Continuous = true;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
int n;
if (int.TryParse(textBox1.Text, out n))
{
// 1 から始まる入力を 0 ベースの PageIndex に変換します
c1FlexViewer1.PageIndex = n - 1;
}
}
}