PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Oct 20, 2018 3:58 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Nov 20, 2012 4:26 pm 
Offline

Joined: Thu Oct 16, 2008 1:54 pm
Posts: 14
MigraDoc / PDFSharp 1.32

Calling AddSpace at the start of a FormattedText block results in the white-space inheriting the underline from the previous block.
Attachment:
File comment: Screen-shot of the bug in action
pdfsharp-underline-bug.png
pdfsharp-underline-bug.png [ 39.64 KiB | Viewed 4107 times ]


To reproduce:
Code:
var para = section.AddParagraph();

var block = para.AddFormattedText();
block.Font.Underline = Underline.Single;
block.Add(new Text("This should be underlined"));

block = para.AddFormattedText();
block.Font.Underline = Underline.None;
block.AddSpace(10);
block.Add(new Text("<-- These spaces should not"));


The problem appears to be in the RenderSpace method of the ParagraphRenderer class. I was able to fix the bug by changing this method to:
Code:
void RenderSpace(Character character)
{
   XUnit width = GetSpaceWidth(character);
   RenderUnderline(width, false);
   RealizeHyperlink(width);
   this.currentXPosition += width;
}


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 21, 2012 3:28 pm 
Offline

Joined: Thu Oct 16, 2008 1:54 pm
Posts: 14
I've attached a simple project to reproduce the problem, using the latest NuGet version of PDFSharp and MigraDoc.


Attachments:
PdfSharpAddSpaceBug-NoLib.zip [3.97 KiB]
Downloaded 446 times
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group