Skip to content

Commit 551b3bf

Browse files
committed
1016957: Added sample code for page-level action.
1 parent 308027b commit 551b3bf

File tree

12 files changed

+114
-0
lines changed

12 files changed

+114
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Add-Page-Level-Actions-in-PDF/Add-Page-Level-Actions-in-PDF.csproj" />
3+
</Solution>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Add_Page_Level_Actions_in_PDF</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<Folder Include="Data\" />
17+
</ItemGroup>
18+
19+
</Project>
Binary file not shown.
20.9 KB
Loading

Pages/Add-Page-Level-Actions-in-PDF/.NET/Add-Page-Level-Actions-in-PDF/Output/gitkeep.txt

Whitespace-only changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Syncfusion.Pdf;
2+
using Syncfusion.Pdf.Interactive;
3+
4+
// Create a new PDF document.
5+
using (PdfDocument document = new PdfDocument())
6+
{
7+
// Add a page to the document.
8+
PdfPage page1 = document.Pages.Add();
9+
// Create and add new JavaScript action to execute when the first page opens
10+
page1.Actions.OnOpen = new PdfJavaScriptAction("app.alert(\"Welcome! This page has just been opened.\");");
11+
// Create and add new URI action to execute when the first page closes
12+
page1.Actions.OnClose = new PdfUriAction("http://www.google.com");
13+
// Add second page to the document.
14+
PdfPage page2 = document.Pages.Add();
15+
// Create a sound action
16+
PdfSoundAction soundAction = new PdfSoundAction(Path.GetFullPath(@"Data/Startup.wav"));
17+
soundAction.Sound.Bits = 16;
18+
soundAction.Sound.Channels = PdfSoundChannels.Stereo;
19+
soundAction.Sound.Encoding = PdfSoundEncoding.Signed;
20+
soundAction.Volume = 0.9f;
21+
// Set the sound action to execute when the second page opens
22+
page2.Actions.OnOpen = soundAction;
23+
// Create and add new Launch action to execute when the second page closes
24+
page2.Actions.OnClose = new PdfLaunchAction(Path.GetFullPath(@"Data/logo.png"));
25+
// Add third page to the document
26+
PdfPage page3 = document.Pages.Add();
27+
// Create and add new JavaScript action to execute when the third page opens
28+
PdfAction jsAction = new PdfJavaScriptAction("app.alert(\"Welcome! Third page has just been opened.\");");
29+
jsAction.Next = new PdfJavaScriptAction("app.alert(\"This is the second action.\");");
30+
jsAction.Next.Next = new PdfJavaScriptAction("app.alert(\"This is the third action.\");");
31+
page3.Actions.OnOpen = jsAction;
32+
//Save the document
33+
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
34+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Removing-page-level-actions-from-PDF/Removing-page-level-actions-from-PDF.csproj" />
3+
</Solution>
20.9 KB
Loading

Pages/Removing-page-level-actions-from-PDF/.NET/Removing-page-level-actions-from-PDF/Output/gitkeep.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)