PeachPDF

PeachPDF.PdfGenerateConfig

PdfGenerateConfig.AllowLocalFileAccess Property

Whether the document may reach the local file system. Defaults to true, preserving the historical behavior in which file: references are read from disk and relative references resolve against the current working directory.

Set to false when rendering untrusted input, or in a host with no meaningful file system (a browser/WebAssembly app). Two things then change: every file: resource request resolves to “not found”, and a NetworkLoader with no BaseUri of its own (DataUriNetworkLoader and MimeKitNetworkLoader are both in this category) no longer inherits the working directory as a base — so a relative reference goes unresolved rather than being turned into a file: URI and read from disk.

This covers every resource the document asks for — <img>, <link rel="stylesheet">, CSS url(), SVG <image href>, and @font-face src: url() — because they all resolve through one place. A deny wins even over an explicitly configured FileUriNetworkLoader.

It does not restrict the root document, which is an input rather than a fetch: an HTML string passed to GeneratePdf, or a file a FileUriNetworkLoader was explicitly constructed with, is still read.

public bool AllowLocalFileAccess { get; set; }

Property Value

System.Boolean