Skip to content

dotkarl/Verify.QuestPDF

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Verify.QuestPDF

Build status NuGet Status

Extends Verify to allow verification of documents via QuestPDF.

Designed to help assert the output of projects using QuestPDF to generate PDFs.

NuGet package

https://nuget.org/packages/Verify.QuestPDF/

Usage

Enable:

public static class ModuleInitializer
{
    [ModuleInitializer]
    public static void Init() =>
        VerifyQuestPdf.Initialize();
}

snippet source | anchor

Code that generates a document

static IDocument GenerateDocument() =>
    Document.Create(container =>
    {
        container.Page(page =>
        {
            page.Size(PageSizes.A5);
            page.Margin(1, Unit.Centimetre);
            page.PageColor(Colors.Grey.Lighten3);
            page.DefaultTextStyle(x => x.FontSize(20));

            page.Header()
                .Text("Hello PDF!")
                .SemiBold().FontSize(36);

            page.Content()
                .Column(x =>
                {
                    x.Item()
                        .Text(Placeholders.LoremIpsum());
                });

            page.Footer()
                .AlignCenter()
                .Text(x =>
                {
                    x.Span("Page ");
                    x.CurrentPageNumber();
                });
        });
    });

snippet source | anchor

Verify a Document

[Test]
public Task VerifyDocument()
{
    var document = GenerateDocument();
    return Verify(document);
}

snippet source | anchor

Results

Metadata

{
  Pages: 1,
  Metadata: {
    CreationDate: DateTime_1,
    ModifiedDate: DateTime_2,
    ImageQuality: 101,
    PdfA: false,
    RasterDpi: 72
  }
}

snippet source | anchor

Pdf as image

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%