Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="Add-Page-Level-Actions-in-PDF/Add-Page-Level-Actions-in-PDF.csproj" />
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Add_Page_Level_Actions_in_PDF</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<Folder Include="Data\" />
</ItemGroup>

</Project>
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Syncfusion.Pdf;
using Syncfusion.Pdf.Interactive;

// Create a new PDF document.
using (PdfDocument document = new PdfDocument())
{
// Add a page to the document.
PdfPage page1 = document.Pages.Add();
// Create and add new JavaScript action to execute when the first page opens
page1.Actions.OnOpen = new PdfJavaScriptAction("app.alert(\"Welcome! This page has just been opened.\");");
// Create and add new URI action to execute when the first page closes
page1.Actions.OnClose = new PdfUriAction("http://www.google.com");
// Add second page to the document.
PdfPage page2 = document.Pages.Add();
// Create a sound action
PdfSoundAction soundAction = new PdfSoundAction(Path.GetFullPath(@"Data/Startup.wav"));
soundAction.Sound.Bits = 16;
soundAction.Sound.Channels = PdfSoundChannels.Stereo;
soundAction.Sound.Encoding = PdfSoundEncoding.Signed;
soundAction.Volume = 0.9f;
// Set the sound action to execute when the second page opens
page2.Actions.OnOpen = soundAction;
// Create and add new Launch action to execute when the second page closes
page2.Actions.OnClose = new PdfLaunchAction(Path.GetFullPath(@"Data/logo.png"));
// Add third page to the document
PdfPage page3 = document.Pages.Add();
// Create and add new JavaScript action to execute when the third page opens
PdfAction jsAction = new PdfJavaScriptAction("app.alert(\"Welcome! Third page has just been opened.\");");
jsAction.Next = new PdfJavaScriptAction("app.alert(\"This is the second action.\");");
jsAction.Next.Next = new PdfJavaScriptAction("app.alert(\"This is the third action.\");");
page3.Actions.OnOpen = jsAction;
//Save the document
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="Removing-page-level-actions-from-PDF/Removing-page-level-actions-from-PDF.csproj" />
</Solution>
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Syncfusion.Pdf;
using Syncfusion.Pdf.Interactive;

// Create a new PDF document.
using (PdfDocument document = new PdfDocument())
{
// Add a page to the document.
PdfPage page1 = document.Pages.Add();
// Create and add new JavaScript action to execute when the first page opens
page1.Actions.OnOpen = new PdfJavaScriptAction("app.alert(\"Welcome! This page has just been opened.\");");
// Create and add new URI action to execute when the first page closes
page1.Actions.OnClose = new PdfUriAction("http://www.google.com");
// Add second page to the document.
PdfPage page2 = document.Pages.Add();
// Create a sound action
PdfSoundAction soundAction = new PdfSoundAction(Path.GetFullPath(@"Data/Startup.wav"));
soundAction.Sound.Bits = 16;
soundAction.Sound.Channels = PdfSoundChannels.Stereo;
soundAction.Sound.Encoding = PdfSoundEncoding.Signed;
soundAction.Volume = 0.9f;
// Set the so und action to execute when the second page opens
page2.Actions.OnOpen = soundAction;
// Create and add new Launch action to execute when the second page closes
page2.Actions.OnClose = new PdfLaunchAction(Path.GetFullPath(@"Data/logo.png"));
// Add third page to the document
PdfPage page3 = document.Pages.Add();
// Create and add new JavaScript action to execute when the third page opens
PdfAction jsAction = new PdfJavaScriptAction("app.alert(\"Welcome! Third page has just been opened.\");");
jsAction.Next = new PdfJavaScriptAction("app.alert(\"This is the second action.\");");
jsAction.Next.Next = new PdfJavaScriptAction("app.alert(\"This is the third action.\");");
page3.Actions.OnOpen = jsAction;
// Removing the open action on first page
page1.Actions.OnOpen = null;
// Removing the close action on second page
page2.Actions.OnClose = null;
// Removing both actions on third page
page3.Actions.Clear(false);
//Save the document
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Removing_page_level_actions_from_PDF</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
</ItemGroup>

</Project>
Loading