12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using ComPDFKit.PDFDocument;
- using compdfkit_tools.Helper;
- using ComPDFKitViewer.PdfViewer;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Markup;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace compdfkit_tools.PDFControl
- {
- /// <summary>
- /// PDFCreateInfoControl.xaml 的交互逻辑
- /// </summary>
- public partial class CPDFCreateInfoControl : UserControl
- {
- public CPDFViewer pdfViewer;
- public void InitWithPDFViewer(CPDFViewer pdfViewer)
- {
- this.pdfViewer = pdfViewer;
- InitializeCreateInfo(pdfViewer.Document);
- }
- public CPDFCreateInfoControl()
- {
- InitializeComponent();
- }
- private void InitializeCreateInfo(CPDFDocument cpdfDocument)
- {
- VersionTextBlock.Text = cpdfDocument.GetInfo().Version;
- PageCountTextBlock.Text = cpdfDocument.PageCount.ToString();
- CreatorTextBlock.Text = cpdfDocument.GetInfo().Creator;
- CreationDateTextBlock.Text = ConverPDFTime(cpdfDocument.GetInfo().CreationDate);
- ModificationDateTextBlock.Text = ConverPDFTime(cpdfDocument.GetInfo().ModificationDate);
- }
- private string ConverPDFTime(string timeText)
- {
- try
- {
- if (Regex.IsMatch(timeText, "(?<=D\\:)[0-9]+(?=[\\+\\-])"))
- {
- string dateStr = Regex.Match(timeText, "(?<=D\\:)[0-9]+(?=[\\+\\-])").Value;
- timeText = dateStr.Substring(0, 4) + "-" + dateStr.Substring(4, 2) + "-" + dateStr.Substring(6, 2) + " " + dateStr.Substring(8, 2) + ":" +
- dateStr.Substring(10, 2) + ":" + dateStr.Substring(12, 2);
- }
- else if (Regex.IsMatch(timeText, "(?<=D\\:)[0-9]+"))
- {
- string dateStr = Regex.Match(timeText, "(?<=D\\:)[0-9]+").Value;
- if (dateStr.Length > 0)
- {
- timeText = dateStr.Substring(0, 4) + "-" + dateStr.Substring(4, 2) + "-" + dateStr.Substring(6, 2) + " " + dateStr.Substring(8, 2) + ":" +
- dateStr.Substring(10, 2) + ":" + dateStr.Substring(12, 2);
- }
- }
- }
- catch(Exception ex)
- {
- }
-
- return timeText;
- }
- }
- }
|