[#15] MailWindow: Add feature to print
This commit is contained in:
@ -16,6 +16,8 @@ namespace Elwig.Documents {
|
||||
protected TempFile? _pdfFile = null;
|
||||
protected string? _pdfPath;
|
||||
protected string? PdfPath => _pdfPath ?? _pdfFile?.FilePath;
|
||||
public int? TotalPages { get; private set; }
|
||||
public int? Pages => TotalPages / (DoubleSided ? 2 : 1);
|
||||
|
||||
public bool ShowFoldMarks = App.Config.Debug;
|
||||
public bool DoubleSided = false;
|
||||
@ -114,7 +116,8 @@ namespace Elwig.Documents {
|
||||
progress?.Report(GenerationProportion * 100 * i / n);
|
||||
}
|
||||
progress?.Report(GenerationProportion * 100);
|
||||
await Pdf.Convert(tmpFiles, pdf.FileName, DoubleSided, new Progress<double>(v => progress?.Report(GenerationProportion * 100 + v * (1 - GenerationProportion))));
|
||||
var pages = await Pdf.Convert(tmpFiles, pdf.FileName, DoubleSided, new Progress<double>(v => progress?.Report(GenerationProportion * 100 + v * (1 - GenerationProportion))));
|
||||
TotalPages = pages.Pages;
|
||||
foreach (var tmp in tmpHtmls) {
|
||||
tmp.Dispose();
|
||||
}
|
||||
@ -124,7 +127,8 @@ namespace Elwig.Documents {
|
||||
using (var tmpHtml = new TempFile("html")) {
|
||||
await File.WriteAllTextAsync(tmpHtml.FilePath, await Render(), Utils.UTF8);
|
||||
progress?.Report(50.0);
|
||||
await Pdf.Convert(tmpHtml.FilePath, pdf.FilePath, DoubleSided);
|
||||
var pages = await Pdf.Convert(tmpHtml.FilePath, pdf.FilePath, DoubleSided);
|
||||
TotalPages = pages.Pages;
|
||||
}
|
||||
_pdfFile = pdf;
|
||||
}
|
||||
|
Reference in New Issue
Block a user