Browse Source

Improved compatibility with texts that contain the carriage return character '\r'.

Marcin Ziąbek 1 year ago
parent
commit
f44d54ac5b

+ 8 - 0
Source/QuestPDF/Elements/Text/TextBlock.cs

@@ -224,11 +224,19 @@ namespace QuestPDF.Elements.Text
                 return;
             
             RebuildParagraphForEveryPage = Items.Any(x => x is TextBlockPageNumber);
+            
+            RemoveCarriageReturnCharacters();
             BuildParagraph();
             
             AreParagraphMetricsValid = false;
         }
 
+        private void RemoveCarriageReturnCharacters()
+        {
+            foreach (var textBlockSpan in Items.OfType<TextBlockSpan>())
+                textBlockSpan.Text = textBlockSpan.Text.Replace("\r", "");
+        }
+
         private void BuildParagraph()
         {
             var paragraphStyle = new ParagraphStyleConfiguration

+ 3 - 0
Source/QuestPDF/Resources/ReleaseNotes.txt

@@ -31,3 +31,6 @@ Version 2024.3.1
 - Enhanced compatibility with dotnet standard projects.
 - Fix: on the Windows platform, the "Could not find an appropriate font fallback for the following glyphs: $U-000D" exception is thrown when the "QuestPDF.Settings.CheckIfAllTextGlyphsAreAvailable" is set true, and the "TextDescriptor.Line" method is used (that inserts the '\r' character).
 - Fix: resolved an issue where the positioning of hyperlinks was incorrect when text contained injected block items.
+
+Version 2024.3.2
+- Improved compatibility with texts that contain the carriage return character '\r'.