SoundAnnotations.vb
''
'' このコードは、DioDocs for PDF のサンプルの一部として提供されています。
'' Copyright (c) GrapeCity inc. All rights reserved.
''
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Pdf
Imports GrapeCity.Documents.Text
Imports GrapeCity.Documents.Pdf.Annotations
'' このサンプルは、PDF ドキュメントに音声注釈を追加する方法を示します。
Public Class SoundAnnotations
Sub CreatePDF(ByVal stream As Stream)
Dim doc = New GcPdfDocument()
Dim page = doc.NewPage()
Dim g = page.Graphics
'' 注釈の作成者のユーザー名
Dim user1 = "Aiff Ding"
Dim user2 = "Wav Dong"
Dim tf = New TextFormat() With {.Font = StandardFonts.Helvetica, .FontSize = 10}
Dim noteWidth = 72 * 3
Dim gap = 8
Dim rc = Util.AddNote(
"このサンプルは、GcPdf を使用して音声注釈を追加する方法を示します。" +
"注釈に関連付けられているトラックは、それをサポートしているビューワで再生できます。" +
"PDF は、音声注釈で AIFF および WAV トラックをサポートします。",
page)
'' AIFF 音声注釈
Dim ip = New PointF(rc.X, rc.Bottom + gap)
rc = Util.AddNote("赤色の音声注釈がこのメモの右側に配置されています。音声を再生するにはアイコンをダブルクリックします。",
page, New RectangleF(ip.X, ip.Y, noteWidth, 100))
Dim aiffAnnot = New SoundAnnotation() With
{
.UserName = user1,
.Contents = "AIFF トラックによる音声注釈です。",
.Rect = New RectangleF(rc.Right, rc.Top, 24, 24),
.Icon = SoundAnnotationIcon.Speaker,
.Color = Color.Red,
.Sound = SoundObject.FromFile(Path.Combine("Resources", "Sounds", "ding.aiff"), AudioFormat.Aiff)
}
page.Annotations.Add(aiffAnnot)
'' WAV 音声注釈
ip = New PointF(rc.X, rc.Bottom + gap)
rc = Util.AddNote("青色の音声注釈がこのノートの右側に配置されています。音声を再生するにはアイコンをダブルクリックします。",
page, New RectangleF(ip.X, ip.Y, noteWidth, 100))
Dim wavAnnot = New SoundAnnotation() With
{
.UserName = user2,
.Contents = "WAV トラックによる音声注釈です。",
.Rect = New RectangleF(rc.Right, rc.Top, 24, 24),
.Icon = SoundAnnotationIcon.Mic,
.Color = Color.Blue,
.Sound = SoundObject.FromFile(Path.Combine("Resources", "Sounds", "dong.wav"), AudioFormat.Wav)
}
page.Annotations.Add(wavAnnot)
'' PDF ドキュメントを保存します。
doc.Save(stream)
End Sub
End Class