Document.Import

Import(Stream, PdfImportOptions, MergeOptions)

Imports a set of pages from provided PDF document.

public Document Import(Stream stream, PdfImportOptions importOptions = null, 
    MergeOptions mergeOptions = null)
ParameterTypeDescription
streamStreamA stream with PDF document.
importOptionsPdfImportOptionsSpecifies the options how to import pages from PDF document.
mergeOptionsMergeOptionsSpecifies the options how to merge provided pages.

Return Value

Returns the reference to the document.

See Also


Import(string, PdfImportOptions, MergeOptions)

Imports a set of pages from provided PDF document.

public Document Import(string file, PdfImportOptions importOptions = null, 
    MergeOptions mergeOptions = null)
ParameterTypeDescription
fileStringA file with PDF document.
importOptionsPdfImportOptionsSpecifies the options how to import pages from PDF document.
mergeOptionsMergeOptionsSpecifies the options how to merge provided pages.

Return Value

Returns the reference to the document.

Examples

Shows how to import all pages from a set of PDF documents page by page.

string dataDir = RunExamples.GetDataDir_Import();

var d = new Document();

d.Import(Path.Combine(dataDir, "sampleText.pdf"))
 .Import(Path.Combine(dataDir, "sampleImage.pdf"))
 .Import(Path.Combine(dataDir, "sampleTable.pdf"));

d.Save(Path.Combine(dataDir, "sample_SimpleMerge.one"));

Shows how to import all pages from a set of PDF documents while inserting pages from every PDF document as children of a top level OneNote page.

string dataDir = RunExamples.GetDataDir_Import();

var d = new Document();

foreach (var file in new[] { "sampleText.pdf", "sampleImage.pdf", "sampleTable.pdf" })
{
    d.AppendChildLast(new Page()).Title = new Title() { TitleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append(file) };
    d.Import(Path.Combine(dataDir, file), new PdfImportOptions(), new MergeOptions() { InsertAt = int.MaxValue, InsertAsChild = true });
}

d.Save(Path.Combine(dataDir, "sample_StructuredMerge.one"));

Shows how to import all content from a set of PDF documents while merging pages from every PDF document to a single OneNote page.

string dataDir = RunExamples.GetDataDir_Import();

var d = new Document();

var importOptions = new PdfImportOptions();
var mergeOptions = new MergeOptions() { ImportAsSinglePage = true, PageSpacing = 100 };

d.Import(Path.Combine(dataDir, "sampleText.pdf"), importOptions, mergeOptions)
 .Import(Path.Combine(dataDir, "sampleImage.pdf"), importOptions, mergeOptions)
 .Import(Path.Combine(dataDir, "sampleTable.pdf"), importOptions, mergeOptions);

d.Save(Path.Combine(dataDir, "sample_SinglePageMerge.one"));

See Also