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.

Thu Dec 05, 2013 6:30 pm

My question is this: as the length of a text is measured with page.Canvas.DrawString print

Thank you very much.

r1d2m3
 
Posts: 2
Joined: Sat Aug 24, 2013 10:07 pm

Fri Dec 06, 2013 6:04 am

Hello,

Thanks for your inquiry.
Sorry that we don't understand well your question. Is it that using page.Canvas.DrawString function to draw a text based on its length? If so, hope the following code can help you. If not, would you please give us further information? So that we can understand well your question and provide you with a solution soon. Thank you.
Code: Select all
            PdfDocument document = new PdfDocument();
            PdfPageBase page= document.Pages.Add();

            String text = "Go! Turn Around! Go! Go! Go!";
            PdfPen pen = PdfPens.DeepSkyBlue;
            PdfSolidBrush brush = new PdfSolidBrush(Color.White);
            PdfStringFormat format = new PdfStringFormat();
            PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 18f, PdfFontStyle.Italic);

            //Measures a string by using this font.
            SizeF size = font.MeasureString(text, format);

            RectangleF rctg = new RectangleF(10, 50, size.Width, size.Height);

            page.Canvas.DrawString(text, font, pen, brush, rctg, format);

            document.SaveToFile("sample.pdf");


Best regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Dec 09, 2013 7:21 pm

Thanks for the reply.
That was the problem to solve.

r1d2m3
 
Posts: 2
Joined: Sat Aug 24, 2013 10:07 pm

Tue Dec 10, 2013 1:49 am

Hello,

Welcome to write to us again for further problems.

Best regards and have a nice day.
Amy
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF