PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 8:24 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 Feb 02, 2010 11:16 am 
Offline

Joined: Tue Feb 02, 2010 10:39 am
Posts: 2
PdfSharp version 1.31.

When drawing text to PDF page (using XGraphics created by XGraphics.FromPdfPage), and page direction is XPageDirection.Upwards, the XFontStyle.Underline and XFontStyle.Strikeout styles are not rendered correctly. Corresponding lines are misplaced and look interchanged: strikeout is below baseline, and underline goes through the middle of the letters.

I propose a patch to the PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.DrawString that fixes the bug. Note that line numbers may slightly differ because we've ported PdfSharp sources to .NET 1.1.

Code:
--- C:/TMP/XGraphicsPdfRenderer.cs-revBASE.svn000.tmp.cs   Вт фев  2 14:02:16 2010
+++ D:/projects-svn/cis-forms.net/PdfSharp/PdfSharp.Drawing.Pdf/XGraphicsPdfRenderer.cs   Вт фев  2 13:16:37 2010
@@ -504,7 +504,7 @@
         // TODO: emulate bold by thicker outline
       }
 
-      if (italic && !descriptor.IsBoldFace)
+      if (italic && !descriptor.IsItalicFace)
       {
         // TODO: emulate italic by shearing transformation
       }
@@ -550,14 +550,20 @@
       {
         double underlinePosition = lineSpace * realizedFont.FontDescriptor.descriptor.UnderlinePosition / font.cellSpace;
         double underlineThickness = lineSpace * realizedFont.FontDescriptor.descriptor.UnderlineThickness / font.cellSpace;
-        DrawRectangle(null, brush, x, y - underlinePosition, width, underlineThickness);
+        double underlineRectY = Gfx.PageDirection == XPageDirection.Downwards
+          ? y - underlinePosition
+          : y + underlinePosition - underlineThickness;
+        DrawRectangle(null, brush, x, underlineRectY, width, underlineThickness);
       }
 
       if (strikeout)
       {
         double strikeoutPosition = lineSpace * realizedFont.FontDescriptor.descriptor.StrikeoutPosition / font.cellSpace;
         double strikeoutSize = lineSpace * realizedFont.FontDescriptor.descriptor.StrikeoutSize / font.cellSpace;
-        DrawRectangle(null, brush, x, y - strikeoutPosition - strikeoutSize, width, strikeoutSize);
+        double strikeoutRectY = Gfx.PageDirection == XPageDirection.Downwards
+          ? y - strikeoutPosition
+          : y + strikeoutPosition - strikeoutSize;
+        DrawRectangle(null, brush, x, strikeoutRectY, width, strikeoutSize);
       }
     }


PS. It may be useful to allow attachments in this forum. I've tried with .diff and .txt extensions with no success.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 03, 2010 9:22 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
baSSiLL wrote:
PS. It may be useful to allow attachments in this forum. I've tried with .diff and .txt extensions with no success.


Attachments are allowed (images and archives).


Attachments:
File comment: I'm an attachment
Hello.zip [129 Bytes]
Downloaded 561 times

_________________
Regards
Thomas Hoevel
PDFsharp Team
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 37 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