Skip to content

Commit 083e1e2

Browse files
Add comments explaining why index.html dummy filename is needed for Scryber path resolution
Agent-Logs-Url: https://github.com/grandnode/grandnode2/sessions/5d2dbad8-02eb-4e9a-90c8-63cd785b237d Co-authored-by: KrzysztofPajak <16772986+KrzysztofPajak@users.noreply.github.com>
1 parent 2b8d760 commit 083e1e2

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/Business/Grand.Business.Common/Services/Pdf/HtmlToPdfService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public async Task PrintOrdersToPdf(Stream stream, IList<Order> orders, string la
4444
var html = await _viewRenderService.RenderToStringAsync(OrderTemplate,
4545
new ValueTuple<IList<Order>, string>(orders, vendorId));
4646
TextReader sr = new StringReader(html);
47+
//Scryber uses Path.GetDirectoryName(LoadedSource) to resolve relative image paths,
48+
//so we must pass a file path (not a directory) rooted in wwwroot.
4749
var basePath = Path.Combine(_webHostEnvironment.WebRootPath, "index.html");
4850
using var doc = Document.ParseDocument(sr, basePath, ParseSourceType.DynamicContent);
4951
doc.SaveAsPDF(stream);
@@ -80,6 +82,8 @@ public async Task PrintPackagingSlipsToPdf(Stream stream, IList<Shipment> shipme
8082

8183
var html = await _viewRenderService.RenderToStringAsync(ShipmentsTemplate, shipments);
8284
TextReader sr = new StringReader(html);
85+
//Scryber uses Path.GetDirectoryName(LoadedSource) to resolve relative image paths,
86+
//so we must pass a file path (not a directory) rooted in wwwroot.
8387
var basePath = Path.Combine(_webHostEnvironment.WebRootPath, "index.html");
8488
using var doc = Document.ParseDocument(sr, basePath, ParseSourceType.DynamicContent);
8589
doc.SaveAsPDF(stream);

0 commit comments

Comments
 (0)