1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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;
- defaultEdit.SystemFontNameList = new List<string>();
- SettingHelper.SetPDFEditProperty(defaultEdit);
- Settings.Default.Save();
- return defaultEdit;
- }
- }
- }
|