原創|其它|編輯:郝浩|2012-11-08 14:48:57.000|閱讀 1208 次
概述:單個對象會被轉化為Aspose.Pdf DOM(文檔對象模型),Aspose.Pdf提供了一個非常驚人的功能,可以訪問這些單個對象。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
單個對象會被轉化為Aspose.Pdf DOM(文檔對象模型),Aspose.Pdf提供了一個非常驚人的功能,可以訪問這些單個對象。假設需要通過XML文件生成一個PDF文檔(在PDF生成之前需要對這些單個對象提供某些特定的格式),或者是想要從一個XML文檔中導入標題,然后將它們轉換成所生成的PDF書簽。你將如何實現呢?下面是個很簡單的方法:
C#
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); //Object xmlDoc contains all contents from original word document in XML format defined in Aspose.PDF //XML Schema. pdf.BindXML(xmlDoc, null); //Before saving, to add bookmarks from headings. pdf.IsBookmarked = true; foreach (Aspose.Pdf.Generator.Section sec in pdf.Sections) { foreach (Aspose.Pdf.Generator.Paragraph para in sec.Paragraphs) { if (para is Aspose.Pdf.Generator.Heading) { Aspose.Pdf.Generator.Heading h = para as Aspose.Pdf.Generator.Heading; h.IsInList = true; } } } pdf.Save(outputFile);
VB.NET
Dim pdf As Aspose.Pdf.Generator.Pdf = New Aspose.Pdf.Generator.Pdf() 'Object xmlDoc contains all contents from original word document in XML format defined in Aspose.PDF 'XML Schema. pdf.BindXML(xmlDoc,Nothing) 'Before saving, to add bookmarks from headings. pdf.IsBookmarked = True Dim sec As Aspose.Pdf.Generator.Section For Each sec In pdf.Sections Dim para As Aspose.Pdf.Generator.Paragraph For Each para In sec.Paragraphs If TypeOf para Is Aspose.Pdf.Generator.Heading Then Dim h As Aspose.Pdf.Generator.Heading = para as Aspose.Pdf.Generator.Heading h.IsInList = True End If Next Next pdf.Save(outputFile)
結論
基于上述示例中,可以看到,在輕松實現的XML文件轉換成PDF格式的同時,Aspose.Pdf也提供了一個簡單但強大的API,在PDF文檔生成和輸出之前,用于訪問和修改這些單個對象。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網