PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Apr 19, 2024 2:38 pm

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: Tue Feb 02, 2016 1:01 am 
Offline

Joined: Tue Feb 02, 2016 12:41 am
Posts: 1
I have code similar to the following which draws two overlapping rectangles which share the same top-left corner coordinates.

Code:
  PdfDocument document = new PdfDocument();
  PdfPage page = document.AddPage();
  XGraphics gfx = XGraphics.FromPdfPage(page);
  gfx.DrawRectangle(XBrushes.Black, 11, 11, 0.5, 100);
  gfx.DrawRectangle(XBrushes.Red, 11, 11, 100, 0.5);


When I view the resulting PDF at 100% zoom, the top left corners of those rectangles appear to overshoot so that rather than making a clean corner they make a "+" shape.

Attachment:
RectanglesDontAlign.png
RectanglesDontAlign.png [ 8.87 KiB | Viewed 4014 times ]


This effect makes the output of my program look unprofessional. What am I doing wrong? If anyone has any insights I would be most grateful.

I attached a zip with the example source file.


Attachments:
File comment: Source, output pdf, and magnified screenshot showing the effect.
RectanglesDontAlign.zip [7.1 KiB]
Downloaded 337 times
Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 03, 2016 9:08 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Hi!
fatootie wrote:
This effect makes the output of my program look unprofessional.
If you think so.

In my experience Adobe Reader often shows such glitches. It's one pixel off at 100%, it's one pixel of at 1600%, it's one pixel off at 6400%.

Adobe Reader display options may also have an effect on this.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
File looks fine with Chrome, Firefox, Reader (that MS thingy that comes with Windows 10), and Edge.
It looks correct with Adobe Reader 11 if the option "Enhance thin lines" under Preferences => Page Display is off.

It sometimes looks better if you specify the lower corner and use a negative height:
Code:
            gfx.DrawRectangle(XBrushes.Black, 20, 120, 0.5, -100);
            gfx.DrawRectangle(XBrushes.Red, 20, 20.5, 100, -0.5);


At 100% the inverted version looks correct, at 150% the original version looks correct and the inverted version overlaps, at 200% both look correct.
It is an Adobe Reader mystery and I guess you will have to live with it.
AFAIK you cannot control (override) the "Enhance thin lines" from a PDF file.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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: No registered users and 225 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