Aspose.Pdf如何在PDF文件里创建文本和内联图片

作者:控件中国网   出处:控件中国网   2016-09-20 09:50:12   阅读:6

在很多场合下文本和图片经常需要一起使用,增加客户对文档的阅读性,这种方式一般叫做文本和内联图片,保持文本和图片在同一行,并且可以控制图片和文本的相对位置。Aspose.Pdf是一款功能强大的PDF文档类处理控件,不仅可以创建、编辑和提取PDF文档,还可以转换PDF文档为多种格式,使用该产品开发人员在创建PDF文档时设置图片和文本的内联,可以设置图片在文本的左边或者右边,具体使用代码和效果可以参考下面的详细代码:
<a href=http://www.componentcn.com/kongjianchanpin/PDF/PDFkongjian/2014-09-18/178.html target=_blank class=infotextkey>Aspose PDF</a>.png
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create section object and add it to sections collection of PDF
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
 
// Create a text object
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text();
// Add text object to paragraphs collection of section
sec1.Paragraphs.Add(text1);
// Create segment 2 and add it to segements collection of text object
Aspose.Pdf.Generator.Segment seg2 = text1.Segments.Add();
 
// Create a Image object to contain logo gif.
Aspose.Pdf.Generator.Image img1 = new Aspose.Pdf.Generator.Image();
// Specify the image file path
img1.ImageInfo.File = "logo.png";
// Indicate seg2's InlineParagraph is a image.
seg2.InlineParagraph = img1;
// Add sample text to segments collection of text object
text1.Segments.Add("This is a test for inline");
// Create the result PDF Document
pdf1.Save("InlineImage_out_.pdf");                           
Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat