christiaanderidder / QuestPDF.Markdown

QuestPDF.Markdown allows rendering markdown into a QuestPDF document
MIT License
29 stars 7 forks source link

Large Embedded image doesn't get rendered #77

Closed idi-dwilson closed 2 months ago

idi-dwilson commented 2 months ago

Large Embedded image doesn't get rendered

Support of embedded images was recently added but anything above 65520 in character length will not get rendered.

In the ParsedMarkdownDocument.DownloadImages method it is checking Uri.IsWellFormedUriString when getting the set of urls to process. Uri.IsWellFormedUriString calls Uri.TryCreate internally which checks a buffer limit constant of 65520 on string length.

Reproduce: Add markdown that contains embedded image where the string length of the Url > 65520.

Actual: A link is rendered in the PDF instead of the embedded image

Expected: There will be a practical limit based on string length were embedding large images as Base64 isn't a good idea but the 65520 limit is just small enough to cause issues.

Versions:

Suggestion: Move the Uri.IsWellFormedUriString check to right before httpClient is used to download from the url but after regex that matches data:image. I would submit PR but I don't have permission to the repository to do so.

christiaanderidder commented 2 months ago

Hi @idi-dwilson,

Thanks for submitting the issue, a fix will be included in the next release.

idi-dwilson commented 2 months ago

Thanks for quick response!