public Conv() { IsDrag = new ReactiveProperty <bool>(true).AddTo(Disposable); IsConvertingShare = new ReactiveProperty <bool>(true).AddTo(Disposable); ButtonStart = new AsyncReactiveCommand().AddTo(Disposable); ButtonStart = IsConvertingShare.ToAsyncReactiveCommand(); ButtonStart.Subscribe(async _ => { await Task.Run(() => { using (var Pdf = new iTextSharp()) { Pdf.Output = SaveFile(Path.GetFileName(LastInput), Path.GetDirectoryName(LastInput)); if (Pdf.Output == string.Empty) { return; } Pdf.Open(); foreach (var dp in DataPieces.OrderBy(x => x.page.Value)) { switch (dp.fork) { case DataPiece.Fork.Bitmap: Pdf.AddToPdf(dp.path); break; case DataPiece.Fork.Zip: Pdf.AddToPdf(dp.byteData); break; } } } }); MessageBox.Show("完了"); }); ButtonRemoveAll = new AsyncReactiveCommand().AddTo(Disposable); ButtonRemoveAll = IsConvertingShare.ToAsyncReactiveCommand(); ButtonRemoveAll.Subscribe(async _ => { DataPieces.Clear(); }); }
/// <summary> /// This method consist settings of pdf file /// </summary> /// <param name="ms"></param> /// <param name="doc"></param> public void Settings(MemoryStream ms, iTextSharp.text.Document doc) { PdfWriter.GetInstance(doc, ms); iTextSharp.text.Rectangle rec = new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.A4); doc.SetPageSize(rec); doc.SetMargins(0, 0, 0, 0); doc.Open(); doc.NewPage(); }