GeneratePdfAndShow, GenerateXpsAndShow
This commit is contained in:
@@ -21,24 +21,20 @@ namespace QuestPDF.ReportSample
|
|||||||
|
|
||||||
var model = DataSource.GetReport();
|
var model = DataSource.GetReport();
|
||||||
Report = new StandardReport(model);
|
Report = new StandardReport(model);
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void GenerateAndShowPdf()
|
|
||||||
{
|
|
||||||
//ImagePlaceholder.Solid = true;
|
//ImagePlaceholder.Solid = true;
|
||||||
|
|
||||||
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"test_result.pdf");
|
|
||||||
Report.GeneratePdf(path);
|
|
||||||
Process.Start("explorer.exe", path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GenerateAndShowXps()
|
public void GeneratePdfAndShow()
|
||||||
{
|
{
|
||||||
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"test_result.xps");
|
Report.GeneratePdfAndShow();
|
||||||
Report.GenerateXps(path);
|
}
|
||||||
Process.Start("explorer.exe", path);
|
|
||||||
|
[Test]
|
||||||
|
public void GenerateXpsAndShow()
|
||||||
|
{
|
||||||
|
Report.GenerateXpsAndShow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using QuestPDF.Drawing;
|
using QuestPDF.Drawing;
|
||||||
using QuestPDF.Infrastructure;
|
using QuestPDF.Infrastructure;
|
||||||
@@ -28,6 +29,13 @@ namespace QuestPDF.Fluent
|
|||||||
DocumentGenerator.GeneratePdf(stream, document);
|
DocumentGenerator.GeneratePdf(stream, document);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void GeneratePdfAndShow(this IDocument document)
|
||||||
|
{
|
||||||
|
var filePath = Path.Combine(Path.GetTempPath(), $"QuestPDF Document.pdf");
|
||||||
|
document.GeneratePdf(filePath);
|
||||||
|
OpenFileUsingDefaultProgram(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region XPS
|
#region XPS
|
||||||
@@ -50,6 +58,13 @@ namespace QuestPDF.Fluent
|
|||||||
DocumentGenerator.GenerateXps(stream, document);
|
DocumentGenerator.GenerateXps(stream, document);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void GenerateXpsAndShow(this IDocument document)
|
||||||
|
{
|
||||||
|
var filePath = Path.Combine(Path.GetTempPath(), $"QuestPDF Document.xps");
|
||||||
|
document.GenerateXps(filePath);
|
||||||
|
OpenFileUsingDefaultProgram(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Images
|
#region Images
|
||||||
@@ -77,5 +92,22 @@ namespace QuestPDF.Fluent
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Helpers
|
||||||
|
|
||||||
|
private static void OpenFileUsingDefaultProgram(string filePath)
|
||||||
|
{
|
||||||
|
var process = new Process
|
||||||
|
{
|
||||||
|
StartInfo = new ProcessStartInfo(filePath)
|
||||||
|
{
|
||||||
|
UseShellExecute = true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
process.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user