←选择平台

创建(CreateDocumentOptions)方法

总结

创建一个新的空虚拟文档。

语法
c#
VB
c++
Java
公共共享函数创建(按值传递选项作为CreateDocumentOptions)作为LEADDocument
公共静态文档创建(CreateDocumentOptions选项)

参数

选项

在创建文档时使用的选项。不能

返回值

新创建的文档。

讲话

创建一个新的空虚拟文档准备充满页面从其他文档。

这种方法会增加项目的关键“创建”、“访问”和“修改”元数据值等于当前日期和时间。新创建的LEADDocument对象将有一个空的列表页面。它可以由用户填充。

的成员选项使用如下:

成员 描述
缓存UseCache 用于确定新创建的文件将被保存在缓存中。
CachePolicy
如果使用缓存:复制到新创建的文档和用于确定当文档及其项目从缓存中清除。
MimeType
复制到新创建的文档MimeType成员。这个值可以但建议你将它设置为文档的MIME类型,因为它将在保存文档时使用。使用MIME类型中定义的常数之一常量类。在虚拟文件的情况下,这个值可以离开

例子
c#
VB
使用Leadtools;使用Leadtools.Codecs;使用Leadtools.Document.Writer;使用Leadtools.Document;使用Leadtools.Caching;使用Leadtools.Annotations.Engine;使用Leadtools.Ocr;使用Leadtools.Barcode;使用Leadtools.Document.Converter;公共无效DocumentFactoryCreateExample (){var缓存= GetCache ();/ /创建一个新的文档varcreateOptions =CreateDocumentOptions ();createOptions。缓存=缓存;字符串documentId =;使用(LEADDocument文档= DocumentFactory.Create (createOptions)){文档。Name =“虚拟”;/ /应该0页面和文档System.Diagnostics.Debug.Assert (document.Pages。数= = 0);System.Diagnostics.Debug.Assert (document.Documents。数= = 0);/ /添加页面从PDF文件1和2LoadDocumentOptions loadOptions =LoadDocumentOptions ();loadOptions。缓存=缓存;LEADDocument childDocument = DocumentFactory.LoadFromFile (Path.Combine (LEAD_VARS.ImagesDir“Leadtools.pdf”),loadOptions);/ /不处理子文档,但将其保存在缓存中/ /这是可选的,在这个例子中,因为我们将尝试重新加载代码父文档/ /从缓存中——和孩子文档应该在缓存中childDocument.SaveToCache ();/ /添加页面document.Pages.Add (childDocument.Pages [0]);document.Pages.Add (childDocument.Pages [1]);/ /添加一个空白页vardocumentPage = document.Pages.CreatePage (LeadSizeD.Create (LEADDocument。LEADDocument UnitsPerInch * 8.5。UnitsPerInch * 11), 300);document.Pages.Add (documentPage);/ /添加页面从TIF文件3和4childDocument = DocumentFactory.LoadFromFile (Path.Combine (LEAD_VARS.ImagesDir“ocr1.tif”),loadOptions);/ /还保存在缓存中childDocument.SaveToCache ();/ /添加页面document.Pages.Add (childDocument.Pages [0]);document.Pages.Add (childDocument.Pages [0]);/ /应该有5页,2文档(PDF和TIF)System.Diagnostics.Debug.Assert (document.Pages。数= = 5);System.Diagnostics.Debug.Assert (document.Documents。数= = 2);/ /告诉父文档处理任何的孩子当父母处理的文档文档。AutoDisposeDocuments =真正的;/ /显示该文档的信息,应该说5页Console.WriteLine (“原始文档信息”);PrintOutDocumentInfo(文档);/ /保存,父文档到缓存document.SaveToCache ();/ /告诉所有文件不删除自己从缓存中文档。AutoDeleteFromCache =;/ /保存ID所以我们可以加载它documentId = document.DocumentId;}/ /现在,从缓存中加载文档varloadFromCacheOptions =LoadFromCacheOptions ();loadFromCacheOptions。缓存=缓存;loadFromCacheOptions。文档Id = documentId;使用(LEADDocument文档= DocumentFactory.LoadFromCache (loadFromCacheOptions)){/ /应该有5页,2文档(PDF和TIF)System.Diagnostics.Debug.Assert (document.Pages。数= = 5);System.Diagnostics.Debug.Assert (document.Documents。数= = 2);/ /显示该文档的信息,应该还说5页Console.WriteLine (“从缓存加载信息”);PrintOutDocumentInfo(文档);/ /删除第一页document.Pages.RemoveAt (0);/ /删除最后一页document.Pages.RemoveAt (document.Pages。数- 1);/ /应该有3页,2文档(PDF和TIF)System.Diagnostics.Debug.Assert (document.Pages。数= = 3);System.Diagnostics.Debug.Assert (document.Documents。数= = 2);Console.WriteLine (“在删除前2页”);PrintOutDocumentInfo(文档);/ /从缓存中删除本文档及其所有的孩子当我们处理文档。AutoDeleteFromCache =真正的;}}公共无效PrintOutDocumentInfo (LEADDocument文档){Console.WriteLine (“一般”);Console.WriteLine (DocumentId:“+ document.DocumentId);如果(文档。Uri ! =)Console.WriteLine (”Uri:“+ document.Uri);Console.WriteLine (名称:“+ document.Name);Console.WriteLine (”CacheStatus:“+ document.CacheStatus);Console.WriteLine (”LastCacheSyncTime:“+ document.LastCacheSyncTime);Console.WriteLine (”IsReadOnly:“+ document.IsReadOnly);Console.WriteLine (”IsLocal:“+ document.IsLocal);Console.WriteLine (MimeType:“+ document.MimeType);Console.WriteLine (”IsEncrypted:“+ document.IsEncrypted);Console.WriteLine (”IsDecrypted:“+ document.IsDecrypted);Console.WriteLine (“用户数据:“+ document.UserData);Console.WriteLine (“缓存”);Console.WriteLine (”HasCache:“+ document.HasCache);Console.WriteLine (”AutoDeleteFromCache:“+ document.AutoDeleteFromCache);Console.WriteLine (“元数据”);foreach(vardocument.Metadata)Console.WriteLine (“{0}{1}”,项目。键,item.Value);Console.WriteLine (“文件”);Console.WriteLine (“数:”+ document.Documents.Count);foreach(varchildDocumentdocument.Documents){Console.WriteLine (名称:“+ childDocument.Name);}Console.WriteLine (“页面”);Console.WriteLine (“数:”+ document.Pages.Count);(varpageNumber = 1;pageNumber < = document.Pages.Count;pageNumber + +){var文档页面=。页面[pageNumber - 1];Console.WriteLine (”PageNumber:“+ pageNumber);Console.WriteLine (”OriginalPageNumber:“+ page.OriginalPageNumber);Console.WriteLine (”OriginalDocumentName:“+ page.Document.Name);Console.WriteLine (“大小:{0}”,page.Size);}Console.WriteLine (“- - - - - - - - - -”);}公共ObjectCache GetCache (){/ /创建一个LEADTOOLS FileCache对象varcacheDir = Path.Combine (LEAD_VARS.ImagesDir,“缓存”);如果(Directory.Exists (cacheDir))Directory.Delete (cacheDir真正的);Directory.CreateDirectory (cacheDir);var缓存=FileCache ();缓存。缓存Directory = cacheDir;返回缓存;}静态LEAD_VARS{公共常量字符串ImagesDir =@“C: \ LEADTOOLS21 \ Resources \图片”;}静态LEAD_VARS{公共常量字符串ImagesDir =@“C: \ LEADTOOLS21 \ Resources \图片”;}
进口Leadtools进口Leadtools.Codecs进口Leadtools.Document.Writer进口Leadtools.Svg进口Leadtools.Document进口Leadtools.Caching进口Leadtools.Annotations.Engine进口Leadtools.Barcode进口Leadtools.Ocr进口LeadtoolsDocumentExamples.LeadtoolsExamples.Common进口Leadtools.Document.Converter公共DocumentFactoryCreateExample ()昏暗的缓存作为ObjectCache = GetCache ()创建一个新文档昏暗的createOptions作为CreateDocumentOptions ()createOptions。缓存=缓存昏暗的documentId作为字符串=没有什么使用文档作为LEADDocument = DocumentFactory.Create (createOptions)文档。Name =“虚拟”'应该0页面和文档System.Diagnostics.Debug.Assert (document.Pages。= 0)System.Diagnostics.Debug.Assert (document.Documents。= 0)“添加页面从PDF文件1和2昏暗的loadOptions作为LoadDocumentOptions ()loadOptions。缓存=缓存昏暗的childDocument作为LEADDocument = DocumentFactory.LoadFromFile (Path.Combine (ImagesPath.Path“Leadtools.pdf”),loadOptions)不处理子文档,但将其保存在缓存中“这是可选的,在这个例子中,因为我们将尝试重新加载代码父文档“从缓存中——和孩子文档应该在缓存中childDocument.SaveToCache ()“现在添加页面document.Pages.Add (childDocument.Pages (0))document.Pages.Add (childDocument.Pages (1))添加一个空白页昏暗的documentPage作为Leadtools.Document。文档Page = document.Pages.CreatePage(LeadSizeD.Create(LEADDocument.UnitsPerInch * 8.5, LEADDocument.UnitsPerInch * 11), 300)document.Pages.Add (documentPage)“添加页面从TIF文件3和4childDocument = DocumentFactory.LoadFromFile (Path.Combine (ImagesPath.Path“Ocr.tif”),loadOptions)也将其保存在缓存中childDocument.SaveToCache ()“现在添加页面document.Pages.Add (childDocument.Pages (2))document.Pages.Add (childDocument.Pages (3))“应该有5页和2文件(PDF和TIF)System.Diagnostics.Debug.Assert (document.Pages。= 5)System.Diagnostics.Debug.Assert (document.Documents。= 2)“告诉父文档处理任何的孩子当父母处理的文档文档。AutoDisposeDocuments =真正的显示该文档的信息,应该说5页Console.WriteLine (“原始文档信息”)PrintOutDocumentInfo(文档)“现在保存,父文档到缓存document.SaveToCache ()并告诉所有文件不删除自己从缓存中文档。AutoDeleteFromCache =“拯救ID所以我们可以加载它documentId = document.DocumentId结束使用“现在,从缓存中加载文档昏暗的loadFromCacheOptions作为LoadFromCacheOptionsloadFromCacheOptions。缓存=缓存loadFromCacheOptions。文档Id = documentId使用文档作为LEADDocument = DocumentFactory.LoadFromCache (loadFromCacheOptions)“应该有5页和2文件(PDF和TIF)System.Diagnostics.Debug.Assert (document.Pages。= 5)System.Diagnostics.Debug.Assert (document.Documents。= 2)显示该文档的信息,应该还说5页Console.WriteLine (“从缓存加载信息”)PrintOutDocumentInfo(文档)“删除第一页document.Pages.RemoveAt (0)删除最后一页document.Pages.RemoveAt (document.Pages。- 1)“应该有3页和2文件(PDF和TIF)System.Diagnostics.Debug.Assert (document.Pages。= 3)System.Diagnostics.Debug.Assert (document.Documents。= 2)Console.WriteLine (“在删除前2页”)PrintOutDocumentInfo(文档)“从缓存中删除本文档及其所有的孩子当我们处理文档。AutoDeleteFromCache =真正的结束使用结束公共共享PrintOutDocumentInfo (按值传递文档作为LEADDocument)Console.WriteLine (“一般”)Console.WriteLine (DocumentId:“+ document.DocumentId)如果没有(document.Uri)然后Console.WriteLine (”Uri:“+ document.Uri.ToString ())其他的Console.WriteLine (名称:“+ document.Name)结束如果Console.WriteLine (”CacheStatus:“+ document.CacheStatus.ToString ())Console.WriteLine (”LastCacheSyncTime:“+ document.LastCacheSyncTime.ToString ())Console.WriteLine (”IsReadOnly:“+ document.IsReadOnly.ToString ())Console.WriteLine (”IsLocal:“+ document.IsLocal.ToString ())Console.WriteLine (MimeType:“+ document.MimeType)Console.WriteLine (”IsEncrypted:“+ document.IsEncrypted.ToString ())Console.WriteLine (”IsDecrypted:“+ document.IsDecrypted.ToString ())如果没有(document.UserData)然后Console.WriteLine (“用户数据:“+ document.UserData.ToString ())结束如果Console.WriteLine (“缓存”)Console.WriteLine (”HasCache:“+ document.HasCache.ToString ())Console.WriteLine (”AutoDeleteFromCache:“+ document.AutoDeleteFromCache.ToString ())Console.WriteLine (“元数据”)每一个作为KeyValuePair (字符串,字符串)document.MetadataConsole.WriteLine (“{0}{1}”,项目。键,item.Value)下一个Console.WriteLine (“文件”)Console.WriteLine (“数:”+ document.Documents。.ToString ())每一个childDocument作为LEADDocumentdocument.DocumentsConsole.WriteLine (名称:“+ childDocument.Name)下一个Console.WriteLine (“页面”)Console.WriteLine (“数:”+ document.Pages。.ToString ())pageNumber作为整数= 1document.Pages。昏暗的页面作为Leadtools.Document。文档Page = document.Pages(pageNumber - 1)Console.WriteLine (”PageNumber:“+ pageNumber.ToString ())Console.WriteLine (”OriginalPageNumber:“+ page.OriginalPageNumber.ToString ())Console.WriteLine (”OriginalDocumentName:“+ page.Document.Name)Console.WriteLine (“大小:{0}”page.Size.ToString ())下一个Console.WriteLine (“- - - - - - - - - -”)结束公共共享函数GetCache ()作为ObjectCache“创建一个LEADTOOLS FileCache对象昏暗的cacheDir作为字符串= Path.Combine (ImagesPath.Path“缓存”)如果Directory.Exists (cacheDir)然后Directory.Delete (cacheDir真正的)结束如果Directory.CreateDirectory (cacheDir)昏暗的缓存作为FileCache ()缓存。缓存Directory = cacheDir返回缓存结束函数
需求
目标平台
Leadtools.Document作为sembly
188金宝搏的网址客服|支持|联系我们|知识产权的通知
©1991 - 2021领先的技术公司。保留所有权利。