AlivePDF 中的自动换行

发布于 2024-08-21 22:55:06 字数 2259 浏览 10 评论 0原文

当我显示一些文本时,它只会出现在 1 行中,这就是原因 整个文本在 pdf 中不可见。 如果 txt 更多,它应该自动采取下一行。 请参阅下面的代码

<?xml version="1.0" encoding="utf-8"?>
 <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="horizontal" >
    <mx:Script>
        <![CDATA[
           import org.alivepdf.pdf.PDF;
            import org.alivepdf.saving.Method;
            import org.alivepdf.fonts.*;
            import org.alivepdf.pages.Page;
             import org.alivepdf.display.Display;
             import org.alivepdf.layout.*;

    [Bindable] private var message:String;
   private var pdf:PDF;
            private var file:File;
            private function submitData():void {
            message+='The Text Value is ' + t1.text + ' The second
text value is' + t2.text +
                        'it is testing message it is testing message it is
testing message '+
                        'The Text Value is ' + t1.text + ' The second text value
is' + t2.text+
                        'it is testing message it is testing message it is
testing message ';
            }

             public function generate ():void
             {
                submitData();

             var pdf:PDF = new PDF( Orientation.PORTRAIT, Unit.MM,
Size.A4 );
                 pdf.setDisplayMode( Display.FULL_PAGE,
Layout.SINGLE_PAGE );
                var newPage:Page = new Page (Orientation.PORTRAIT,
Unit.MM, Size.A4 );
                pdf.addPage( newPage );
                //pdf.setFont(IFont,12);
                pdf.addText(message,5,15);
                pdf.addPage();
                var fs:FileStream = new FileStream();
                file =
File.desktopDirectory.resolvePath("testPage.pdf");
                fs.open( file, FileMode.WRITE);
                var bytes:ByteArray = pdf.save(Method.LOCAL);
                                 fs.writeBytes(bytes);
                fs.close();
             }
        ]]>
    </mx:Script>

    <mx:TextInput id="t1"  text="txt111" />
    <mx:TextInput id="t2"  text="txt222"/>
   <mx:Button click="generate()" label="Generate PDF"
horizontalCenter="0" verticalCenter="0"/>

    </mx:WindowedApplication>

是在 pdf 中显示文本的任何解决方案,我们是否也可以为我们的字体提供字体大小 文本 ? 谢谢

when i am showing some text it is going in 1 line only thats why
whole text is not visible in pdf.
if txt are more it should take automatically next line.
please see code below

<?xml version="1.0" encoding="utf-8"?>
 <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="horizontal" >
    <mx:Script>
        <![CDATA[
           import org.alivepdf.pdf.PDF;
            import org.alivepdf.saving.Method;
            import org.alivepdf.fonts.*;
            import org.alivepdf.pages.Page;
             import org.alivepdf.display.Display;
             import org.alivepdf.layout.*;

    [Bindable] private var message:String;
   private var pdf:PDF;
            private var file:File;
            private function submitData():void {
            message+='The Text Value is ' + t1.text + ' The second
text value is' + t2.text +
                        'it is testing message it is testing message it is
testing message '+
                        'The Text Value is ' + t1.text + ' The second text value
is' + t2.text+
                        'it is testing message it is testing message it is
testing message ';
            }

             public function generate ():void
             {
                submitData();

             var pdf:PDF = new PDF( Orientation.PORTRAIT, Unit.MM,
Size.A4 );
                 pdf.setDisplayMode( Display.FULL_PAGE,
Layout.SINGLE_PAGE );
                var newPage:Page = new Page (Orientation.PORTRAIT,
Unit.MM, Size.A4 );
                pdf.addPage( newPage );
                //pdf.setFont(IFont,12);
                pdf.addText(message,5,15);
                pdf.addPage();
                var fs:FileStream = new FileStream();
                file =
File.desktopDirectory.resolvePath("testPage.pdf");
                fs.open( file, FileMode.WRITE);
                var bytes:ByteArray = pdf.save(Method.LOCAL);
                                 fs.writeBytes(bytes);
                fs.close();
             }
        ]]>
    </mx:Script>

    <mx:TextInput id="t1"  text="txt111" />
    <mx:TextInput id="t2"  text="txt222"/>
   <mx:Button click="generate()" label="Generate PDF"
horizontalCenter="0" verticalCenter="0"/>

    </mx:WindowedApplication>

is any solution to show text in pdf, can we give font size also to our
text ?
thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

卸妝后依然美 2024-08-28 22:55:06

addText 不换行。请改用 writeText 方法。

来自文档

addText() 方法将在给定坐标处输出文本。 不进行自动换行

链接页面包含这两种方法的代码示例。

The addText doesn't wrap. Use writeText method instead.

From the docs:

The addText() method will put out text at a given coordinate. No word wrapping is done.

The linked page has code samples for both methods.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文