1. Insert a discontinuity:
If you want to start a new row, column, paragraph, or page, call Documentbuilder.insertbreak.
Example
Insert a page break in the document:
Documentbuilder builder = new Documentbuilder ();D ocument doc = new Document ();D ocumentbuilder builder = new Documentbuilde R (Doc); builder. Writeln ("This is Page 1."); Builder. InsertBreak (breaktype.pagebreak); builder. Writeln ("This is Page 2."); Builder. InsertBreak (breaktype.pagebreak); builder. Writeln ("This is Page 3.");
Visual Basic
Dim doc As New Document () Dim builder As New Documentbuilder (DOC) builder. Writeln ("This is Page 1.") Builder. InsertBreak (breaktype.pagebreak) builder. Writeln ("This is Page 2.") Builder. InsertBreak (breaktype.pagebreak) builder. Writeln ("This is Page 3.")
2. Inserting an image
Documentbuilder provides several [{{Documentbuilder]. Insertimage}}) The multi-load collection method , which enables the insertion of an inline or floating image, if the image is an EMF or WMF metafile, it will be inserted into the document's metafile format, and all other images will be stored in PNG format.
Documentbuilder. the Insertimage method can use images from different sources:
Pass a string parameter ({{documentbuilder.insertimage}}) from file or URL by passing
Flow from one stream parameter ({{documentbuilder.insertimage}})
From an image object through an image parameter (documentbuilder.insertimage)
Pass a byte array parameter ({{documentbuilder.insertimage}}) from a byte array
(1) inserting an inline image
Example
How to insert an inline image at the cursor position of a document.
C#
Document doc = new document ();D ocumentbuilder builder = new Documentbuilder (doc); builder. Insertimage (MyDir + "watermark.png");
Visual Basic
Dim doc As New Document () Dim builder As New Documentbuilder (DOC) builder. Insertimage (MyDir & "Watermark.png")
(2) inserting a floating (absolute position) image
Example
How to insert a floating image from a file or URL:
C#
Document doc = new document ();D ocumentbuilder builder = new Documentbuilder (doc); builder. Insertimage (MyDir + "Watermark.png", Relativehorizontalposition.margin, Relativeverticalposition.margin, 100, Wraptype.square);
Visual Basic
Dim doc As New Document () Dim builder As New Documentbuilder (DOC) builder. Insertimage (MyDir & "Watermark.png", Relativehorizontalposition.margin, Relativeverticalposition.margin, Wraptype.square, Max.
3. Insert a Bookmark
Inserting a book into the document, you need to do a few things:
Call [Documentbuilder. Startbookmark] Set the desired book signature by it
Inserting bookmark text using the Documentbuilder method
Call [Documentbuilder. Endbookmark] It sets the same name as the bookmark you previously set.
bookmarks can overlap and span any range. Create a valid tag you need to call Documentbuilder.startbookmark and Documentbuilder bookmarks , their tag names must be the same
Example
How to use Document Builder to insert a label in your documents:
C#
Document doc = new document ();
Documentbuilder builder = new Documentbuilder (DOC);
Builder. Startbookmark ("Finebookmark");
Builder. Writeln ("This is just a fine bookmark.");
Builder. Endbookmark ("Finebookmark"); Visual Basicdim Doc as New Document () Dim Builder as New Documentbuilder (DOC) builder. Startbookmark ("Finebookmark") builder. Writeln ("This is just a fine bookmark.") Builder. Endbookmark ("Finebookmark")
Aspose.words Latest version download
"Serial" Aspose.words Insert document element using tutorial (ii)