Document: Rename DoubleSided to DoublePaged

This commit is contained in:
2024-03-05 12:19:38 +01:00
parent 95850c1d81
commit d3c232d550
4 changed files with 13 additions and 13 deletions

View File

@ -17,10 +17,10 @@ namespace Elwig.Documents {
protected string? _pdfPath;
protected string? PdfPath => _pdfPath ?? _pdfFile?.FilePath;
public int? TotalPages { get; private set; }
public int? Pages => TotalPages / (DoubleSided ? 2 : 1);
public int? Pages => TotalPages / (DoublePaged ? 2 : 1);
public bool ShowFoldMarks = App.Config.Debug;
public bool DoubleSided = false;
public bool DoublePaged = false;
public string DataPath;
public int CurrentNextSeason;
@ -116,7 +116,7 @@ namespace Elwig.Documents {
progress?.Report(GenerationProportion * 100 * i / n);
}
progress?.Report(GenerationProportion * 100);
var pages = 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, DoublePaged, new Progress<double>(v => progress?.Report(GenerationProportion * 100 + v * (1 - GenerationProportion))));
TotalPages = pages.Pages;
foreach (var tmp in tmpHtmls) {
tmp.Dispose();
@ -127,7 +127,7 @@ namespace Elwig.Documents {
using (var tmpHtml = new TempFile("html")) {
await File.WriteAllTextAsync(tmpHtml.FilePath, await Render(), Utils.UTF8);
progress?.Report(50.0);
var pages = await Pdf.Convert(tmpHtml.FilePath, pdf.FilePath, DoubleSided);
var pages = await Pdf.Convert(tmpHtml.FilePath, pdf.FilePath, DoublePaged);
TotalPages = pages.Pages;
}
_pdfFile = pdf;

View File

@ -10,7 +10,7 @@
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\Document.css"/>
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\Document.Page.css"/>
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\Document.Table.css"/>
@if (Model.DoubleSided) {
@if (Model.DoublePaged) {
<style>
@@page :left {
margin: 25mm 25mm 35mm 20mm;
@ -38,7 +38,7 @@
</div>
<footer>@Raw(Model.Footer)</footer>
</div>
@if (Model.DoubleSided) {
@if (Model.DoublePaged) {
<div class="footer-wrapper left">
<div class="pre-footer">
<span class="page"></span>

View File

@ -49,17 +49,17 @@ namespace Elwig.Helpers.Printing {
return Task.CompletedTask;
}
public static async Task<(int Pages, IEnumerable<int> PerDoc)> Convert(string htmlPath, string pdfPath, bool doubleSided = false, IProgress<double>? progress = null) {
return await Convert([htmlPath], pdfPath, doubleSided, progress);
public static async Task<(int Pages, IEnumerable<int> PerDoc)> Convert(string htmlPath, string pdfPath, bool doublePaged = false, IProgress<double>? progress = null) {
return await Convert([htmlPath], pdfPath, doublePaged, progress);
}
public static async Task<(int Pages, IEnumerable<int> PerDoc)> Convert(IEnumerable<string> htmlPath, string pdfPath, bool doubleSided = false, IProgress<double>? progress = null) {
public static async Task<(int Pages, IEnumerable<int> PerDoc)> Convert(IEnumerable<string> htmlPath, string pdfPath, bool doublePaged = false, IProgress<double>? progress = null) {
if (WinziPrintProc == null) throw new InvalidOperationException("The WinziPrint process has not been initialized yet");
progress?.Report(0.0);
using var client = new TcpClient("127.0.0.1", 30983);
using var stream = client.GetStream();
await stream.WriteAsync(Encoding.UTF8.GetBytes(
"-e utf-8;-p;" + (doubleSided ? "-2;" : "") +
"-e utf-8;-p;" + (doublePaged ? "-2;" : "") +
$"{string.Join(';', htmlPath)};{pdfPath}" +
"\r\n"));
using var reader = new StreamReader(stream);

View File

@ -485,7 +485,7 @@ namespace Elwig.Windows {
.ToDictionary(d => d.Member, m => {
var docs = m.Docs.Select(d => d.Doc).ToList();
foreach (var doc in docs) {
doc!.DoubleSided = false;
doc!.DoublePaged = false;
if (doc is BusinessDocument b)
b.IncludeSender = false;
};
@ -518,7 +518,7 @@ namespace Elwig.Windows {
if (docs.Count == 0 || m.Docs[0].Type == DocType.Custom) {
docs.Insert(0, new Letterhead(m.Member));
}
docs.ForEach(doc => doc.DoubleSided = doublePaged);
docs.ForEach(doc => doc.DoublePaged = doublePaged);
if (docs.Count > 0 && docs[0] is BusinessDocument b)
b.IncludeSender = true;
return docs;
@ -528,7 +528,7 @@ namespace Elwig.Windows {
if (printDocs.Count > 0) {
try {
var print = Document.Merge(printDocs);
print.DoubleSided = doublePaged;
print.DoublePaged = doublePaged;
await print.Generate(new Progress<double>(v => {
ProgressBar.Value = 100.0 * emailNum / totalNum + v * printNum / totalNum;
}));