Parcourir la source

compdfkit(win) - 修复了水印/密码损坏文档崩溃,修复了水印先设置自定义页面,再重新选择自定义页面后页码范围变为0开始,补充了水印页面范围水印和输入框居中

liuaoran il y a 1 an
Parent
commit
85fa634846

+ 4 - 0
Demo/Examples/Compdfkit_Tools/Security/Encryption/FileGridListControl.xaml.cs

@@ -102,6 +102,10 @@ namespace Compdfkit_Tools.PDFControl
                 }
 
                 var document = CPDFDocument.InitWithFilePath(fileInfoData.Location);
+                if (document == null)
+                {
+                    continue;
+                }
                 if (document.IsLocked)
                 {
                     PasswordWindow window = new PasswordWindow();

+ 4 - 0
Demo/Examples/Compdfkit_Tools/Security/Watermark/AddWatermark/FileGridListWithPageRangeControl.xaml.cs

@@ -161,6 +161,10 @@ namespace Compdfkit_Tools.PDFControl
                 foreach (string filePath in openFileDialog.FileNames)
                 {
                     CPDFDocument document = CPDFDocument.InitWithFilePath(filePath);
+                    if(document == null)
+                    {
+                        continue;
+                    }
                     if (document.IsLocked)
                     {
                         PasswordWindow passwordWindow = new PasswordWindow();

+ 6 - 1
Demo/Examples/Compdfkit_Tools/Security/Watermark/AddWatermark/PageRangeDialog.xaml

@@ -4,11 +4,13 @@
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:Compdfkit_Tools.PDFControl"
+         xmlns:cpdfcommon="clr-namespace:Compdfkit_Tools.Common"
         mc:Ignorable="d"
         ResizeMode="NoResize"
         Title="Settings" Height="580" Width="704" Loaded="Window_Loaded">
     <Window.Resources>
         <ResourceDictionary>
+            <cpdfcommon:TextLengthToVisibilityConverter x:Key="TextLengthToVisibilityConverter"></cpdfcommon:TextLengthToVisibilityConverter>
             <ResourceDictionary.MergedDictionaries>
                 <ResourceDictionary Source="../../../Asset/Styles/RadioButtonStyle.xaml"></ResourceDictionary>
             </ResourceDictionary.MergedDictionaries>
@@ -47,7 +49,10 @@
                     <RadioButton x:Name="CustomRangeRdo" Tag="Custom" Grid.Row="3" Margin="0,0,0,8" Checked="RangeRdo_Checked">
                         <StackPanel Orientation="Horizontal">
                             <TextBlock Text="Custom Range" VerticalAlignment="Center" FontSize="14" FontFamily="Microsoft YaHei"></TextBlock>
-                            <TextBox Margin="12,0,0,0" Text="{Binding PageRange, UpdateSourceTrigger=PropertyChanged}" Height="28" Width="150" IsEnabled="{Binding ElementName=CustomRangeRdo, Path=IsChecked}"></TextBox>
+                            <Grid>
+                                <TextBox x:Name="RangeTbx" Margin="12,0,0,0" Text="{Binding PageRange, UpdateSourceTrigger=PropertyChanged}" Height="28" Width="150" IsEnabled="{Binding ElementName=CustomRangeRdo, Path=IsChecked}" VerticalContentAlignment="Center"></TextBox>
+                                <TextBlock Text="1,3,5-10" VerticalAlignment="Center" Margin="15,0,0,0"  Visibility="{Binding ElementName=RangeTbx, Path=Text, Converter={StaticResource TextLengthToVisibilityConverter}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
+                            </Grid>
                         </StackPanel>
                     </RadioButton>
                 </Grid>

+ 5 - 0
Demo/Examples/Compdfkit_Tools/Security/Watermark/AddWatermark/PageRangeDialog.xaml.cs

@@ -146,6 +146,11 @@ namespace Compdfkit_Tools.PDFControl
                         canContinue = CommonHelper.GetPagesInRange(ref list, PageRange, fileInfo.Document.PageCount, new char[] { ',' }, new char[] { '-' }, false);
                         if (canContinue)
                         {
+                            // Increment each element in the list by 1
+                            for (int i = 0; i < list.Count; i++)
+                            {
+                                list[i]++;
+                            }
                             PageIndexList = list;
                         }
                         else

+ 4 - 0
Demo/Examples/Compdfkit_Tools/Security/Watermark/RemoveWatermark/RemoveWatermarkListControl.xaml.cs

@@ -107,6 +107,10 @@ DependencyProperty.Register(nameof(IsEnsure), typeof(bool), typeof(RemoveWaterma
                 foreach (string filePath in openFileDialog.FileNames)
                 {
                     CPDFDocument document = CPDFDocument.InitWithFilePath(filePath);
+                    if(document == null)
+                    {
+                        continue;
+                    }
                     if (document.IsLocked)
                     {
                         PasswordWindow passwordWindow = new PasswordWindow();