12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using ComPDFKit.PDFPage;
- using ComPDFKit.PDFPage.Edit;
- using ComPDFKitViewer;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Master.Properties;
- using PDFSettings;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PDF_Master.Helper
- {
- public static class PDFEditHelper
- {
- /// <summary>
- /// 获取本地配置,并且更新对应属性
- /// </summary>
- /// <returns></returns>
- public static PDFEditEvent GetPDFEditDefaultProperty(out DefaultEditProperty defaultEdit, CPDFViewer pdf)
- {
- PDFEditEvent editEvent = null;
- defaultEdit = SettingHelper.GetPDFEditDefaultProperty(CPDFEditType.EditText);
- if (defaultEdit == null)
- {
- defaultEdit = SetDefaultEdit();
- }
- editEvent = GetPDFEditEvent(defaultEdit, pdf);
- return editEvent;
- }
- /// <summary>
- /// 更新CPDFViewer的属性
- /// </summary>
- /// <param name="defaultEdit"></param>
- /// <param name="pdf"></param>
- /// <returns></returns>
- public static PDFEditEvent GetPDFEditEvent(DefaultEditProperty defaultEdit, CPDFViewer pdf)
- {
- PDFEditEvent dFEditEvent = new PDFEditEvent();
- dFEditEvent.FontName = defaultEdit.FontName;
- dFEditEvent.FontSize = defaultEdit.FontSize;
- dFEditEvent.TextAlign = defaultEdit.TextAlign;
- dFEditEvent.AutoBlock = defaultEdit.AutoBlock;
- dFEditEvent.ClipImage = defaultEdit.ClipImage;
- dFEditEvent.EditType = defaultEdit.EditType;
- dFEditEvent.FontColor = defaultEdit.FontColor;
- dFEditEvent.HorizontalMirror = defaultEdit.HorizontalMirror;
- dFEditEvent.IsBold = defaultEdit.IsBold;
- dFEditEvent.IsItalic = defaultEdit.IsItalic;
- dFEditEvent.ReplaceImagePath = defaultEdit.ReplaceImagePath;
- dFEditEvent.Rotate = defaultEdit.Rotate;
- dFEditEvent.Transparency = defaultEdit.Transparency;
- dFEditEvent.VerticalMirror = defaultEdit.VerticalMirror;
- pdf.SetPDFEditParam(dFEditEvent);
- return dFEditEvent;
- }
- public static DefaultEditProperty SetDefaultEdit()
- {
- DefaultEditProperty defaultEdit = new PDFSettings.DefaultEditProperty();
- defaultEdit.FontName = "Arial";
- defaultEdit.FontSize = 14;
- defaultEdit.TextAlign = TextAlignType.AlignLeft;
- defaultEdit.AutoBlock = true;
- defaultEdit.ClipImage = false;
- defaultEdit.EditType = ComPDFKit.PDFPage.CPDFEditType.EditText;
- defaultEdit.FontColor = System.Windows.Media.Color.FromArgb(255, 0, 0, 0);
- defaultEdit.HorizontalMirror = false;
- defaultEdit.VerticalMirror = false;
- defaultEdit.IsBold = false;
- defaultEdit.IsItalic = false;
- defaultEdit.ReplaceImagePath = null;
- defaultEdit.Rotate = 0;
- defaultEdit.Transparency = 255;
- SettingHelper.SetPDFEditProperty(defaultEdit);
- Settings.Default.Save();
- return defaultEdit;
- }
- }
- }
|