using it.stefanochizzolini.clown.documents;
using it.stefanochizzolini.clown.documents.contents.colorSpaces;
using it.stefanochizzolini.clown.documents.contents.composition;
using it.stefanochizzolini.clown.documents.contents.fonts;
using it.stefanochizzolini.clown.documents.interaction.navigation.page;
using it.stefanochizzolini.clown.files;
using it.stefanochizzolini.clown.tools;
using System;
using System.Drawing;
namespace it.stefanochizzolini.clown.samples{
/**
<summary>This sample demonstrates how to apply visual transitions to the pages of a document.</summary>
<remarks>To watch the transition effects applied to the document, you typically have to select
the presentation (full screen) view mode on your PDF viewer (for example Adobe Reader).</remarks>
*/
public class PageTransitionSample
: ISample
{
#region dynamic
#region interface
#region public
#region ISample
public void Run(
SampleLoader loader
)
{
// (boilerplate user choice -- ignore it)
string filePath = loader.GetPdfFileChoice("Please select a PDF file");
// 1. Open the PDF file!
File file = new File(filePath);
// Get the PDF document!
Document document = file.Document;
// 2. Applying the visual transitions...
Transition.StyleEnum[] transitionStyles = (Transition.StyleEnum[])Enum.GetValues(typeof(Transition.StyleEnum));
int transitionStylesLength = transitionStyles.Length;
Random random = new Random();
foreach(Page page in document.Pages)
{
// Apply a transition to the page!
page.Transition = new Transition(
document,
transitionStyles[random.Next(transitionStylesLength)], // NOTE: Random selection of the transition is done here just for demonstrative purposes; in real world, you would obviously choose only the appropriate enumeration constant among those available.
.5d // Transition duration (half a second).
);
// Set the display time of the page on presentation!
page.Duration = 2; // Page display duration (2 seconds).
page.Update();
}
// (boilerplate metadata insertion -- ignore it)
loader.BuildAccessories(document,this.GetType(),"Transition","applying visual transitions to pages");
// 3. Serialize the PDF file (again, boilerplate code -- see the SampleLoader class source code)!
loader.Serialize(file,this.GetType().Name);
}
#endregion
#endregion
#endregion
#endregion
}
}
|