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
{
///
/// 获取本地配置,并且更新对应属性
///
///
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;
}
///
/// 更新CPDFViewer的属性
///
///
///
///
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();
SettingHelper.SetPDFEditProperty(defaultEdit);
Settings.Default.Save();
return defaultEdit;
}
}
}