Table of Contents

Class PdfFileUtility

Namespace
PdfSharp.Quality
Assembly
PdfSharp.Quality-gdi.dll

Static helper functions for file IO. These function are intended for unit test und sample in a solution code only.

public static class PdfFileUtility
Inheritance
PdfFileUtility
Inherited Members

Methods

FindLatestPdfTempFile(string?, string, bool)

Finds the latest PDF temporary file in the specified folder, including sub-folders, or null, if no such file exists.

public static string? FindLatestPdfTempFile(string? name, string path, bool recursive = false)

Parameters

name string

The name.

path string

The path.

recursive bool

if set to true [recursive].

Returns

string

GetTempPdfFileName(string?, bool)

Creates a temporary name of a PDF file with the pattern '{namePrefix}-{WIN|WSL|LNX|...}-{...uuid...}_temp.pdf'. The name ends with '_temp.pdf' to make it easy to delete it using the pattern '*_temp.pdf'. No file is created by this function. The name contains 10 hex characters to make it unique. It is not tested whether the file exists, because we have no path here.

public static string GetTempPdfFileName(string? namePrefix, bool addInfo = true)

Parameters

namePrefix string
addInfo bool

Returns

string

GetTempPdfFullFileName(string?, bool)

Creates a temporary file and returns the full name. The name pattern is '.../temp/.../{namePrefix}-{WIN|WSL|LNX|...}-{...uuid...}_temp.pdf'. The namePrefix may contain a sub-path relative to the temp directory. The name ends with '_temp.pdf' to make it easy to delete it using the pattern '*_temp.pdf'. The file is created and immediately closed. That ensures the returned full file name can be used.

public static string GetTempPdfFullFileName(string? namePrefix, bool addInfo = true)

Parameters

namePrefix string
addInfo bool

Returns

string

SaveAndShowDocument(PdfDocument, string, bool)

Save the specified document and shows it in a PDF viewer application.

public static string SaveAndShowDocument(PdfDocument doc, string name, bool addInfo = true)

Parameters

doc PdfDocument
name string
addInfo bool

Returns

string

SaveAndShowDocumentIfDebugging(PdfDocument, string, bool)

Save the specified document and shows it in a PDF viewer application only if the current program is debugged.

public static string SaveAndShowDocumentIfDebugging(PdfDocument doc, string name, bool addInfo = true)

Parameters

doc PdfDocument
name string
addInfo bool

Returns

string

SaveDocument(PdfDocument, string, bool)

Save the specified document and returns the path.

public static string SaveDocument(PdfDocument doc, string name, bool addInfo = true)

Parameters

doc PdfDocument
name string
addInfo bool

Returns

string

ShowDocument(string)

Shows the specified document in a PDF viewer application.

public static void ShowDocument(string pdfFilename)

Parameters

pdfFilename string

The PDF filename.

ShowDocumentIfDebugging(string)

Shows the specified document in a PDF viewer application only if the current program is debugged.

public static void ShowDocumentIfDebugging(string pdfFilename)

Parameters

pdfFilename string

The PDF filename.