SVGDocument类
句法
C#
VB
Objective-C
C ++
爪哇
[SerializableAttribute()]
上市班级svgdocument:ISVGDOCUMENT,可见的,可见的
@界面ltsvgdocument:nsobject
上市班级svgdocument工具ISVGDOCUMENT,可序列化
例子
此示例将尝试将每个文档的第一页作为SVG加载到文件夹中。如果成功,它将将页面保存为SVG文件。
使用LeadTools;
使用Leadtools.codecs;
使用leadtools.drawing;
使用LeadTools.Forms.documentWriters;
使用LeadTools.svg;
使用leadToolSexamples.Common;
上市空白svgdocumentExample()
{
//输入目录
细绳indir = imagespath.path;
// 输出目录
细绳OUTDIR = path.combine(imagsPath.path,“ svgpages”);
如果(!directory.exists(OutDir))
目录。
使用((var编解码器=新的rastercodecs())
{
//将300设置为加载文档文件的默认值
codecs.options.rasterizedocument.load.resolution = 300;
codecs.throwexceptionsoninvalidimages =错误的;
//从输入目录获取所有文件
foreach((varsrcfilename在目录。
{
console.Writeline(“检查{0}”,srcfileName);
使用((varinfo = codecs.getInformation(srcfilename,错误的))
{
//如果其文档或向量(跳过SVG文件本身),我们可以加载为SVG
如果(info.format!= rasterimageformat.unknown &&//有效格式
info.format!= rasterimageformat.svg &&//不svg
(info.document.isdocumentfile ||// 一个文件
info.vector.isvectorfile))//或向量
{
//尝试将第一页加载为SVG
尝试
{
使用(svgdocument svgdocument = codecs.loadsvg(srcfilename,1,无效的)作为svgdocument)
{
//将其保存到磁盘
细绳name = path.getFilename(srcfileName).replace(“。”,,,,“ - ”);
name = path.changeextension(名称,“ SVG”);
细绳dstfilename = path.combine(oftdir,name);
console.Writeline(“保存到{0}”,dstfileName);
svgdocument.savetofile(dstfileName,,,无效的);
}
}
抓住(异常EX)
{
console.Writeline(ex.message);
}
}
}
}
}
}
进口LeadTools
进口LeadTools.codecs
进口LeadTools.Drawing
进口leadtools.forms.documentwriters
进口LeadTools.svg
上市共享子svgdocumentExample()
'输入目录
暗淡indir作为细绳= common.imagespath.path
' 输出目录
暗淡Outdir作为细绳= path.combine(common.imagespath.path,“ svgpages”)
如果不是Directory.exists(OUTDIR)然后
目录。
结尾如果
使用编解码器作为新的rastercodecs()
'将300设置为加载文档文件的默认值
codecs.options.rasterizedocument.load.resolution = 300
codecs.throwexceptionsoninvalidimages =错误的
'从输入目录获取所有文件
为了每个srcfilename作为细绳在目录。
console.Writeline(“检查{0}”,srcfilename)
使用信息作为codecsimageinfo = codecs.getInformation(srcfilename,,,错误的)
'如果其文档或向量(跳过SVG文件本身),我们可以加载为SVG
如果info.format <> rasterimageformat.unknown并且
info.format <> rasterimageformat.svg并且
(info.document.isdocumentfile要不然
info.vector.isvectorfile)然后
'尝试将第一页加载为SVG
尝试
使用svgdocument作为svgdocument =直播(codecs.loadsvg(srcfilename,1,没有什么),svgdocument)
'将其保存到磁盘
暗淡姓名作为细绳= path.getFilename(srcfileName).replace(“。”,,,,“ - ”)
name = path.changeextension(名称,“ SVG”)
暗淡dstfilename作为细绳= path.combine(Outdir,名称)
console.Writeline(“保存到{0}”,dstfilename)
svgdocument.savetofile(dstfileName,,,没有什么)
结尾使用
抓住前任作为例外
console.Writeline(ex.message)
结尾尝试
结尾如果
结尾使用
下一个
结尾使用
结尾子