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.

Tue Jan 28, 2020 4:09 pm

Hi, when im writing into my newly created pdf, i am encountering a text overlapping issue.
Here is part of my code:
I'm trying to add lines from my list to the pdf,

page.Canvas.DrawString(ls[linenumber - 5], new PdfFont(PdfFontFamily.TimesRoman, 9f), new PdfSolidBrush(Color.Black), 5, start+5);
page.Canvas.DrawString(ls[linenumber - 4], new PdfFont(PdfFontFamily.TimesRoman, 9f), new PdfSolidBrush(Color.Black), 5, start+15);
page.Canvas.DrawString(ls[linenumber - 3], new PdfFont(PdfFontFamily.TimesRoman, 9f), new PdfSolidBrush(Color.Black), 5, start+25);
page.Canvas.DrawString(ls[linenumber - 2], new PdfFont(PdfFontFamily.TimesRoman, 9f), new PdfSolidBrush(Color.Black), 5, start+35);
page.Canvas.DrawString(ls[linenumber - 1], new PdfFont(PdfFontFamily.TimesRoman, 9f), new PdfSolidBrush(Color.Black), 5, start+45);
page.Canvas.DrawString(ls[linenumber], new PdfFont(PdfFontFamily.TimesRoman, 9f), new PdfSolidBrush(Color.Black), 5, start+55);

total there are 12 lines, but the result is 6 line overlapping each other, i wonder what did i do wrong.

below is the code i used to create the new document

PdfDocument doc2 = new PdfDocument();
PdfPageBase page = doc2.Pages.Add();
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
PdfMargins margin = new PdfMargins();
margin.Top = unitCvtr.ConvertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Bottom = margin.Top;
margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Right = margin.Left;
PdfSection section = doc2.Sections.Add();
section.PageSettings.Size = PdfPageSize.A4;
section.PageSettings.Margins = margin;
section = doc2.Sections.Add();
section.PageSettings.Margins = margin;


page = section.Pages.Add();

jzhuang94
 
Posts: 4
Joined: Tue Jan 28, 2020 4:01 pm

Tue Jan 28, 2020 5:58 pm

never mind, its fixed

jzhuang94
 
Posts: 4
Joined: Tue Jan 28, 2020 4:01 pm

Wed Jan 29, 2020 4:20 am

Hello,

Thanks for your message.
Glad to hear that you solved the issue. Just feel free to contact us if you need further assistance in the future.
Wish you all the best!

Sincerely,
Lisa
E-iceblue support team
User avatar

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

Return to Spire.PDF

cron