QuestPDF / QuestPDF/QuestPDF

FitArea() needed even though there is enough space

Open
#1,478 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
14.2k
Forks
771
Avg merge
3h 37m
Merged PRs (30d)
11

Description

See attached sample project.

When creating an A5-sized PDF, adding an A5-sized SVG throws DocumentLayoutException. Is this expected? Certainly there is enough space when the SVG has the same size as the PDF? It works if you call FitArea() but why is it needed?

internal class Program
{
    static void Main(string[] args)
    {
        QuestPDF.Settings.License = LicenseType.Evaluation;

        try
        {
            Document.Create(container =>
            {
                container.Page(page =>
                {
                    page.Size(PageSizes.A5);

                    // Size of test.svg is A5 (148x210 mm)
                    page.Content()
                        .Svg(@".\\Resources\\test.svg")
                        // .FitArea()
                        ;
                });
            })
        .GeneratePdf("hello.pdf");
        }
        catch (DocumentLayoutException ex)
        {
            // Unexpected?
            throw;
        }
    }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached QuestPdfTest3.zip sample and its Program.cs reproduction, including the A5 page, A5-sized test.svg, and DocumentLayoutException. Trace SVG layout with and without FitArea(); done means reproducing the behavior and either correcting the sizing issue or documenting the expected handling with a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.