Table of Contents

Class PdfDocumentBase

Namespace
Syncfusion.Pdf
Assembly
Syncfusion.Pdf.Portable.dll

Represent common properties of PdfDocument and PdfLoadedDocument classes.

public abstract class PdfDocumentBase
Inheritance
PdfDocumentBase
Derived
Inherited Members

Examples

//Create a new document.
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
//Set the document`s viewer preference
doc.ViewerPreferences.PageLayout = PdfPageLayout.TwoPageLeft;
doc.ViewerPreferences.PageScaling = PageScalingMode.AppDefault;
doc.ViewerPreferences.PageMode = PdfPageMode.FullScreen;
doc.Save("ViewerPreferences.pdf");
//Close the document
doc.Close(true);
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = doc.Pages.Add()
'Set the document`s viewer preference
doc.ViewerPreferences.PageLayout = PdfPageLayout.TwoPageLeft
doc.ViewerPreferences.PageScaling = PageScalingMode.AppDefault
doc.ViewerPreferences.PageMode = PdfPageMode.FullScreen
doc.Save("ViewerPreferences.pdf")
'Close the document
doc.Close(True)

Constructors

PdfDocumentBase()

protected PdfDocumentBase()
See Also

Properties

BaseUri

Gets or sets the Base URI of the PDF document.

public string BaseUri { get; set; }

Property Value

string

Examples

//Create a new instance of PdfDocument class.
PdfDocument document = new PdfDocument();
//Set the Base URI.
document.BaseUri = "https://www.syncfusion.com/";
//Create a new page.
PdfPage page = document.Pages.Add();
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new instance of PdfDocument class.
Dim document As PdfDocument = New PdfDocument()
'Set the Base URI.
document.BaseUri = "https://www.syncfusion.com/"
'Create a new page.
Dim page As PdfPage = document.Pages.Add()
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
See Also

Bookmarks

Gets the bookmarks.

public abstract PdfBookmarkBase Bookmarks { get; }

Property Value

PdfBookmarkBase

Examples

//Create a new instance of PdfDocument class.
PdfDocument document = new PdfDocument();
//Add the section.
PdfSection sec = document.Sections.Add();
//Add pages to the section.
PdfPage page = document.Pages.Add();
//Get boookmarks from pdf document.
PdfBookmarkBase outlines = document.Bookmarks;
//Add new bookmark.
PdfBookmark bookmark = outlines.Add("Section");
for (int i = 0; i != 5; i++)
{
//Add pages to the section.
page = sec.Pages.Add();
//Add new bookmark.
bookmark.Add("Page" + i);
//Set the destination for the created bookmark.
bookmark.Destination = new PdfDestination(page);
}
//Save and close the pdf document.
document.Save("Output.pdf");
document.Close(true);
'Create a new instance of PdfDocument class.
Dim document As PdfDocument = New PdfDocument()
'Add the section.
Dim sec As PdfSection = document.Sections.Add()
'Add pages to the section.
Dim page As PdfPage = document.Pages.Add()
'Get boookmarks from pdf document.
Dim outlines As PdfBookmarkBase = document.Bookmarks
'Add new bookmark.
Dim bookmark As PdfBookmark = outlines.Add("Section")
For i As Integer = 0 To 5 - 1
page = sec.Pages.Add()
bookmark.Add("Page" + i)
bookmark.Destination = New PdfDestination(page)
Next
'Save and close the document.
document.Save("Output.pdf")
document.Close(True)

Remarks

To know more about refer this link .

See Also

Compression

Gets or sets the PDF document compression level. By default the compression level is None

public PdfCompressionLevel Compression { get; set; }

Property Value

PdfCompressionLevel

Examples

//Create a new document.
PdfDocument doc = new PdfDocument();
//Set the document`s compression level.
doc.Compression = PdfCompressionLevel.Best;
//Creates a new page
PdfPage page = doc.Pages.Add();
doc.Save("Compression.pdf");
//Close the document
doc.Close(true);
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
'Set the document`s compression level.
doc.Compression = PdfCompressionLevel.Best
'Create a page.
Dim page As PdfPage = doc.Pages.Add()
doc.Save("Compression.pdf")
'Close the document.
doc.Close(True)

Remarks

To know more about refer this link .

See Also

DocumentInformation

Gets or sets document's information and properties such as document's title, subject, keyword etc.

public virtual PdfDocumentInformation DocumentInformation { get; }

Property Value

PdfDocumentInformation

Examples

//Create new pdf document.
PdfDocument document = new PdfDocument();
//Set the document author property.
document.DocumentInformation.Author = "Syncfusion";
//Get the document author property value.
string author = document.DocumentInformation.Author;
//Save and close the document.
document.Save("output.pdf");
document.Close(true);
//Load an existing document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("output.pdf");
//Get the loaded document author property value.
author = ldoc.DocumentInformation.Author;
//Save and close the document.
ldoc.Save("output.pdf");
ldoc.Close(true);
'Create new pdf document.
Dim document As PdfDocument = New PdfDocument()
'Set the document author property.
document.DocumentInformation.Author = "Syncfusion"
'Get the document author property value.
Dim author As String = document.DocumentInformation.Author
'Save and close the document.
document.Save("output.pdf")
document.Close(True)
'Load an existing document. 
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("output.pdf")
'Get the loaded document author property value.
author = ldoc.DocumentInformation.Author
'Save and close the document.
ldoc.Save("output.pdf")
ldoc.Close(True)

Remarks

To know more about refer this link .

See Also

EnableMemoryOptimization

Gets or sets whether to optimize memory.

public bool EnableMemoryOptimization { get; set; }

Property Value

bool

Examples

//Create a new instance of PdfDocument class.
PdfDocument document = new PdfDocument();
//Enable memory optimization.
document.EnableMemoryOptimization = true;
//Merge source document
PdfDocument.Merge(document, "Source.pdf");
//Save and close the pdf document.
document.Save("Output.pdf");
document.Close(true);
'Create a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Enable memory optimization.
document.EnableMemoryOptimization = True
'Merge source document.
PdfDocument.Merge(document, "Source.pdf")
'Save and close the document.
document.Save("Output.pdf")
document.Close(True)

Remarks

Optimization will be effective only with merge, append and import functions. Only memory will be optimized, different in time occur based on the document size.

See Also

FileStructure

Gets or sets the internal structure of the PDF document.

public PdfFileStructure FileStructure { get; set; }

Property Value

PdfFileStructure

Examples

//Create a new document
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
// Set the document`s cross reference Type
doc.FileStructure.CrossReferenceType = PdfCrossReferenceType.CrossReferenceStream;
// Set the pdf version
doc.FileStructure.Version = PdfVersion.Version1_6;
// Save the document
doc.Save("FileStructure.pdf");
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = doc.Pages.Add()
'  Set the document`s cross reference Type
doc.FileStructure.CrossReferenceType = PdfCrossReferenceType.CrossReferenceStream
' set the pdf version
doc.FileStructure.Version = PdfVersion.Version1_6
' Save the document
doc.Save("FileStructure.pdf")
See Also

Layers

Gets the collection of PdfLayer from the PDF document

public PdfDocumentLayerCollection Layers { get; }

Property Value

PdfDocumentLayerCollection
See Also

PageCount

Gets the number of pages.

public abstract int PageCount { get; }

Property Value

int
See Also

PortfolioInformation

Gets or sets the portfolio information to the Document.

public PdfPortfolioInformation PortfolioInformation { get; set; }

Property Value

PdfPortfolioInformation

Examples

// Create a new instance of PdfDocument class.
PdfDocument document = new PdfDocument();
//Creating new portfolio
document.PortfolioInformation = new PdfPortfolioInformation();
//setting the view mode of the portfolio
document.PortfolioInformation.ViewMode = PdfPortfolioViewMode.Tile;
//Creating the attachment
PdfAttachment pdfFile = new PdfAttachment("Input.pdf");
pdfFile.FileName = "EmployeeDetails.pdf";
//Setting the startup document to view
document.PortfolioInformation.StartupDocument = pdfFile;
//Adding the attachment into document
document.Attachments.Add(pdfFile);
// Save and close the document.
document.Save("Output.pdf");
document.Close(true);
'Create a new instance of PdfDocument class.
Dim document As New PdfDocument()
'Creating new portfolio
document.PortfolioInformation = New PdfPortfolioInformation()
'setting the view mode of the portfolio
document.PortfolioInformation.ViewMode = PdfPortfolioViewMode.Tile
'Creating the attachment
Dim pdfFile As New PdfAttachment("Input.pdf")
pdfFile.FileName = "EmployeeDetails.pdf"
'Setting the startup document to view
document.PortfolioInformation.StartupDocument = pdfFile
'Adding the attachment into document
document.Attachments.Add(pdfFile)
'Save and close the document.
document.Save("Output.pdf")
document.Close(True)

Remarks

To know more about refer this link .

See Also

Security

Gets the security features of the document like encryption.

public PdfSecurity Security { get; }

Property Value

PdfSecurity

Examples

//Create a new document.
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
// Reading security settings of the document
PdfSecurity security = doc.Security;
doc.Save("Security.pdf");
//Close the document
doc.Close(true);
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = doc.Pages.Add()
' Reading security settings of the document
Dim security As PdfSecurity = doc.Security
doc.Save("Security.pdf")
'Close the document
doc.Close(True)

Remarks

To know more about refer this link .

See Also

ViewerPreferences

Gets or sets a viewer preferences. This property is used for presenting the PDF document in a viewer.

public PdfViewerPreferences ViewerPreferences { get; set; }

Property Value

PdfViewerPreferences

Examples

//Create a new document.
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
//Set the document`s viewer preference
doc.ViewerPreferences.PageLayout = PdfPageLayout.TwoPageLeft;
doc.ViewerPreferences.PageScaling = PageScalingMode.AppDefault;
doc.ViewerPreferences.PageMode = PdfPageMode.FullScreen;
doc.Save("ViewerPreferences.pdf");
//Close the document
doc.Close(true);
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = doc.Pages.Add()
'Set the document`s viewer preference
doc.ViewerPreferences.PageLayout = PdfPageLayout.TwoPageLeft
doc.ViewerPreferences.PageScaling = PageScalingMode.AppDefault
doc.ViewerPreferences.PageMode = PdfPageMode.FullScreen
doc.Save("ViewerPreferences.pdf")
'Close the document
doc.Close(True)
See Also

Methods

Append(PdfLoadedDocument)

Appends the loaded document given as parameter to the current document.

public void Append(PdfLoadedDocument ldDoc)

Parameters

ldDoc PdfLoadedDocument

The loaded document to be imported.

Examples

// Source document
PdfLoadedDocument srcDoc = new PdfLoadedDocument("SrcDocument.pdf");
//Create a new document.
PdfDocument doc = new PdfDocument();          
// Appending the document with source document.
doc.Append(srcDoc);
// Save the document.
doc.Save("Append.pdf");
//close both the instance
doc.Close(true);
srcDoc.Close(true);
' Source document
Dim srcDoc As PdfLoadedDocument = New PdfLoadedDocument("SrcDocument.pdf")
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
' Appending the document with source document.
doc.Append(srcDoc)
' Save the document.
doc.Save("Append.pdf")
'Close bothe the instance
doc.Close(True)
srcDoc.Close(True)

Remarks

The appended loaded document must remain open until the current document is saved.

See Also

CheckFields(PdfLoadedDocument, PdfPageBase, List<PdfField>, PdfPageBase)

Checks form fields are connected with the page.

protected virtual void CheckFields(PdfLoadedDocument ldDoc, PdfPageBase page, List<PdfField> fields, PdfPageBase importedPage)

Parameters

ldDoc PdfLoadedDocument

The loaded document.

page PdfPageBase

The page.

fields List<PdfField>

An array where the fields connected to the page are stored.

importedPage PdfPageBase
See Also

Close()

Closes the document. Releases all common resources.

public void Close()

Examples

//Create a new document.
PdfDocument doc = new PdfDocument();               
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
//Create Pdf graphics for the page
PdfGraphics g = page.Graphics;
// Loads an Image            
PdfImage pdfImg = new PdfBitmap(Image.FromFile("Logo.png"));
//Draw the image
g.DrawImage(pdfImg,20, 20, 100,200);
//Save the document
doc.Save("Close.pdf");
//Close the document
doc.Close();
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = doc.Pages.Add()
'Create Pdf graphics for the page
Dim g As PdfGraphics = page.Graphics
' Loads an Image            
Dim pdfImg As PdfImage = New PdfBitmap(Image.FromFile("Logo.png"))   
'Draw the image
g.DrawImage(pdfImg,20, 20, 100,200)
'Save the document
doc.Save("Close.pdf")
' Closes the document
doc.Close()
See Also

Close(bool)

Closes the document.

public virtual void Close(bool completely)

Parameters

completely bool

if set to true the document should close its stream as well.

Examples

//Create a new document.
PdfDocument doc = new PdfDocument();               
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
//Create Pdf graphics for the page
PdfGraphics g = page.Graphics;
// Loads an Image            
PdfImage pdfImg = new PdfBitmap(Image.FromFile("Logo.png")); 
//Draw the image
g.DrawImage(pdfImg,20, 20, 100,200);
//Save the document
doc.Save("Close.pdf");
// Closes the document completely.
doc.Close(true);
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = doc.Pages.Add()
'Create Pdf graphics for the page
Dim g As PdfGraphics = page.Graphics
' Loads an Image            
Dim pdfImg As PdfImage = New PdfBitmap(Image.FromFile("Logo.png")) 
'Draw the image
g.DrawImage(pdfImg,20, 20, 100,200)
'Save the document
doc.Save("Close.pdf")
' Closes the document completely.
doc.Close(True)
See Also

DisposeOnClose(IDisposable)

Adds an object to a collection of the objects that will be disposed during document closing.

public void DisposeOnClose(IDisposable obj)

Parameters

obj IDisposable

The object that will be disposed during document closing.

Examples

//Create a new document.
PdfDocument doc = new PdfDocument();               
//Creates a new page
PdfPage page = doc.Pages.Add();
//Create Pdf graphics for the page
PdfGraphics g = page.Graphics;
// Loads an Image
Image img = Image.FromFile("input.png");
PdfImage pdfImg = new PdfBitmap(img);
//Draw the image
g.DrawImage(pdfImg,20, 20, 100,200);            
doc.Save("DisposeOnClose.pdf");        
// Dispose the Img object along with the document.
doc.DisposeOnClose(img);
//Close the document
doc.Close(true);
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = doc.Pages.Add()
'Create Pdf graphics for the page
Dim g As PdfGraphics = page.Graphics
' Loads an Image
Dim img As Image = Image.FromFile("Logo.png")
Dim pdfImg As PdfImage = New PdfBitmap(img)
'Draw the image
g.DrawImage(pdfImg,20, 20, 100,200)
doc.Save("DisposeOnClose.pdf")
' Dispose the Img object along with the document.
doc.DisposeOnClose(img)
'Close the document
doc.Close(True)
See Also

ImportPage(PdfLoadedDocument, PdfPageBase)

Imports the specified page into the current document pages collection

public PdfPageBase ImportPage(PdfLoadedDocument ldDoc, PdfPageBase page)

Parameters

ldDoc PdfLoadedDocument

The loaded document to be imported.

page PdfPageBase

The page to be inserted.

Returns

PdfPageBase

The page in the target document.

Examples

// Source document
PdfLoadedDocument srcDoc = new PdfLoadedDocument("SrcDocument.pdf");
//Create a new document.
PdfDocument doc = new PdfDocument();
// Importing pages from source document.
doc.ImportPage(srcDoc, srcDoc.Pages[0]);
doc.Save("ImportPages.pdf");
//Close both the instance
doc.Close(true);
srcDoc.Close(true);
' Source document
Dim srcDoc As PdfLoadedDocument = New PdfLoadedDocument("SrcDocument.pdf")
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
' Importing pages from source document.
doc.ImportPage(srcDoc, srcDoc.Pages(0))
doc.Save("ImportPages.pdf")
'Close both the instance
doc.Close(True)
srcDoc.Close(True)

Remarks

The loaded document must remain open until the current document is saved

See Also

ImportPage(PdfLoadedDocument, int)

Imports the loaded document's page index to the current document.

public PdfPageBase ImportPage(PdfLoadedDocument ldDoc, int pageIndex)

Parameters

ldDoc PdfLoadedDocument

The loaded document to be imported.

pageIndex int

Index of the page.

Returns

PdfPageBase

The page in the target document.

Examples

// Source document
PdfLoadedDocument srcDoc = new PdfLoadedDocument("SrcDocument.pdf");
//Create a new document.
PdfDocument doc = new PdfDocument();
// Importing pages from source document.
doc.ImportPage(srcDoc, 0);
doc.Save("ImportPages.pdf");
//Close both the instance
doc.Close(true);
srcDoc.Close(true);
' Source document
Dim srcDoc As PdfLoadedDocument = New PdfLoadedDocument("SrcDocument.pdf")
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
' Importing pages from source document.
doc.ImportPage(srcDoc, 0)
doc.Save("ImportPages.pdf")
'Close both the instance
doc.Close(True)
srcDoc.Close(True)

Remarks

The loaded document must remain open until the current document is saved

See Also

ImportPageRange(PdfLoadedDocument, int, int)

Imports a page range from a loaded document to the current document

public PdfPageBase ImportPageRange(PdfLoadedDocument ldDoc, int startIndex, int endIndex)

Parameters

ldDoc PdfLoadedDocument

The loaded document to be imported.

startIndex int

The start page index.

endIndex int

The end page index.

Returns

PdfPageBase

The last created page in the target document.

Examples

// Source document
PdfLoadedDocument srcDoc = new PdfLoadedDocument("SrcDocument.pdf");
//Create a new document.
PdfDocument doc = new PdfDocument();
// Importing pages from source document.
doc.ImportPageRange(srcDoc, 0, 2);
doc.Save("ImportPages.pdf");
//Close both the instance
doc.Close(true);
srcDoc.Close(true);
' Source document
Dim srcDoc As PdfLoadedDocument = New PdfLoadedDocument("SrcDocument.pdf")
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
' Importing pages from source document.
doc.ImportPageRange(srcDoc, 0, 2)
doc.Save("ImportPages.pdf")
'Close both the instance
doc.Close(True)
srcDoc.Close(True)

Remarks

The loaded document must remain open until the current document is saved

See Also

ImportPageRange(PdfLoadedDocument, int, int, bool)

Imports a page range from a loaded document to the current document

public PdfPageBase ImportPageRange(PdfLoadedDocument ldDoc, int startIndex, int endIndex, bool importBookmarks)

Parameters

ldDoc PdfLoadedDocument

The loaded document to be imported.

startIndex int

The start page index.

endIndex int

The end page index.

importBookmarks bool

Gets value whether to import bookmarks from the imported page.

Returns

PdfPageBase

The last created page in the target document.

Examples

// Source document
PdfLoadedDocument srcDoc = new PdfLoadedDocument("SrcDocument.pdf");
//Create a new document.
PdfDocument doc = new PdfDocument();
// Importing pages from source document without bookmarks.
doc.ImportPageRange(srcDoc, 0, 2, false);
doc.Save("ImportPages.pdf");
//Close both the instance
doc.Close(true);
srcDoc.Close(true);
' Source document
Dim srcDoc As PdfLoadedDocument = New PdfLoadedDocument("SrcDocument.pdf")
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
' Importing pages from source document.
doc.ImportPageRange(srcDoc, 0, 2, true)
doc.Save("ImportPages.pdf")
'Close both the instance
doc.Close(True)
srcDoc.Close(True)

Remarks

The loaded document must remain open until the current document is saved

See Also

Merge(PdfDocumentBase, PdfLoadedDocument)

Merges the specified dest.

public static PdfDocumentBase Merge(PdfDocumentBase dest, PdfLoadedDocument src)

Parameters

dest PdfDocumentBase

The destination document.

src PdfLoadedDocument

The source document.

Returns

PdfDocumentBase

The merged document

Examples

// Source document.
PdfLoadedDocument srcDoc = new PdfLoadedDocument("Src1.pdf");
// Destination PDF document
PdfDocument destDoc = new PdfDocument();          
//Merge the source pdf document.
PdfDocumentBase.Merge(destDoc, srcDoc);
destDoc.Save("Merge.pdf");
' Source document.
Dim srcDoc As PdfLoadedDocument = New PdfLoadedDocument("Src1.pdf")
' Destination PDF document
Dim destDoc As PdfDocument = New PdfDocument()
'Merge the source pdf document.
PdfDocumentBase.Merge(destDoc, srcDoc)
destDoc.Save("Merge.pdf")
See Also

Merge(PdfDocumentBase, PdfMergeOptions, params object[])

Merges the specified source documents with PdfMergeOptions and return destination document.

public static PdfDocumentBase Merge(PdfDocumentBase dest, PdfMergeOptions options, params object[] sourceDocuments)

Parameters

dest PdfDocumentBase

The destination document, where the other documents are merged into. If it's null a new document object will be created.

options PdfMergeOptions

customize the merging PDF.

sourceDocuments object[]

The source documents.

Returns

PdfDocumentBase

The options contain Optimizing resources.

Examples

// Destination PDF document
PdfDocument destDoc = new PdfDocument();
// Source PDF documents
string[] source = { "Src1.pdf", "Src2.pdf" };
PdfMergeOptions option = new PdfMergeOptions();
option.OptimizeResources = true;
//Merge the source pdf document.
PdfDocumentBase.Merge(destDoc, option, source);
destDoc.Save("Merge.pdf");
' Destination PDF document
Dim destDoc As PdfDocument = New PdfDocument()
' Source PDF documents
Dim [option] As PdfMergeOptions = New PdfMergeOptions()
[option].OptimizeResources = True
PdfDocumentBase.Merge(destDoc, [option], source)
'Merge the source pdf document.
PdfDocumentBase.Merge(destDoc, source)
destDoc.Save("Merge.pdf")

Remarks

This method is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight

See Also

Merge(PdfDocumentBase, params object[])

Merges the specified source documents and return destination document.

public static PdfDocumentBase Merge(PdfDocumentBase dest, params object[] sourceDocuments)

Parameters

dest PdfDocumentBase

The destination document, where the other documents are merged into. If it's null a new document object will be created.

sourceDocuments object[]

The source documents.

Returns

PdfDocumentBase

The document containing merged documents.

Examples

// Destination PDF document
PdfDocument destDoc = new PdfDocument();
// Source PDF documents
string[] source = { "Src1.pdf", "Src2.pdf" };
//Merge the source pdf document.
PdfDocumentBase.Merge(destDoc, source);
destDoc.Save("Merge.pdf");
' Destination PDF document
Dim destDoc As PdfDocument = New PdfDocument()
' Source PDF documents
Dim source() As String = { "Src1.pdf", "Src2.pdf" }
'Merge the source pdf document.
PdfDocumentBase.Merge(destDoc, source)
destDoc.Save("Merge.pdf")

Remarks

This method is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight

See Also

Save(Stream)

Saves the document to the specified output stream.

public abstract void Save(Stream stream)

Parameters

stream Stream

The stream object where PDF document will be saved.

Examples

//Create a new document.
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
//Create Pdf graphics for the page
PdfGraphics g = page.Graphics;
// Loads an Image            
PdfImage pdfImg = new PdfBitmap(Image.FromFile("Logo.png")); 
//Draw the image
g.DrawImage(pdfImg, 20, 20, 100, 200);
// Save the document as a stream
MemoryStream stream = new MemoryStream();
doc.Save(stream);
'Create a new document.
Dim doc As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = doc.Pages.Add()
'Create Pdf graphics for the page
Dim g As PdfGraphics = page.Graphics
' Loads an Image            
Dim pdfImg As PdfImage = New PdfBitmap(Image.FromFile("Logo.png"))
'Draw the image
g.DrawImage(pdfImg, 20, 20, 100, 200)
' Save the document as a stream
Dim stream As MemoryStream = New MemoryStream()
doc.Save(stream)
See Also

Events

SaveProgress

Occurs when the document is being saved.

public event PdfDocumentBase.ProgressEventHandler SaveProgress

Event Type

PdfDocumentBase.ProgressEventHandler

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add new pages to the document.
PdfPage page = document.Pages.Add();
//Create font and font style.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f, PdfFontStyle.Bold);
//Draw text in the new page.
page.Graphics.DrawString("Essential PDF", font, PdfBrushes.Black, new PointF(10, 10));
document.SaveProgress += new PdfDocument.ProgressEventHandler(document_SaveProgress);
//Saves the document
document.Save("Document.pdf");
//Close the document
document.Close(true);
// Event handler for PageAdded event
void document_SaveProgress(object sender, ProgressEventArgs arguments)
{
  MessageBox.Show(String.Format("Current: {0}, Progress: {1}, Total {2}", arguments.Current, arguments.Progress, arguments.Total));
}
'Create a new PDF document.
Private document As PdfDocument = New PdfDocument()
'Add new pages to the document.
Private page As PdfPage = document.Pages.Add()
'Create font and font style.
Private font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12f, PdfFontStyle.Bold)
'Draw text in the new page.
page.Graphics.DrawString("Essential PDF", font, PdfBrushes.Black, New PointF(10, 10))
AddHandler document.SaveProgress, AddressOf document_SaveProgress
'Saves the document
document.Save("Document.pdf")
'Close the document
document.Close(True)
' Event handler for PageAdded event
Private Sub document_SaveProgress(ByVal sender As Object, ByVal arguments As ProgressEventArgs)
 MessageBox.Show(String.Format("Current: {0}, Progress: {1}, Total {2}", arguments.Current, arguments.Progress, arguments.Total))
End Sub

Remarks

This event raised on saving the document. It will keep track of the save progress of the document.

See Also

See Also