PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

XTextFormatter.cs incorrect Layout

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Bug Reports - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
janvee



Joined: 11 Aug 2008
Posts: 1

PostPosted: Mon Aug 11, 2008 3:31 pm    Post subject: XTextFormatter.cs incorrect Layout Reply with quote

When you draw a string containing 2 spaces like "this is me" then in the actual drawing 3 spaces are used. This prohibits exact placing of various sequential strings. The code below contains the fixes marked with "JV-2008-8-11"

Code:
    void CreateLayout()
    {
      double rectWidth = this.layoutRectangle.width;
      double rectHeight = this.layoutRectangle.height - this.cyAscent - this.cyDescent;
      int firstIndex = 0;
      double x = 0, y = 0;
      int count = this.blocks.Count;
      for (int idx = 0; idx < count; idx++)
      {
        Block block = (Block)this.blocks[idx];
        if (block.Type == BlockType.LineBreak)
        {
          if (Alignment == XParagraphAlignment.Justify)
            ((Block)this.blocks[firstIndex]).Alignment = XParagraphAlignment.Left;
          AlignLine(firstIndex, idx - 1, rectWidth);
          firstIndex = idx + 1;
          x = 0;
          y += this.lineSpace;
        }
        else
        {
            double width =  block.Width; //JV-2008-08-11
          if ((x + width <= rectWidth || x == 0) && block.Type != BlockType.LineBreak)
          {
            block.Location = new XPoint(x, y);
              x += width + this.spaceWidth; // JV-2008-08-11
          }
          else
          {
            AlignLine(firstIndex, idx - 1, rectWidth);
            firstIndex = idx;
            y += this.lineSpace;
            if (y > rectHeight)
            {
              block.Stop = true;
              break;
            }
            block.Location = new XPoint(0, y);
            x = width;
          }
        }
      }
      if (firstIndex < count && this.Alignment != XParagraphAlignment.Justify)
        AlignLine(firstIndex, count - 1, rectWidth);
    }
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Bug Reports - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com