翻譯|使用教程|編輯:李顯亮|2020-06-29 11:40:42.663|閱讀 304 次
概述:在本文中,我們將看到如何 將PDF保存為SVG圖片。該文將詳細介紹如何使用C#/VB.NET添加SVG圖片到PDF和將SVG圖片保存為PDF。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Spire.PDF是一個PDF庫,其中包含令人難以置信的豐富功能,可以在.NET,Silverlight和WPF平臺上創建,讀取,編輯和處理PDF文檔。作為獨立的PDF庫,它不需要用戶安裝Adobe Acrobat或任何其他第三方庫。
在本文中,我們將看到如何 將PDF保存為SVG圖片。該文將詳細介紹如何使用C#/VB.NET添加SVG圖片到PDF和將SVG圖片保存為PDF。
將SVG圖片保存為PDF
源SVG圖片如下:
C#
using Spire.Pdf; namespace SVGtoPDF { class Program { static void Main(string[] args) { PdfDocument doc = new PdfDocument(); doc.LoadFromSvg("Sample.svg"); doc.SaveToFile("Result.pdf", FileFormat.PDF); } } }
VB.NET
Imports Spire.Pdf Namespace SVGtoPDF Class Program Private Shared Sub Main(ByVal args() As String) Dim doc As PdfDocument = New PdfDocument doc.LoadFromSvg("Sample.svg") doc.SaveToFile("Result.pdf", FileFormat.PDF) End Sub End Class End Namespace
效果圖
添加SVG圖片到PDF
將已有的SVG圖片插入到PDF時,我們還可以設置SVG圖片的位置和大小:
C#
using Spire.Pdf; using Spire.Pdf.Graphics; using System.Drawing; namespace AddSVGImagetoPDF { class Program { static void Main(string[] args) { PdfDocument doc1 = new PdfDocument(); doc1.LoadFromSvg("Sample.svg"); PdfDocument doc2 = new PdfDocument(); doc2.LoadFromFile("Sample2.pdf"); PdfTemplate template = doc1.Pages[0].CreateTemplate(); //template.Draw(doc2.Pages[0].Canvas, new PointF()); //設置圖片位置和大小 doc2.Pages[0].Canvas.DrawTemplate(doc1.Pages[0].CreateTemplate(), new PointF(80, 80), new SizeF(300, 300)); doc2.SaveToFile("Result0.pdf", FileFormat.PDF); } } }
VB.NET
Imports Spire.Pdf Imports Spire.Pdf.Graphics Imports System.Drawing Namespace AddSVGImagetoPDF Class Program Private Shared Sub Main(ByVal args() As String) Dim doc1 As PdfDocument = New PdfDocument doc1.LoadFromSvg("Sample.svg") Dim doc2 As PdfDocument = New PdfDocument doc2.LoadFromFile("Sample2.pdf") Dim template As PdfTemplate = doc1.Pages(0).CreateTemplate 'template.Draw(doc2.Pages[0].Canvas, new PointF()); '設置圖片位置和大小 doc2.Pages(0).Canvas.DrawTemplate(doc1.Pages(0).CreateTemplate, New PointF(80, 80), New SizeF(300, 300)) doc2.SaveToFile("Result0.pdf", FileFormat.PDF) End Sub End Class End Namespace
效果圖
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn