彩票走势图

使用Aspose.Pdf在PDF文件中调整文本

原创|其它|编辑:郝浩|2012-11-06 16:26:31.000|阅读 1892 次

概述:在本文中,我们将向您展示如何在PDF文件文本字段中调整文本。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

在本文中,我们将向您展示如何在PDF文件文本字段中调整文本。

Aspose.Pdf中的FormEditor类提供了修改一个PDF表单字段的功能。现在,如果你的要求是为了调整文本字段中的文本,使用FormFieldFacade枚举中的AlignJustified值,并调用FormEditor.DecorateField方法,就可以实现该要求。下面给出具体应用实列:

C#

using (FileStream source = File.Open("source.pdf", FileMode.Open))
{
    MemoryStream ms = new MemoryStream();

    //Create Form Object
    Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();

    //Open Source File
    form.BindPdf(source);

    //Fill Text Field
    form.FillField("Text1", "Thank you for using Aspose");
    
    //Save the document in Memory Stream
    form.Save(ms);
    
    ms.Seek(0, SeekOrigin.Begin);

    FileStream dest = new FileStream("destination.pdf", FileMode.Create);

    //Create formEditor Object
    FormEditor formEditor = new FormEditor();

    //Open PDF from memory stream
    formEditor.BindPdf(ms);

    //Set Text Alignment as Justified
    formEditor.Facade.Alignment = FormFieldFacade.AlignJustified;

    //Decorate form field.
    formEditor.DecorateField();

    //Save te resultant file.
    formEditor.Save(dest);

    //close file stream
    dest.Close();
}

VB.NET

Using source As FileStream = File.Open("source.pdf", FileMode.Open)
    Dim ms As New MemoryStream()

    'Create Form Object
    Dim form As New Aspose.Pdf.Facades.Form()

    'Open Source File
    form.BindPdf(source)

    'Fill Text Field
    form.FillField("Text1", "Thank you for using Aspose")

    'Save the document in Memory Stream
    form.Save(ms)

    ms.Seek(0, SeekOrigin.Begin)

    Dim dest As New FileStream("destination.pdf", FileMode.Create)

    'Create formEditor Object
    Dim formEditor As New FormEditor()

    'Open PDF from memory stream
    formEditor.BindPdf(ms)

    'Set Text Alignment as Justified
    formEditor.Facade.Alignment = FormFieldFacade.AlignJustified

    'Decorate form field.
    formEditor.DecorateField()

    'Save te resultant file.
    formEditor.Save(dest)

    'close file stream
    dest.Close()
End Using
 

 


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP