Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 25 additions & 0 deletions FormFields/Read_Only_FormFields/Formfields_Readonly.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.37216.2 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Formfields_Readonly", "Formfields_Readonly\Formfields_Readonly.csproj", "{9909EFE3-E8EF-4E57-BCDD-9AC5DA9F0B54}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9909EFE3-E8EF-4E57-BCDD-9AC5DA9F0B54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9909EFE3-E8EF-4E57-BCDD-9AC5DA9F0B54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9909EFE3-E8EF-4E57-BCDD-9AC5DA9F0B54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9909EFE3-E8EF-4E57-BCDD-9AC5DA9F0B54}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B2C5FFB4-25EC-486B-8CDB-EA071D870954}
EndGlobalSection
EndGlobal
9 changes: 9 additions & 0 deletions FormFields/Read_Only_FormFields/Formfields_Readonly/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="Formfields_Readonly.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Formfields_Readonly"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
14 changes: 14 additions & 0 deletions FormFields/Read_Only_FormFields/Formfields_Readonly/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Configuration;
using System.Data;
using System.Windows;

namespace Formfields_Readonly
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.PdfViewer.WPF" Version="*" />
</ItemGroup>

</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Window x:Class="Formfields_Readonly.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Formfields_Readonly"
xmlns:syncfusion="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<StackPanel Orientation="Horizontal" Margin="10">
<TextBlock Text="Select User:" VerticalAlignment="Center" Margin="0,0,10,0"/>
<ComboBox x:Name="UserComboBox" Width="150" SelectionChanged="UserComboBox_SelectionChanged">
<ComboBoxItem Content="User1" />
<ComboBoxItem Content="User2"/>
</ComboBox>
</StackPanel>

<syncfusion:PdfViewerControl x:Name="pdfViewer" Grid.Row="1"></syncfusion:PdfViewerControl>

</Grid>
</Window>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using Syncfusion.Pdf.Interactive;
using Syncfusion.Pdf.Parsing;
using System.Collections.ObjectModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Formfields_Readonly
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private ObservableCollection<PdfField> user1List = new ObservableCollection<PdfField>();
private ObservableCollection<PdfField> user2List = new ObservableCollection<PdfField>();
public MainWindow()
{
InitializeComponent();
pdfViewer.Load("../../../Input.pdf");
pdfViewer.DocumentLoaded += PdfViewer_DocumentLoaded;
}

private void PdfViewer_DocumentLoaded(object sender, System.EventArgs e)
{
UpdateFormFields();
}

private void UpdateFormFields()
{

if (pdfViewer.LoadedDocument.Form != null)
{
var FormFieldCollections = pdfViewer.LoadedDocument.Form.Fields;

if (FormFieldCollections.Count > 0)
{
for (int i = 0; i < FormFieldCollections.Count; i++)
{
if (FormFieldCollections[i].Name == "User1_Name" || FormFieldCollections[i].Name == "User1_Age" || FormFieldCollections[i].Name == "User1_Country")
{
user1List.Add(FormFieldCollections[i]);
}
else
{
user2List.Add(FormFieldCollections[i]);
}
}
}



}
}
private void UserComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (pdfViewer.LoadedDocument == null) return;

var selectedUser = (UserComboBox.SelectedItem as ComboBoxItem).Content.ToString();

if (selectedUser == "User1")
{
foreach (var field in user1List)
{
if (field is PdfLoadedTextBoxField textField)
textField.ReadOnly = false;
}

foreach (var field in user2List)
{
if (field is PdfLoadedTextBoxField textField)
textField.ReadOnly = true;
}
}
else if (selectedUser == "User2")
{
foreach (var field in user2List)
{
if (field is PdfLoadedTextBoxField textField)
textField.ReadOnly = false;
}

foreach (var field in user1List)
{
if (field is PdfLoadedTextBoxField textField)
textField.ReadOnly = true;
}
}
}
}
}
Loading