diff --git a/FormFields/Read_Only_FormFields/Formfields_Readonly.sln b/FormFields/Read_Only_FormFields/Formfields_Readonly.sln new file mode 100644 index 0000000..e299e65 --- /dev/null +++ b/FormFields/Read_Only_FormFields/Formfields_Readonly.sln @@ -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 diff --git a/FormFields/Read_Only_FormFields/Formfields_Readonly/App.xaml b/FormFields/Read_Only_FormFields/Formfields_Readonly/App.xaml new file mode 100644 index 0000000..e7f7688 --- /dev/null +++ b/FormFields/Read_Only_FormFields/Formfields_Readonly/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/FormFields/Read_Only_FormFields/Formfields_Readonly/App.xaml.cs b/FormFields/Read_Only_FormFields/Formfields_Readonly/App.xaml.cs new file mode 100644 index 0000000..9031f6a --- /dev/null +++ b/FormFields/Read_Only_FormFields/Formfields_Readonly/App.xaml.cs @@ -0,0 +1,14 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace Formfields_Readonly +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } + +} diff --git a/FormFields/Read_Only_FormFields/Formfields_Readonly/AssemblyInfo.cs b/FormFields/Read_Only_FormFields/Formfields_Readonly/AssemblyInfo.cs new file mode 100644 index 0000000..b0ec827 --- /dev/null +++ b/FormFields/Read_Only_FormFields/Formfields_Readonly/AssemblyInfo.cs @@ -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) +)] diff --git a/FormFields/Read_Only_FormFields/Formfields_Readonly/Formfields_Readonly.csproj b/FormFields/Read_Only_FormFields/Formfields_Readonly/Formfields_Readonly.csproj new file mode 100644 index 0000000..1c15958 --- /dev/null +++ b/FormFields/Read_Only_FormFields/Formfields_Readonly/Formfields_Readonly.csproj @@ -0,0 +1,15 @@ + + + + WinExe + net8.0-windows + enable + enable + true + + + + + + + diff --git a/FormFields/Read_Only_FormFields/Formfields_Readonly/Input.pdf b/FormFields/Read_Only_FormFields/Formfields_Readonly/Input.pdf new file mode 100644 index 0000000..41d2cb7 Binary files /dev/null and b/FormFields/Read_Only_FormFields/Formfields_Readonly/Input.pdf differ diff --git a/FormFields/Read_Only_FormFields/Formfields_Readonly/MainWindow.xaml b/FormFields/Read_Only_FormFields/Formfields_Readonly/MainWindow.xaml new file mode 100644 index 0000000..a4b0a9d --- /dev/null +++ b/FormFields/Read_Only_FormFields/Formfields_Readonly/MainWindow.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + diff --git a/FormFields/Read_Only_FormFields/Formfields_Readonly/MainWindow.xaml.cs b/FormFields/Read_Only_FormFields/Formfields_Readonly/MainWindow.xaml.cs new file mode 100644 index 0000000..7e0d009 --- /dev/null +++ b/FormFields/Read_Only_FormFields/Formfields_Readonly/MainWindow.xaml.cs @@ -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 +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + private ObservableCollection user1List = new ObservableCollection(); + private ObservableCollection user2List = new ObservableCollection(); + 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; + } + } + } + } +} \ No newline at end of file