简体   繁体   English

Flutter pdf 插件长文本不在新行中

[英]Flutter pdf plugin long text is not going in new line

I am using a plugin我正在使用插件

pdf: ^3.7.1 pdf:^3.7.1

On Using Following Code关于使用以下代码

pw.Text(Very Long Text,
    style: pw.TextStyle(
              fontSize: 20,
           ),
),

The very long text is not going in a new line it's going out of the bound of the page.很长的文本没有换行,它超出了页面的范围。 在此处输入图像描述

As you can see the text is cut after reaching the end.如您所见,文本在到达结尾后被剪切。 Even on using paragraph same happened.即使在使用段落时也会发生同样的情况。

That happens because that package can't "go inside" a single widget and split it in order to make it fit the page (or, in other cases, to create a new page).发生这种情况是因为 package 不能“进入”单个小部件并将其拆分以使其适合页面(或者在其他情况下创建新页面)。 You have to either wrap the text yourself and make it a multiline widget, or split the text yourself (maybe using something like CR or LF as separator) and divide it over different widgets.您必须自己包装文本并使其成为多行小部件,或者自己拆分文本(可能使用 CR 或 LF 作为分隔符)并将其划分为不同的小部件。

Wrap your Text in SizedBox and give it a width将您的文本包装在 SizedBox 中并给它一个宽度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM