PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jun 16, 2024 2:13 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed May 23, 2012 7:23 pm 
Offline

Joined: Wed May 23, 2012 7:17 pm
Posts: 2
Hi,

I have a question. I'm trying to create a PDF that has a text layout rectangle to insert text into. This layout rectangle should be COMPLETELY transparent. Including the border. It should be invisible. I just need to use it to layout and align text inside of to force the text to wrap to a new line if it runs outside the dimensions of the rectangle. I've run into an issue with the DrawString() method ...

... when using a container rectangle inside the graphics.DrawString() method, it automatically creates a tiny little border around my layout rectangle despite drawing the rectangle with XPens.Transparent. It makes the INSIDE of the rectangle transparent, but it does NOT remove the tiny white border around it.

If I could figure out how to wrap text using DrawString WITHOUT laying it out inside a container rectangle that would work! I need my text to wrap that's why I have to use a container rectangle, which is the issue...I can't get the container rectangle's border to be transparent.

In another section of the page, I'm using a container rectangle to layout an image. It works fine, but thats using DrawImage() method, not DrawString(). I have to use DrawString() method here because I'm just outputting text inside the rectangle so DrawImage() won't work...please advise.

Here's my code snippet that does this..

Code:

                    XRect practiceNameContainer = new XRect(420, 595, 120, 120);
                    gfx.DrawRectangle(XPens.Transparent, practiceNameContainer);

                 
                    XTextFormatter textFormatter = new XTextFormatter(gfx);
                    textFormatter.DrawString(this.PracticeName, font, XBrushes.Black, practiceNameContainer, XStringFormats.TopLeft);



Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2012 8:00 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
Hi!

I haven't tried it, but adding "//" in front of "gfx.DrawRectangle" should do the trick.

AFAIK the container is the XRect (that's what you pass to DrawString) and not the drawn rectangle. So do not draw the rectangle, that should to the trick.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2012 2:29 pm 
Offline

Joined: Wed May 23, 2012 7:17 pm
Posts: 2
Thanks for the reply....I found out yesterday you are absolutely correct! Stumbled upon that myself. Not sure why I was trying to draw the rectangle also...but it is strange that the DrawRectangle() method draws the rectangle with a black border even if the pen or brush used to draw the rectangle is a transparent one, or is an ARGB one with alpha set to 0 for full transparency....is that a bug or what?

Thanks!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 153 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