根据可用宽度和字体计算文本高度? [英] Calculate text height based on available width and font?

查看:23
本文介绍了根据可用宽度和字体计算文本高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用 PDFsharp 从数据库中动态创建 PDF 文档.

We are creating PDF documents on the fly from the database using PDFsharp.

我需要知道计算文本区域高度的最佳方法关于使用的字体和可用宽度.

I need to know the best way to calculate the height of the text area based on the font used and the available width.

我需要知道高度,以便在需要时处理分页符.

I need to know the height so I can process page breaks when required.

推荐答案

在 .NET 中,您可以调用Graphics.MeasureString 了解如何绘制的文本会变大.

In .NET you can call Graphics.MeasureString to find out how large the drawn text is going to be.

没错,但是在使用 PDFsharp 时,您调用 XGraphics.MeasureString.

Right, but when using PDFsharp you call XGraphics.MeasureString.

这篇关于根据可用宽度和字体计算文本高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆