File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33using System . IO ;
44using System . Runtime . InteropServices ;
55using QuestPDF . Fluent ;
6+ using QuestPDF . Previewer ;
67
78namespace QuestPDF . ExampleInvoice
89{
@@ -14,21 +15,32 @@ class Program
1415 /// </summary>
1516 static void Main ( string [ ] args )
1617 {
17- var filePath = "invoice.pdf" ;
18-
1918 var model = InvoiceDocumentDataSource . GetInvoiceDetails ( ) ;
2019 var document = new InvoiceDocument ( model ) ;
20+
21+ // Generate PDF file and show it in the default viewer
22+ //GenerateDocumentAndShow(document);
23+
24+ // Or open the QuestPDF Previewer and experiment with the document's design
25+ // in real-time without recompilation after each code change
26+ document . ShowInPreviewer ( ) ;
27+ }
28+
29+ static void GenerateDocumentAndShow ( InvoiceDocument document )
30+ {
31+ const string filePath = "invoice.pdf" ;
32+
2133 document . GeneratePdf ( filePath ) ;
2234
23- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
35+ var process = new Process
2436 {
25- Process . Start ( "explorer.exe" , filePath ) ;
26- }
27- else
28- {
29- var fullPath = Path . Combine ( Directory . GetCurrentDirectory ( ) , filePath ) ;
30- Console . WriteLine ( $ "Output PDF file is available here: { fullPath } " ) ;
31- }
37+ StartInfo = new ProcessStartInfo ( filePath )
38+ {
39+ UseShellExecute = true
40+ }
41+ } ;
42+
43+ process . Start ( ) ;
3244 }
3345 }
3446}
Original file line number Diff line number Diff line change 77 </PropertyGroup >
88
99 <ItemGroup >
10- <PackageReference Include =" QuestPDF" Version =" 2022.4 .1" />
10+ <PackageReference Include =" QuestPDF" Version =" 2022.6 .1" />
1111 </ItemGroup >
1212
1313</Project >
You can’t perform that action at this time.
0 commit comments