Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.4.3
|
Leadtools.Documents Namespace > DocumentFactory Class : Create Method |
public static Document Create( string documentType, CreateDocumentOptions options )
'Declaration
Public Shared Function Create( _ ByVal documentType As String, _ ByVal options As CreateDocumentOptions _ ) As Document
'Usage
Dim documentType As String Dim options As CreateDocumentOptions Dim value As Document value = DocumentFactory.Create(documentType, options)
public static Document create(String documentType, CreateDocumentOptions options)
public: static Document^ Create( String^ documentType, CreateDocumentOptions^ options )
This method will throw an exception if neither of CreateDocumentOptions.Cache or Cache was setup with a valid cache object.
Use this method to create a new empty document. documentType controls the type of the document created and the following values are currently supported:
Value | Description |
---|---|
"Raster" | Creates a new Raster document. Requires the Leadtools.Documents.Raster.dll assembly. |
"Pdf" | Creates a new PDF document. Requires the Leadtools.Documents.Pdf.dll assembly. |
Any other value | Will throw an exception. |
This method will add items with the key "Created", "Accessed" and "Modified" to Metadata with values equal to the current date and time. The newly created Document object will have an empty list of Pages. It can then be populated by the user.
The member of options are used as follows:
Member | Description |
---|---|
CachePolicy |
This method requires a cache object and hence the policy is always used. Copied to the newly created document and is used to determine when the document and its item are purged from the cache. This value must not be null. |
MimeType |
Copied as is into the newly created document MimeType member. This value can be null but it is recommend you set it to the MIME type of the document since it will be used when saving the document. Use one of the MIME types constants defined in the Constants class. |
After the document is obtained, InternalObject will be to the internal LEADTOOLS object used with the document.
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.Forms.DocumentWriters Imports Leadtools.Svg Imports Leadtools.Documents Imports Leadtools.Caching Imports Leadtools.Annotations.Core Imports Leadtools.Barcode Imports Leadtools.Forms.Ocr <TestMethod()> _ Public Sub DocumentFactoryCreateExample() DocumentFactory.Cache = CreateCache() Dim options As New LoadDocumentOptions() options.UseCache = False Dim createOptions As New CreateDocumentOptions() createOptions.MimeType = "my mime type" Using document As Leadtools.Documents.Document = DocumentFactory.Create("Raster", createOptions) Dim pages As DocumentPages = document.Pages For i As Integer = 1 To 2 Dim page As Leadtools.Documents.DocumentPage = pages.CreatePage(LeadSizeD.Create(i * 8.5 * document.UnitsPerInch, i * 11 * document.UnitsPerInch), 300) page.IsDeleted = (i = 2) pages.Add(page) Next i PrintOutDocumentInfo(document) End Using End Sub
using Leadtools; using Leadtools.Codecs; using Leadtools.Forms.DocumentWriters; using Leadtools.Svg; using Leadtools.Documents; using Leadtools.Caching; using Leadtools.Annotations.Core; using Leadtools.Forms.Ocr; using Leadtools.Barcode; [TestMethod] public void DocumentFactoryCreateExample() { DocumentFactory.Cache = CreateCache(); var options = new LoadDocumentOptions(); options.UseCache = false; var createOptions = new CreateDocumentOptions(); createOptions.MimeType = "my mime type"; using (var document = DocumentFactory.Create("Raster", createOptions)) { var pages = document.Pages; for (var i = 1; i <= 2; i++) { var page = pages.CreatePage(LeadSizeD.Create(i * 8.5 * Document.UnitsPerInch, i * 11 * Document.UnitsPerInch), 300); page.IsDeleted = (i == 2); pages.Add(page); } PrintOutDocumentInfo(document); } }