Browse Source

其他-补充创建空白PDF功能

ZhouJieSheng 2 năm trước cách đây
mục cha
commit
0285c8447f

+ 9 - 1
PDF Office/App.config

@@ -1,8 +1,16 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
 <configuration>
     <configSections>
     </configSections>
     <startup> 
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
     </startup>
+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>
 </configuration>

+ 5 - 4
PDF Office/App.xaml.cs

@@ -125,6 +125,10 @@ namespace PDF_Office
             base.ConfigureRegionAdapterMappings(regionAdapterMappings);
         }
 
+        /// <summary>
+        /// 验证SDK和转档库密钥
+        /// </summary>
+        /// <returns></returns>
         private static bool LicenseVerify()
         {
             bool result = false;
@@ -142,20 +146,17 @@ namespace PDF_Office
             devKey = sdkhelper.DevKey;
             devSecret = sdkhelper.DevSecret;
 #endif
-
             string userKey = sdkhelper.UserKey; 
             string userSecret = sdkhelper.UserSecret; 
 
             try
             {
-                CPDFSDKVerifier.LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(devKey, devSecret, userKey, userSecret);
+                CPDFSDKVerifier.LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(devKey, devSecret);
                 if (verifyResult != CPDFSDKVerifier.LicenseErrorCode.LICENSE_ERR_SUCCESS)
                     return false;
             }
             catch{ }
 
-
-
             string ConverterDevKey = sdkhelper.ConverterDevKey;
             string ConverterDevSecret = sdkhelper.ConverterDevSecret; 
             string ConverterUserkey = sdkhelper.ConverterUserkey; 

+ 15 - 0
PDF Office/PDF Office.csproj

@@ -97,12 +97,27 @@
     <Reference Include="Microsoft.AppCenter.Crashes, Version=0.0.0.0, Culture=neutral, PublicKeyToken=8a600e2fee7ba272, processorArchitecture=MSIL">
       <HintPath>packages\Microsoft.AppCenter.Crashes.4.5.0\lib\net461\Microsoft.AppCenter.Crashes.dll</HintPath>
     </Reference>
+    <Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
+      <HintPath>packages\Microsoft.Office.Interop.Excel.15.0.4795.1001\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </Reference>
+    <Reference Include="Microsoft.Office.Interop.PowerPoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
+      <HintPath>packages\Microsoft.Office.Interop.PowerPoint.15.0.4420.1018\lib\net20\Microsoft.Office.Interop.PowerPoint.dll</HintPath>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </Reference>
+    <Reference Include="Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
+      <HintPath>packages\Microsoft.Office.Interop.Word.15.0.4797.1004\lib\net20\Microsoft.Office.Interop.Word.dll</HintPath>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </Reference>
     <Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
       <HintPath>packages\Microsoft.Xaml.Behaviors.Wpf.1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
     </Reference>
     <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
       <HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
     </Reference>
+    <Reference Include="office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </Reference>
     <Reference Include="Prism, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
       <HintPath>packages\Prism.Core.8.1.97\lib\net461\Prism.dll</HintPath>
     </Reference>

+ 23 - 4
PDF Office/ViewModels/HomeContentViewModel.cs

@@ -44,15 +44,16 @@ namespace PDF_Office.ViewModels
             }
         }
 
-
-
-
         private MainContentViewModel mainContentViewModel;
 
         public DelegateCommand OpenFileCommand { get; set; }
 
         public DelegateCommand<string> ShowToolCommand { get; set; }
 
+        public DelegateCommand CreateBlackPDFCommand { get; set; }
+
+        public DelegateCommand CreateFromOtherFile { get; set; }
+
         public IRegionManager toolregion;
 
         public IEventAggregator eventer;
@@ -65,6 +66,8 @@ namespace PDF_Office.ViewModels
             ToolRegionName = Guid.NewGuid().ToString();
             OpenFileCommand = new DelegateCommand(OpenFile);
             ShowToolCommand = new DelegateCommand<string>(ShowToolContent);
+            CreateBlackPDFCommand = new DelegateCommand(CreatBlankPDF);
+            CreateFromOtherFile = new DelegateCommand(createFromOtherFile);
 
             System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
             {
@@ -81,6 +84,14 @@ namespace PDF_Office.ViewModels
             toolregion.RequestNavigate(ToolRegionName, view);
         }
 
+        /// <summary>
+        /// 从其他格式文件创建PDF
+        /// </summary>
+        private void createFromOtherFile()
+        {
+
+        }
+
         /// <summary>
         /// 打开文件
         /// </summary>
@@ -125,11 +136,19 @@ namespace PDF_Office.ViewModels
             }
         }
 
-        public void CreatBlankPDF()
+        /// <summary>
+        /// 打开其他格式文件
+        /// </summary>
+        public void OpenFromOtherFile()
         {
 
         }
 
+        public void CreatBlankPDF()
+        {
+            mainContentViewModel.CreateFile();
+        }
+
         #region Navigate
         public void OnNavigatedTo(NavigationContext navigationContext)
         {

+ 248 - 14
PDF Office/ViewModels/MainContentViewModel.cs

@@ -16,11 +16,14 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
-using System.Windows.Controls;
 using PDF_Office.Model;
 using System.ComponentModel;
 using PDF_Office.Helper;
 using PDFSettings.Settings;
+using System.Drawing;
+using System.IO;
+using System.Drawing.Imaging;
+using ComPDFKit.PDFDocument;
 
 namespace PDF_Office.ViewModels
 {
@@ -58,6 +61,8 @@ namespace PDF_Office.ViewModels
             set { SetProperty(ref fileChanged, value); }
         }
 
+        private bool isNewDocument = false;
+
         public CPDFViewer PDFViewer { get; set; }
 
 
@@ -65,6 +70,8 @@ namespace PDF_Office.ViewModels
 
         public DelegateCommand<object> Loaded { get; set; }
 
+        public AlertsMessage AlertsMessage = new AlertsMessage();
+
 
         private string regionName;
 
@@ -113,6 +120,10 @@ namespace PDF_Office.ViewModels
         }
 
 
+        /// <summary>
+        /// 打开指定路径的PDF文件
+        /// </summary>
+        /// <param name="filePath"></param>
         public void OpenFile(string filePath)
         {
             var result = LoadFileFormPath(filePath);
@@ -122,28 +133,40 @@ namespace PDF_Office.ViewModels
             }
             FilePath = filePath;
 
-            NavigationParameters parameters = new NavigationParameters {
-                { ParameterNames.MainViewModel, this },
-                { ParameterNames.PDFViewer,PDFViewer}
-            };
-            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
-                {
-                    if (toolregion.Regions.ContainsRegionWithName(MainContentRegionName))
-                        toolregion.RequestNavigate(MainContentRegionName, "ViewContent", parameters);
-                }));
+            NavigateToViewContent();
 
             //检查是否是新文档
             OpenFileInfo isnew = SettingHelper.GetFileInfo(filePath);
             if (isnew == null)
             {
                 isNewDocument = true;
-                if(App.OpenedFileList.Contains(filePath) == false)
+                if (App.OpenedFileList.Contains(filePath) == false)
+                {
                     App.OpenedFileList.Add(filePath);
-                SettingHelper.SortRecentOpenFiles(filePath);
-            } 
+                }
+         
+            }
+            //打开文件后,不管是新文件还是旧文件都需要更新排序
+            SettingHelper.SortRecentOpenFiles(filePath);
+        }
+
+        /// <summary>
+        /// 创建PDFviewer对象后导航到ViewContent
+        /// </summary>
+        private void NavigateToViewContent()
+        {
+            NavigationParameters parameters = new NavigationParameters {
+                { ParameterNames.MainViewModel, this },
+                { ParameterNames.PDFViewer,PDFViewer}
+            };
+            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+            {
+                if (toolregion.Regions.ContainsRegionWithName(MainContentRegionName))
+                    toolregion.RequestNavigate(MainContentRegionName, "ViewContent", parameters);
+            }));
 
         }
-        private bool isNewDocument = false;
+
         /// <summary>
         /// 从文件路径创建PDFViewer对象,已包含文档解密逻辑
         /// </summary>
@@ -195,6 +218,210 @@ namespace PDF_Office.ViewModels
             return true;
         }
 
+        /// <summary>
+        /// 创建文件,路径为空时表示创建空白文档
+        /// 否则表示从图片路径创建PDf
+        /// </summary>
+        /// <param name="imagePath"></param>
+        /// <returns></returns>
+        public bool CreateFile(string imagePath = null)
+        {
+            PDFViewer = new CPDFViewer();
+            PDFViewer.CreateDocument();
+            PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
+            if (PDFViewer.Document == null)
+            {
+                AlertsMessage alertsMessage = new AlertsMessage();
+                alertsMessage.ShowDialog("","创建文件失败.","OK");
+                return false;
+            }
+
+            if (string.IsNullOrEmpty(imagePath))
+            {
+                FileName = "Blank Page.pdf";
+                //默认插入595*842 大小的页面
+                PDFViewer.Document.InsertPage(0, 595, 842, null);
+            }
+            else
+            {
+                FileName = imagePath.Substring(imagePath.LastIndexOf("\\") + 1, imagePath.LastIndexOf(".") - imagePath.LastIndexOf("\\") - 1) + ".pdf";
+                Bitmap pic = new Bitmap(imagePath);
+                int width = pic.Size.Width;
+                int height = pic.Size.Height;
+
+                string ex = System.IO.Path.GetExtension(imagePath);
+                //其他格式或者名称中含空格的图片 在本地先转存一下
+                if ((ex != ".jpg" && ex != ".jpeg") || !Uri.IsWellFormedUriString(imagePath, UriKind.Absolute))
+                {
+                    //将其他格式图片转换成jpg
+                    string folderPath = Path.GetTempPath();
+                    if (File.Exists(folderPath))
+                    {
+                        File.Delete(folderPath);
+                    }
+                    DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                    if (!tempfolder.Exists)
+                    {
+                        tempfolder.Create();
+                    }
+                    string targetPath = System.IO.Path.Combine(folderPath, Guid.NewGuid().ToString());
+                    imagePath = targetPath;
+                    pic.Save(targetPath, ImageFormat.Jpeg);
+                }
+                pic.Dispose();
+
+                var result = PDFViewer.Document.InsertPage(0, width, height, imagePath);
+                if (!result)
+                {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("", "创建文件失败.", "OK");
+                    return false;
+                }
+            }
+
+            //设置背景色
+            ////PDFViewer.SetBackgroundBrush(new SolidColorBrush((Color)System.Windows.Media.ColorConverter.ConvertFromString(Settings.Default.AppProperties.InitialVIew.Background)));
+            PDFViewer.Load();
+            PDFViewer.UndoManager.CanSave = true;
+            FileChanged = Visibility.Visible;
+            PDFViewer.SetFormFieldHighlight(true);
+
+            NavigateToViewContent();
+            return true;
+        }
+
+        /// <summary>
+        /// 从office文件转换成PDF
+        /// </summary>
+        /// <param name="sourcepath"></param>
+        /// <returns></returns>
+        public async Task<bool> CreateFileFromOffice(string sourcepath)
+        {
+            try
+            {
+                string folderPath = Path.GetTempPath();
+                if (File.Exists(folderPath))
+                {
+                    File.Delete(folderPath);
+                }
+                DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                if (!tempfolder.Exists)
+                {
+                    tempfolder.Create();
+                }
+                string targetPath = System.IO.Path.Combine(folderPath, Guid.NewGuid().ToString() + ".pdf");
+
+                string ex = System.IO.Path.GetExtension(sourcepath);
+
+                switch (ex)
+                {
+
+                    case ".doc":
+                    case ".docx":
+                    case "docm":
+                    case ".dot":
+                    case ".dotx":
+                    case ".dotm":
+                    case ".txt":
+                        await Task.Run(() =>
+                        {
+
+                            Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
+                            Microsoft.Office.Interop.Word.Document document = null;
+
+                            word.Visible = false;
+                            word.ShowWindowsInTaskbar = true;
+                            document = word.Documents.Open(sourcepath);
+                            document?.ExportAsFixedFormat(targetPath, Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF);
+                            document?.Close();
+                            word?.Quit();
+                        });
+                        break;
+                    case ".xls":
+                    case ".xlsx":
+                    case ".xlsm":
+                    case ".xlsb":
+                    case ".xlam":
+                    case ".xltx":
+                    case ".xlt":
+                        await Task.Run(() =>
+                        {
+                            Microsoft.Office.Interop.Excel.Application excele = new Microsoft.Office.Interop.Excel.Application();
+                            Microsoft.Office.Interop.Excel.Workbook workbook = null;
+
+                            excele.Visible = false;
+                            try
+                            {
+                                workbook = excele.Workbooks.Open(sourcepath);
+                            }
+                            catch (Exception e)
+                            {
+                                workbook = excele.Workbooks.Open(sourcepath, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "t", false, false, 0, true, 1, Microsoft.Office.Interop.Excel.XlCorruptLoad.xlRepairFile);
+                            }
+
+
+                            workbook?.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, targetPath);
+                            workbook?.Close();
+                            excele?.Quit();
+                        });
+                        break;
+                    case ".ppt":
+                    case ".pptx":
+                    case ".pptm":
+                    case ".pptsx":
+                    case ".pps":
+                    case ".pptsm":
+                    case ".pot":
+                    case ".potm":
+                        await Task.Run(() =>
+                        {
+                            Microsoft.Office.Interop.PowerPoint.Application ppt = new Microsoft.Office.Interop.PowerPoint.Application();
+                            Microsoft.Office.Interop.PowerPoint.Presentation presentation = null;
+
+                            ppt.Visible = Microsoft.Office.Core.MsoTriState.msoCTrue;
+                            presentation = ppt.Presentations.Open(sourcepath);
+
+                            presentation.ExportAsFixedFormat(targetPath, Microsoft.Office.Interop.PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF);
+                            presentation?.Close();
+                            ppt?.Quit();
+                        });
+                        break;
+                }
+
+                PDFViewer = new CPDFViewer();
+                PDFViewer.CreateDocument();
+
+                if (PDFViewer.Document == null)
+                {
+                    AlertsMessage.ShowDialog("","创建PDF失败","OK");
+                    return false;
+                }
+
+                FileName = sourcepath.Substring(sourcepath.LastIndexOf("\\") + 1, sourcepath.LastIndexOf(".") - sourcepath.LastIndexOf("\\") - 1) + ".pdf";
+
+                var tempdoc = CPDFDocument.InitWithFilePath(targetPath);
+                if (tempdoc == null)
+                {
+                    AlertsMessage.ShowDialog("", "创建PDF失败", "OK");
+                    return false;
+                }
+
+                PDFViewer.Document.ImportPages(tempdoc, "");
+
+                //PDFViewer.SetBackgroundBrush(new SolidColorBrush((Color)System.Windows.Media.ColorConverter.ConvertFromString(Settings.Default.AppProperties.InitialVIew.Background)));
+                PDFViewer.Load();
+                PDFViewer.UndoManager.CanSave = true;
+
+
+                return true;
+            }
+            catch (Exception ex)
+            {
+                AlertsMessage.ShowDialog("", "没有安装Office", "OK");
+                return false;
+            }
+        }
+
         private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
         {
             if (e.PropertyName == "CanSave")
@@ -207,9 +434,15 @@ namespace PDF_Office.ViewModels
                 {
                     FileChanged = Visibility.Collapsed;
                 }
+
+                if (!string.IsNullOrEmpty(PDFViewer.Document.FileName))
+                {
+                    FileName = PDFViewer.Document.FileName;
+                }
             }
         }
 
+        #region Navigation
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             if (navigationContext.Parameters.Count <= 0)
@@ -229,5 +462,6 @@ namespace PDF_Office.ViewModels
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
         }
+        #endregion
     }
 }

+ 3 - 1
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -571,7 +571,9 @@ namespace PDF_Office.ViewModels
             string oldFilePath = targetPath;
 
             PDFViewer.UndoManager.CanSave = false;
-            PDFViewer.CloseDocument();
+
+            mainViewModel.OpenFile(targetPath);
+            //TODO:通知各模块更新PDFview对象
             //var result = OpenFile(targetPath, true);
 
             //if (result)

+ 1 - 1
PDF Office/Views/BOTA/BOTAContent.xaml

@@ -68,7 +68,7 @@
             Style="{StaticResource TabControlWithUnderLineStyle}"
             TabStripPlacement="Left">
             <!--  建立一个空的标头占位  -->
-            <TabItem Height="0" />
+            <TabItem Height="0" BorderThickness="0" />
             <TabItem
                 Name="TabItemThumbnail"
                 Width="48"

+ 151 - 48
PDF Office/Views/HomeContent.xaml

@@ -3,33 +3,45 @@
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:cus="clr-namespace:PDF_Office.CustomControl"
+    xmlns:customControl="clr-namespace:PDF_Office.CustomControl"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:homePanel="clr-namespace:PDF_Office.Views.HomePanel"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     xmlns:prism="http://prismlibrary.com/"
     xmlns:viewmodels="clr-namespace:PDF_Office.ViewModels"
+    d:DataContext="{d:DesignInstance Type=viewmodels:HomeContentViewModel}"
     d:DesignHeight="450"
     d:DesignWidth="800"
     prism:ViewModelLocator.AutoWireViewModel="True"
-    xmlns:customControl ="clr-namespace:PDF_Office.CustomControl"
-    xmlns:homePanel="clr-namespace:PDF_Office.Views.HomePanel"
     mc:Ignorable="d">
     <UserControl.Resources>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
-                <ResourceDictionary Source="../Styles/CustomBtnStyle.xaml"/>
+                <ResourceDictionary Source="../Styles/CustomBtnStyle.xaml" />
             </ResourceDictionary.MergedDictionaries>
             <DataTemplate x:Key="PromotionDataTemplate">
-                <StackPanel Background="White" Orientation="Horizontal" Cursor="Hand" Margin="0,10,0,10">
-                    <Image Width="16" Height="16" Source="{Binding ImagePath}" Margin="0,0,10,0"/>
-                    <TextBlock Text="{Binding Content}" FontSize="14" Foreground="#6B6F7D"/>
+                <StackPanel
+                    Margin="0,10,0,10"
+                    Background="White"
+                    Cursor="Hand"
+                    Orientation="Horizontal">
+                    <Image
+                        Width="16"
+                        Height="16"
+                        Margin="0,0,10,0"
+                        Source="{Binding ImagePath}" />
+                    <TextBlock
+                        FontSize="14"
+                        Foreground="#6B6F7D"
+                        Text="{Binding Content}" />
                 </StackPanel>
             </DataTemplate>
         </ResourceDictionary>
     </UserControl.Resources>
     <Grid>
         <Grid.RowDefinitions>
-            <RowDefinition Height="Auto"/>
-            <RowDefinition/>
+            <RowDefinition Height="Auto" />
+            <RowDefinition />
         </Grid.RowDefinitions>
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="270" />
@@ -37,62 +49,153 @@
         </Grid.ColumnDefinitions>
         <!--  左侧菜单栏  -->
         <StackPanel>
-            <Button x:Name="BtnOpenPDF"  Height="48" Margin="41,54,41,0" Foreground="#FFFFFF" Background="#19233B" BorderThickness="1"
-                    Command="{Binding OpenFileCommand}" 
-                    Style="{StaticResource BlueBtnStyle}" >
+            <Button
+                x:Name="BtnOpenPDF"
+                Height="48"
+                Margin="41,54,41,0"
+                Background="#19233B"
+                BorderThickness="1"
+                Command="{Binding OpenFileCommand}"
+                Foreground="#FFFFFF"
+                Style="{StaticResource BlueBtnStyle}">
                 <StackPanel Orientation="Horizontal">
-                    <TextBlock x:Name="TxbOpenPDF" Text="Open File" VerticalAlignment="Center" FontFamily="Segoe UI"  FontSize="16"/>
+                    <TextBlock
+                        x:Name="TxbOpenPDF"
+                        VerticalAlignment="Center"
+                        FontFamily="Segoe UI"
+                        FontSize="16"
+                        Text="Open File" />
                 </StackPanel>
             </Button>
 
-            <Button x:Name="BtnCreatPDF"  Height="48" Width="188" Margin="41,8,41,0" Background="White" BorderThickness="1" HorizontalContentAlignment="Left"
-                    Command="{Binding OpenFileCommand}" 
-                    Style="{StaticResource BlueBtnStyle}" >
-                <Grid Width="184" >
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition />
-                        <ColumnDefinition  Width="48"/>
-                    </Grid.ColumnDefinitions>
-                    <StackPanel Orientation="Horizontal"  HorizontalAlignment="Left">
-                        <Image Width="30" Height="30" Source="../Resources/HomeIcon/file_addition.png" Margin="18,0,12,0"/>
-                        <TextBlock x:Name="TxbCreatePDF" Text="Creat PDF" VerticalAlignment="Center" FontFamily="Segoe UI" Foreground="{StaticResource Common.ForGround.Blue}"  FontSize="16"/>
-                    </StackPanel>
-                    <StackPanel  Orientation="Horizontal" Grid.Column="1"  HorizontalAlignment='Center'>
-                        <Rectangle Fill="#6B869C" Width="1" Height="48"  Margin="0,0,8,0"/>
-                        <Path Data="M12.0001 6.00012L8 10.0002L3.99988 6.00012"  HorizontalAlignment="Center" VerticalAlignment="Center" Stroke="#6B869C"/>
-                    </StackPanel>
+            <Border
+                Margin="41,8,41,0"
+                BorderBrush="#000000"
+                BorderThickness="1"
+                CornerRadius="4">
+                <Grid Width="188" Height="48">
+                    <Menu HorizontalAlignment="Right">
+                        <MenuItem
+                            Width="168"
+                            Height="48"
+                            Padding="138,0,0,0"
+                            HorizontalContentAlignment="Right">
+                            <MenuItem.Header>
+                                <Path
+                                    Width="32"
+                                    HorizontalAlignment="Right"
+                                    VerticalAlignment="Center"
+                                    Data="M12.0001 6.00012L8 10.0002L3.99988 6.00012"
+                                    Stroke="#6B869C" />
+                            </MenuItem.Header>
+                            <MenuItem
+                                Width="158"
+                                Command="{Binding CreateBlackPDFCommand}"
+                                Header="新建空白PDF" />
+                            <MenuItem Header="从网页创建PDF" />
+                            <MenuItem Header="从扫描仪导入" />
+                        </MenuItem>
+                    </Menu>
+                    <Button
+                        Width="156"
+                        HorizontalAlignment="Left"
+                        Background="White"
+                        BorderThickness="0">
+                        <StackPanel Orientation="Horizontal">
+                            <Image
+                                Width="30"
+                                Height="30"
+                                Margin="18,0,12,0"
+                                Source="../Resources/HomeIcon/file_addition.png" />
+                            <TextBlock
+                                x:Name="TxbCreatePDF"
+                                VerticalAlignment="Center"
+                                FontFamily="Segoe UI"
+                                FontSize="16"
+                                Foreground="{StaticResource Common.ForGround.Blue}"
+                                Text="Creat PDF" />
+                        </StackPanel>
+                    </Button>
                 </Grid>
-                
-            </Button>
+            </Border>
 
-            <customControl:CustomIconToggleBtn x:Name="BtnGuid" Margin="0,24,0,0" Width="216" HorizontalContentAlignment="Left" Height="40" Tag="GridMode" Command="{Binding ShowToolCommand}" CommandParameter="Guid" Click="ToggleBtnSelect_Click"
-                                              Style="{StaticResource ToggleBtnSelectStyle}">
-                <StackPanel Orientation="Horizontal" Margin="8,0,8,0">
-                    <Path Fill="{Binding ElementName=BtnGuid,Path=Foreground}" Data="M3.8655 5.79653C3.32363 6.16977 3 6.78565 3 7.44363V15C3 16.1046 3.89543 17 5 17H9V13.1785C9 12.6262 9.44772 12.1785 10 12.1785C10.5523 12.1785 11 12.6262 11 13.1785V17H15C16.1046 17 17 16.1046 17 15V7.44363C17 6.78565 16.6764 6.16977 16.1345 5.79653L11.1345 2.3526C10.4514 1.88206 9.54865 1.88206 8.8655 2.3526L3.8655 5.79653Z"/>
-                    <TextBlock x:Name="TxbHome" Text="Home" VerticalAlignment="Center" Margin="8,0,0,0" FontFamily="SF Pro Text" FontSize="14"/>
+            <customControl:CustomIconToggleBtn
+                x:Name="BtnGuid"
+                Width="216"
+                Height="40"
+                Margin="0,24,0,0"
+                HorizontalContentAlignment="Left"
+                Click="ToggleBtnSelect_Click"
+                Command="{Binding ShowToolCommand}"
+                CommandParameter="Guid"
+                Style="{StaticResource ToggleBtnSelectStyle}"
+                Tag="GridMode">
+                <StackPanel Margin="8,0,8,0" Orientation="Horizontal">
+                    <Path Data="M3.8655 5.79653C3.32363 6.16977 3 6.78565 3 7.44363V15C3 16.1046 3.89543 17 5 17H9V13.1785C9 12.6262 9.44772 12.1785 10 12.1785C10.5523 12.1785 11 12.6262 11 13.1785V17H15C16.1046 17 17 16.1046 17 15V7.44363C17 6.78565 16.6764 6.16977 16.1345 5.79653L11.1345 2.3526C10.4514 1.88206 9.54865 1.88206 8.8655 2.3526L3.8655 5.79653Z" Fill="{Binding ElementName=BtnGuid, Path=Foreground}" />
+                    <TextBlock
+                        x:Name="TxbHome"
+                        Margin="8,0,0,0"
+                        VerticalAlignment="Center"
+                        FontFamily="SF Pro Text"
+                        FontSize="14"
+                        Text="Home" />
                 </StackPanel>
             </customControl:CustomIconToggleBtn>
 
-            <customControl:CustomIconToggleBtn x:Name="BtnTool"  Width="216" Height="40" HorizontalContentAlignment="Left" Tag="GridMode" Command="{Binding ShowToolCommand}" CommandParameter="Tools" Click="ToggleBtnSelect_Click"
-                                              Style="{StaticResource ToggleBtnSelectStyle}">
-                <StackPanel Orientation="Horizontal" Margin="8,0,8,0">
-                    <Path Fill="{Binding ElementName=BtnTool,Path=Foreground}" Data="M3.8655 5.79653C3.32363 6.16977 3 6.78565 3 7.44363V15C3 16.1046 3.89543 17 5 17H9V13.1785C9 12.6262 9.44772 12.1785 10 12.1785C10.5523 12.1785 11 12.6262 11 13.1785V17H15C16.1046 17 17 16.1046 17 15V7.44363C17 6.78565 16.6764 6.16977 16.1345 5.79653L11.1345 2.3526C10.4514 1.88206 9.54865 1.88206 8.8655 2.3526L3.8655 5.79653Z"/>
-                    <TextBlock x:Name="TxbTool" Text="Tool" VerticalAlignment="Center" Margin="8,0,0,0" FontFamily="SF Pro Text" FontSize="14"/>
+            <customControl:CustomIconToggleBtn
+                x:Name="BtnTool"
+                Width="216"
+                Height="40"
+                HorizontalContentAlignment="Left"
+                Click="ToggleBtnSelect_Click"
+                Command="{Binding ShowToolCommand}"
+                CommandParameter="Tools"
+                Style="{StaticResource ToggleBtnSelectStyle}"
+                Tag="GridMode">
+                <StackPanel Margin="8,0,8,0" Orientation="Horizontal">
+                    <Path Data="M3.8655 5.79653C3.32363 6.16977 3 6.78565 3 7.44363V15C3 16.1046 3.89543 17 5 17H9V13.1785C9 12.6262 9.44772 12.1785 10 12.1785C10.5523 12.1785 11 12.6262 11 13.1785V17H15C16.1046 17 17 16.1046 17 15V7.44363C17 6.78565 16.6764 6.16977 16.1345 5.79653L11.1345 2.3526C10.4514 1.88206 9.54865 1.88206 8.8655 2.3526L3.8655 5.79653Z" Fill="{Binding ElementName=BtnTool, Path=Foreground}" />
+                    <TextBlock
+                        x:Name="TxbTool"
+                        Margin="8,0,0,0"
+                        VerticalAlignment="Center"
+                        FontFamily="SF Pro Text"
+                        FontSize="14"
+                        Text="Tool" />
                 </StackPanel>
             </customControl:CustomIconToggleBtn>
 
-            <customControl:CustomIconToggleBtn x:Name="BtnCloud" Width="216" HorizontalContentAlignment="Left" Height="40" Tag="GridMode" Command="{Binding ShowToolCommand}" CommandParameter="Cloud" Click="ToggleBtnSelect_Click"
-                                              Style="{StaticResource ToggleBtnSelectStyle}">
-                <StackPanel Orientation="Horizontal" Margin="8,0,8,0">
-                    <Path Fill="{Binding ElementName=BtnCloud,Path=Foreground}" Data="M14.95 16.5H5.5C3.01472 16.5 1 14.4853 1 12C1 9.51472 3.01472 7.5 5.5 7.5L5.52018 7.50004C5.74751 4.9771 7.86787 3 10.45 3C13.1838 3 15.4 5.21619 15.4 7.95C15.4 8.10931 15.3925 8.26686 15.3778 8.42232C17.4134 8.63601 19 10.3577 19 12.45C19 14.6701 17.2137 16.4729 15 16.4997V16.5H14.95Z"/>
-                    <TextBlock x:Name="TxbCloud" Text="Cloud" FontFamily="SF Pro Text" FontSize="14" VerticalAlignment="Center" Margin="8,0,0,0" />
+            <customControl:CustomIconToggleBtn
+                x:Name="BtnCloud"
+                Width="216"
+                Height="40"
+                HorizontalContentAlignment="Left"
+                Click="ToggleBtnSelect_Click"
+                Command="{Binding ShowToolCommand}"
+                CommandParameter="Cloud"
+                Style="{StaticResource ToggleBtnSelectStyle}"
+                Tag="GridMode">
+                <StackPanel Margin="8,0,8,0" Orientation="Horizontal">
+                    <Path Data="M14.95 16.5H5.5C3.01472 16.5 1 14.4853 1 12C1 9.51472 3.01472 7.5 5.5 7.5L5.52018 7.50004C5.74751 4.9771 7.86787 3 10.45 3C13.1838 3 15.4 5.21619 15.4 7.95C15.4 8.10931 15.3925 8.26686 15.3778 8.42232C17.4134 8.63601 19 10.3577 19 12.45C19 14.6701 17.2137 16.4729 15 16.4997V16.5H14.95Z" Fill="{Binding ElementName=BtnCloud, Path=Foreground}" />
+                    <TextBlock
+                        x:Name="TxbCloud"
+                        Margin="8,0,0,0"
+                        VerticalAlignment="Center"
+                        FontFamily="SF Pro Text"
+                        FontSize="14"
+                        Text="Cloud" />
                 </StackPanel>
             </customControl:CustomIconToggleBtn>
 
         </StackPanel>
-        <homePanel:PromotionContent Grid.Row="1"/>
+        <homePanel:PromotionContent Grid.Row="1" />
         <!--  右侧内容区域  -->
-        <ContentControl Grid.Column="1" Grid.RowSpan="2" prism:RegionManager.RegionName="{Binding ToolRegionName}" />
-        <cus:LoadingControl Grid.ColumnSpan="2" Grid.RowSpan="2" Visibility="{Binding IsLoading}" />
+        <ContentControl
+            Grid.RowSpan="2"
+            Grid.Column="1"
+            prism:RegionManager.RegionName="{Binding ToolRegionName}" />
+        <cus:LoadingControl
+            Grid.RowSpan="2"
+            Grid.ColumnSpan="2"
+            Visibility="{Binding IsLoading}" />
     </Grid>
 </UserControl>

+ 3 - 0
PDF Office/packages.config

@@ -9,6 +9,9 @@
   <package id="Microsoft.AppCenter" version="4.5.0" targetFramework="net462" />
   <package id="Microsoft.AppCenter.Analytics" version="4.5.0" targetFramework="net462" />
   <package id="Microsoft.AppCenter.Crashes" version="4.5.0" targetFramework="net462" />
+  <package id="Microsoft.Office.Interop.Excel" version="15.0.4795.1001" targetFramework="net462" />
+  <package id="Microsoft.Office.Interop.PowerPoint" version="15.0.4420.1018" targetFramework="net462" />
+  <package id="Microsoft.Office.Interop.Word" version="15.0.4797.1004" targetFramework="net462" />
   <package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.31" targetFramework="net462" />
   <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net462" />
   <package id="Prism.Core" version="8.1.97" targetFramework="net462" />