Click here to Skip to main content
16,019,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to develop a windows application to generate PDF with the help of pdfsharp.dll file.How to get a line break between the 2 lines in pdf.

Here is my code.

C#
private void button1_Click(object sender, EventArgs e)
{
   PdfDocument pdf = new PdfDocument();
   PdfPage pg = pdf.AddPage();
   XGraphics grp = XGraphics.FromPdfPage(pg);
   grp.MUH = PdfFontEncoding.Unicode;
   grp.MFEH = PdfFontEmbedding.Default;
   XFont ft = new XFont("Microsoft Sans Serif", 15, XFontStyle.Bold);
   grp.DrawString("This is my first pdf", ft, XBrushes.LightGreen, new XRect(0, 0, pg.Width.Point, pg.Height.Point), XStringFormats.TopCenter);
   string pdffilename = "Converting Pdf";
   XPen pn = new XPen(XColors.Blue, 2);
   grp.DrawLine(pn, 2, 80, 612, 80);
   grp.DrawString("Second line", ft, XBrushes.Black, new XRect(0, 0, pg.Width.Point, pg.Height.Point), XStringFormats.TopLeft);
   pdf.Save(pdffilename);
   Process.Start(pdffilename);
}
I would like to generate the output like this
                        This is my first Pdf
----------------------------------------------------------------------------------
Second line
Posted
Updated 22-Dec-14 6:45am
v3
Comments
DamithSL 22-Dec-14 9:06am    
you better include your code block where you adding other lines
Have you tried any of these?[^]

1 solution

Have a look here: PDF Sharp Line Break[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Dec-14 13:43pm    
5ed.
—SA
Maciej Los 22-Dec-14 13:48pm    
Thank you, Sergey ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900