原創(chuàng)|其它|編輯:郝浩|2012-11-08 14:48:57.000|閱讀 1208 次
概述:單個(gè)對(duì)象會(huì)被轉(zhuǎn)化為Aspose.Pdf DOM(文檔對(duì)象模型),Aspose.Pdf提供了一個(gè)非常驚人的功能,可以訪問(wèn)這些單個(gè)對(duì)象。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
單個(gè)對(duì)象會(huì)被轉(zhuǎn)化為Aspose.Pdf DOM(文檔對(duì)象模型),Aspose.Pdf提供了一個(gè)非常驚人的功能,可以訪問(wèn)這些單個(gè)對(duì)象。假設(shè)需要通過(guò)XML文件生成一個(gè)PDF文檔(在PDF生成之前需要對(duì)這些單個(gè)對(duì)象提供某些特定的格式),或者是想要從一個(gè)XML文檔中導(dǎo)入標(biāo)題,然后將它們轉(zhuǎn)換成所生成的PDF書簽。你將如何實(shí)現(xiàn)呢?下面是個(gè)很簡(jiǎn)單的方法:
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)
結(jié)論
基于上述示例中,可以看到,在輕松實(shí)現(xiàn)的XML文件轉(zhuǎn)換成PDF格式的同時(shí),Aspose.Pdf也提供了一個(gè)簡(jiǎn)單但強(qiáng)大的API,在PDF文檔生成和輸出之前,用于訪問(wèn)和修改這些單個(gè)對(duì)象。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)