/* ----------------------------------------------------------------- */ /// /// Save /// /// <summary> /// Saves the PDF document to the specified file path. /// </summary> /// /// <param name="src">Source reader.</param> /// <param name="options">Save options.</param> /// <param name="prev">Action to be invoked before saving.</param> /// <param name="next">Action to be invoked after saving.</param> /// /* ----------------------------------------------------------------- */ public void Save(IDocumentReader src, SaveOption options, Action <Entity> prev, Action <Entity> next) => Invoke(() => { Value.Set(Properties.Resources.MessageSaving, options.Destination); var itext = src ?? Value.Source.GetItext(Value.Query, Value.IO, false); Value.Set(itext.Metadata, itext.Encryption); using (var dest = new SaveAction(itext, Value.Images, options)) dest.Invoke(prev, next); });
/* ----------------------------------------------------------------- */ /// /// SaveAction /// /// <summary> /// Initializes a new instance of the SaveAction class with /// the specified arguments. /// </summary> /// /// <param name="src">Source reader.</param> /// <param name="images">Image collection.</param> /// <param name="options">Save options.</param> /// /* ----------------------------------------------------------------- */ public SaveAction(IDocumentReader src, ImageCollection images, SaveOption options) { Source = src; Images = images; Options = options; }
/* ----------------------------------------------------------------- */ /// /// GetTarget /// /// <summary> /// Gets the target indices according to the specified options. /// </summary> /// /* ----------------------------------------------------------------- */ private IEnumerable <int> GetTarget(SaveOption e) => e.Target == SaveTarget.All ? Images.Count.Make(i => i) : e.Target == SaveTarget.Selected ? Images.GetSelectedIndices().OrderBy(i => i) : new Range(e.Range, Images.Count).Select(i => i - 1);
/* ----------------------------------------------------------------- */ /// /// Save /// /// <summary> /// Saves the PDF document to the specified file path. /// </summary> /// /// <param name="src">Source reader.</param> /// <param name="options">Save options.</param> /// <param name="prev">Action to be invoked before saving.</param> /// <param name="next">Action to be invoked after saving.</param> /// /* ----------------------------------------------------------------- */ public void Save(IDocumentReader src, SaveOption options, Action <Entity> prev, Action <Entity> next) => Invoke(() => {
/* ----------------------------------------------------------------- */ /// /// Extract /// /// <summary> /// Extracts PDF pages saves to a file with the specified options. /// </summary> /// /// <param name="src">Source object.</param> /// <param name="options">Save options.</param> /// /* ----------------------------------------------------------------- */ public static void Extract(this MainFacade src, SaveOption options) => src.Save( null, options, e => src.Backup.Invoke(e), e => src.Value.Set(Properties.Resources.MessageSaved, e.FullName) );