Files
QuestPDF/Source/QuestPDF.Examples/Engine/Helpers.cs
T

22 lines
596 B
C#
Raw Normal View History

using System;
using System.Diagnostics;
using System.IO;
using QuestPDF.Fluent;
using QuestPDF.Infrastructure;
namespace QuestPDF.Examples.Engine
{
public static class Helpers
{
public static void GeneratePdfAndOpen(this Document document, string? fileName = null)
{
fileName ??= $"{Guid.NewGuid():D}.pdf";
var filePath = Path.GetTempPath() + fileName;
var documentData = document.GeneratePdf();
File.WriteAllBytes(filePath, documentData);
Process.Start("explorer", filePath);
}
}
}