PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 7:35 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Dec 16, 2009 12:42 pm 
Offline

Joined: Sun Sep 20, 2009 12:55 pm
Posts: 3
Hi!

If you use a GDI-Pen to create a PDF-XPen and draw some lines with it, the produced PDF can't be read by the Acrobat-Reader under some circumstances (it sometimes doesn't complain about it, but the display is still wrong). Other readers (like the Foxit) can do so.

The following code will produce the error:
Code:
//Create a GDI-Pen
Pen pen = new Pen(Color.Gray);
pen.LineJoin = LineJoin.MiterClipped;

//Create a PDF-Pen
XPen xPen = new XPen(pen);

//Create a path (a triangle)
GraphicsPath path = new GraphicsPath(FillMode.Alternate);
path.AddLines(new [] {new Point(5, 5),
                                new Point(30, 30),
                                new Point(5, 30)});
path.CloseFigure();

//Draw the path (gfx = XGraphics)
gfx.DrawPath(xPen, new XGraphicsPath(path.PathPoints, path.PathTypes, XFillMode.Alternate));


The resulting PDF contains a triangle if you open it with the Foxit Reader. Using the Acrobat Reader will show an empty page.

The problem is the LineJoin here. PDF doesn't support MiterClipped as mentioned in the PDF-Reference, chapter 8.4.3.4. While creating a new XPen from a GDI-Pen, line 256 of XPen.cs is executed. It reads
Code:
xpen.LineJoin = (XLineJoin)pen.LineJoin;

In this case, xpen.LineJoin is set to 3. The XGraphicsPdfRenderer outputs the value of LineJoin to the PDF, which is the reason Acrobat Reader doesn't display the line.

Shouldn't there be an exception thrown if one tries to create a XPen with LineJoin == MiterClipped?

Malte


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 41 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