{"id":21477632,"url":"https://github.com/adamfoneil/questpdfutil","last_synced_at":"2025-07-15T10:33:34.430Z","repository":{"id":49359159,"uuid":"487313356","full_name":"adamfoneil/QuestPdfUtil","owner":"adamfoneil","description":"A lightweight HTML to PDF conversion library for QuestPDF","archived":false,"fork":false,"pushed_at":"2022-05-01T14:27:18.000Z","size":3367,"stargazers_count":29,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-06T05:06:24.248Z","etag":null,"topics":["html","pdf-converter"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adamfoneil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-30T15:30:56.000Z","updated_at":"2023-02-23T07:03:35.000Z","dependencies_parsed_at":"2022-09-24T02:43:09.864Z","dependency_job_id":null,"html_url":"https://github.com/adamfoneil/QuestPdfUtil","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamfoneil%2FQuestPdfUtil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamfoneil%2FQuestPdfUtil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamfoneil%2FQuestPdfUtil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamfoneil%2FQuestPdfUtil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamfoneil","download_url":"https://codeload.github.com/adamfoneil/QuestPdfUtil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226033235,"owners_count":17563126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html","pdf-converter"],"created_at":"2024-11-23T11:14:38.072Z","updated_at":"2024-11-23T11:14:38.835Z","avatar_url":"https://github.com/adamfoneil.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[QuestPDF](https://www.questpdf.com/documentation/#introduction) is a really neat library. But in my situation, I need the ability to insert HTML snippets into PDFs, which is not supported functionality. See [QuestPDF issue 134](https://github.com/QuestPDF/QuestPDF/issues/134). To be fair, converting HTML to PDF is wildly complicated if you want to support every CSS feature. There are paid libraries from [Syncfusion](https://help.syncfusion.com/file-formats/pdf/converting-html-to-pdf), for example, that do this. But these libraries tend to have large dependency footprints and do way more than I need.\n\nFortunately, my requirements are pretty modest. This project represents my attempt at PDF conversion from HTML, supporting a very small feature set. There are two main things I needed to do:\n\n- get an XML document (in the form of `XDocument` or `XElement`) from a string, with some forgiveness built-in for certain malformed tags. In my use case, the HTML is not perfectly XHTML-compliant. But I needed a valid XML document before attempting any conversion. This is the `XmlHelper.ToDocument` method below.\n- provide an extension method that works with QuestPDF's `IContainer` that does the actual conversion.\n\nSee this in use in my [test method](https://github.com/adamfoneil/QuestPdfUtil/blob/master/Testing/Cases.cs#L69). Note that I couldn't seem to get a real [unit test working](https://github.com/adamfoneil/QuestPdfUtil/blob/master/Testing/Cases.cs#L22) with a binary comparison of expected and actual PDF outputs. It appears that there are always minor differences between outputs of the same PDF. I've seen this symptom in other PDF libraries, so I figure this is just how it is with PDFs. In any case, I was pretty happy to get this much working.\n\n# Reference\n\n## QuestPdfUtil.QuestPdfHelper [QuestPdfHelper.cs](https://github.com/adamfoneil/QuestPdfUtil/blob/master/QuestPdfUtil/QuestPdfHelper.cs#L8)\n- void [Html](https://github.com/adamfoneil/QuestPdfUtil/blob/master/QuestPdfUtil/QuestPdfHelper.cs#L10)\n (this IContainer container, XDocument document, [ Action\u003cTextSpanDescriptor\u003e spanAction ])\n- void [Html](https://github.com/adamfoneil/QuestPdfUtil/blob/master/QuestPdfUtil/QuestPdfHelper.cs#L13)\n (this IContainer container, string html, [ Dictionary\u003cstring, string\u003e replacements ], [ Action\u003cTextSpanDescriptor\u003e spanAction ])\n- void [Html](https://github.com/adamfoneil/QuestPdfUtil/blob/master/QuestPdfUtil/QuestPdfHelper.cs#L19)\n (this IContainer container, XElement element, [ Action\u003cTextSpanDescriptor\u003e spanAction ])\n\n## QuestPdfUtil.XmlHelper [XmlHelper.cs](https://github.com/adamfoneil/QuestPdfUtil/blob/master/QuestPdfUtil/XmlHelper.cs#L5)\n- XDocument [ToDocument](https://github.com/adamfoneil/QuestPdfUtil/blob/master/QuestPdfUtil/XmlHelper.cs#L7)\n (string input, [ string defaultEnclosingTag ], [ Dictionary\u003cstring, string\u003e? replacements ])\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamfoneil%2Fquestpdfutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamfoneil%2Fquestpdfutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamfoneil%2Fquestpdfutil/lists"}