Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.
Fri Mar 08, 2019 2:04 pm
Can Drawline be used to draw a dashed " - - - - - " line instead of a solid line?
-

jspohn
-
- Posts: 6
- Joined: Tue Jan 29, 2019 3:45 pm
Fri Mar 08, 2019 5:57 pm
Did not find any direct method, so I just wrote a loop that constructs short lines with period gaps. Thanks
-

jspohn
-
- Posts: 6
- Joined: Tue Jan 29, 2019 3:45 pm
Mon Mar 11, 2019 3:12 am
Hello,
Thanks for your post.
There is a convenient way like the following sample code. If there is any other questions, just feel free to write back.
- Code: Select all
//Create a pdf document
PdfDocument doc = new PdfDocument();
//Create one page
PdfPageBase page = doc.Pages.Add();
//Draw a dashed line
PdfPen pen = new PdfPen(PdfBrushes.Red, 0.5f);
pen.DashStyle = PdfDashStyle.Custom;
pen.DashPattern = new float[] { 10, 10 };
page.Canvas.DrawLine(pen, new PointF(50, 115), new PointF(270, 115));
//Save the document
doc.SaveToFile("result.pdf");
Sincerely,
Lisa
E-iceblue support team
-


Lisa.Li
-
- Posts: 1536
- Joined: Wed Apr 25, 2018 3:20 am