Creates a new DocumentPage.
public DocumentPage CreatePage(LeadSizeD size,double resolution)
public:DocumentPage^ CreatePage(LeadSizeD^ size,double resolution)
public DocumentPage createPage(LeadSizeD size, double resolution) def CreatePage(self,size,resolution):
size
Size of the new page in document units. Cannot be empty (Empty).
resolution
The resolution of the new page in dots per inch (DPI). Must be greater than or equal 0. A value of 0 means
default resolution of 96.
The newly created page.
Use this method to create new pages to be added in this LEADDocument. The constructor of DocumentPage is not accessible and this is the only method that allows you to create a DocumentPage.
The created page is not added automatically to the document, you must use System.Collections.ObjectModel.Collection.Add or System.Collections.ObjectModel.Collection.Insert) to add the page.
The returned DocumentPage does not have any data. It will only have size set as its Size and resolution as its Resolution. You must add the page to the collection before updating its data such as setting the image using SetImage or annotations using SetAnnotations.
size is in document units, refer to Document Library Coordinate System for more information.
using Leadtools;using Leadtools.Caching;using Leadtools.Document;public void DocumentFactoryCreateExample(){var cache = GetCache();// Create a new documentvar createOptions = new CreateDocumentOptions();createOptions.Cache = cache;createOptions.Descriptor = null;createOptions.MimeType = null;createOptions.UseCache = true;createOptions.UserId = null;Console.WriteLine("Cache Policy: {0}", createOptions.CachePolicy.AbsoluteExpiration);string documentId = null;using (LEADDocument document = DocumentFactory.Create(createOptions)){document.Name = "Virtual";// Should have 0 pages and documentsSystem.Diagnostics.Debug.Assert(document.Pages.Count == 0);System.Diagnostics.Debug.Assert(document.Documents.Count == 0); // DocumentDocuments reference// Add page 1 and 2 from a PDF fileLoadDocumentOptions loadOptions = new LoadDocumentOptions();loadOptions.Cache = cache;LEADDocument childDocument = DocumentFactory.LoadFromFile(Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf"), loadOptions);// Do not dispose the child documents, but save it into the cache// This is optional and is done in this example since we will try to re-load the parent document// from the cache - and the child documents should be in the cache as wellchildDocument.SaveToCache();// Now add the pagesdocument.Pages.Add(childDocument.Pages[0]);document.Pages.Add(childDocument.Pages[1]);// Add an empty pagevar documentPage = document.Pages.CreatePage(LeadSizeD.Create(LEADDocument.UnitsPerInch * 8.5, LEADDocument.UnitsPerInch * 11), 300);document.Pages.Add(documentPage);// Add page 3 and 4 from a TIF filechildDocument = DocumentFactory.LoadFromFile(Path.Combine(LEAD_VARS.ImagesDir, "ocr1.tif"), loadOptions);// Also save it into the cachechildDocument.SaveToCache();// Now add the pagesdocument.Pages.Add(childDocument.Pages[0]);document.Pages.Add(childDocument.Pages[0]);// Should have 5 pages and 2 documents (the PDF and the TIF)System.Diagnostics.Debug.Assert(document.Pages.Count == 5);System.Diagnostics.Debug.Assert(document.Documents.Count == 2);// Tell the parent document to dispose any child documents when the parent is disposeddocument.AutoDisposeDocuments = true;// Show the info of this document, should say 5 pagesConsole.WriteLine("Original document information");PrintOutDocumentInfo(document);// Now save, the parent document into the cachedocument.SaveToCache();// And tell all documents to not delete themselves from the cachedocument.AutoDeleteFromCache = false;// Save the ID so we can load itdocumentId = document.DocumentId;}// Now, load the document from the cachevar loadFromCacheOptions = new LoadFromCacheOptions();loadFromCacheOptions.Cache = cache;loadFromCacheOptions.DocumentId = documentId;using (LEADDocument document = DocumentFactory.LoadFromCache(loadFromCacheOptions)){// Should have 5 pages and 2 documents (the PDF and the TIF)System.Diagnostics.Debug.Assert(document.Pages.Count == 5);System.Diagnostics.Debug.Assert(document.Documents.Count == 2);// Show the info of this document, should still say 5 pagesConsole.WriteLine("Loaded from cache information");PrintOutDocumentInfo(document);// Delete first pagedocument.Pages.RemoveAt(0);// Delete the last pagedocument.Pages.RemoveAt(document.Pages.Count - 1);// Should have 3 pages and 2 documents (the PDF and the TIF)System.Diagnostics.Debug.Assert(document.Pages.Count == 3);System.Diagnostics.Debug.Assert(document.Documents.Count == 2);Console.WriteLine("After removing the first 2 pages");PrintOutDocumentInfo(document);// Delete this document and all its children from the cache when we are disposeddocument.AutoDeleteFromCache = true;}}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";}
import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStream;import java.net.URI;import java.net.URISyntaxException;import java.util.Calendar;import org.junit.*;import org.junit.runner.JUnitCore;import org.junit.runner.Result;import org.junit.runner.notification.Failure;import static org.junit.Assert.*;import leadtools.*;import leadtools.caching.*;import leadtools.document.*;public void documentFactoryCreateExample() throws IOException {final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";FileCache cache = getCache();// Create a new documentCreateDocumentOptions createOptions = new CreateDocumentOptions();createOptions.setCache(cache);createOptions.setDescriptor(null);createOptions.setMimeType(null);createOptions.setUseCache(true);System.out.println("Cache Policy: " + createOptions.getCachePolicy().getAbsoluteExpiration());String documentId = null;LEADDocument document = DocumentFactory.create(createOptions);document.setName("Virtual");// Should have 0 pages and documentsassertTrue(document.getPages().size() == 0);// Add page 1 and 2 from a PDF fileLoadDocumentOptions loadOptions = new LoadDocumentOptions();loadOptions.setCache(cache);LEADDocument childDocument = DocumentFactory.loadFromFile(combine(LEAD_VARS_IMAGES_DIR, "Leadtools.pdf"),loadOptions);// Do not dispose the child documents, but save it into the cache// This is optional and is done in this example since we will try to re-load the// parent document// from the cache - and the child documents should be in the cache as wellchildDocument.saveToCache();// Now add the pagesdocument.getPages().add(childDocument.getPages().get(0));document.getPages().add(childDocument.getPages().get(1));// Add an empty pageDocumentPage documentPage = document.getPages().createPage(LeadSizeD.create(LEADDocument.UNITS_PER_INCH * 8.5, LEADDocument.UNITS_PER_INCH * 11), 300);document.getPages().add(documentPage);// Add page 3 and 4 from a TIF filechildDocument = DocumentFactory.loadFromFile(combine(LEAD_VARS_IMAGES_DIR, "ocr1.tif"), loadOptions);// Also save it into the cachechildDocument.saveToCache();// Now add the pagesdocument.getPages().add(childDocument.getPages().get(0));document.getPages().add(childDocument.getPages().get(0));// Should have 5 pages and 2 documents (the PDF and the TIF)assertTrue(document.getPages().size() == 5);assertTrue(document.getDocuments().size() == 2);// Tell the parent document to dispose any child documents when the parent is// disposeddocument.setAutoDisposeDocuments(false);// Show the info of this document, should say 5 pagesSystem.out.println("Original document information");printOutDocumentInfo(document);// Now save, the parent document into the cachedocument.saveToCache();// And tell all documents to not delete themselves from the cachedocument.setAutoDeleteFromCache(false);// Save the ID so we can load itdocument.dispose();documentId = document.getDocumentId();System.out.println("Docu: " + documentId);// Now, load the document from the cacheLoadFromCacheOptions loadFromCacheOptions = new LoadFromCacheOptions();loadFromCacheOptions.setCache(cache);loadFromCacheOptions.setDocumentId(documentId);System.out.println("Load: " + loadFromCacheOptions.getDocumentId());document = DocumentFactory.loadFromCache(loadFromCacheOptions);// Should have 5 pages and 2 documents (the PDF and the TIF)assertTrue(document.getPages().size() == 5);assertTrue(document.getDocuments().size() == 2);// Show the info of this document, should still say 5 pagesSystem.out.println("Loaded from cache information");printOutDocumentInfo(document);// Delete first pagedocument.getPages().remove(0);document.getPages().remove(document.getPages().size() - 1);// Delete the last page// Should have 3 pages and 2 documents (the PDF and the TIF)assertTrue(document.getPages().size() == 3);assertTrue(document.getDocuments().size() == 2);System.out.println("After removing the first 2 pages");printOutDocumentInfo(document);// Delete this document and all its children from the cache when we are disposeddocument.setAutoDeleteFromCache(true);document.dispose();}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
