Class Document

Class Document

Nom dels espais: Aspose.Note Assemblea: Aspose.Note.dll (25.4.0)

Presenta un document Aspose.Note.

public class Document : CompositeNode<Page>, INode, ICompositeNode<Page>, ICompositeNode, IEnumerable<Page>, IEnumerable, INotebookChildNode
{
}

Inheritance

object Node CompositeNodeBase CompositeNode Document

Implements

INode , ICompositeNode , ICompositeNode , IEnumerable , IEnumerable , INotebookChildNode

Membres heretats

CompositeNode.GetEnumerator() , CompositeNode.InsertChild(int, T1) , CompositeNode.InsertChildrenRange(int, IEnumerable) , CompositeNode.InsertChildrenRange(int, params Page[]) , CompositeNode.AppendChildFirst(T1) , CompositeNode.AppendChildLast(T1) , CompositeNode.RemoveChild(T1) , CompositeNode.Accept(DocumentVisitor) , CompositeNode.GetChildNodes(NodeType) , CompositeNode.GetChildNodes() , CompositeNode.IsComposite , CompositeNode.FirstChild , CompositeNode.LastChild , CompositeNodeBase.GetChildNodes(NodeType) , CompositeNodeBase.GetChildNodes() , CompositeNodeBase.CheckDocument(Node) , Node.Accept(DocumentVisitor) , Node.Document , Node.IsComposite , Node.NodeType , Node.ParentNode , Node.PreviousSibling , Node.NextSibling , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Mostra com enviar un document a una impressora utilitzant el diàleg de Windows estàndard amb opcions de default.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   var document = new Aspose.Note.Document(dataDir + "Aspose.one");
   document.Print();

Mostra com salvar un document.

string inputFile = "Sample1.one";
   string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string outputFile = "SaveDocToOneNoteFormat_out.one";
   Document doc = new Document(dataDir + inputFile);
   doc.Save(dataDir + outputFile);

Mostra com fer un document encriptat.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   LoadOptions loadOptions = new LoadOptions { DocumentPassword = "password" };
   Document doc = new Document(dataDir + "Sample1.one", loadOptions);

Mostra com salvar el document amb xifratge.

string dataDir = RunExamples.GetDataDir_NoteBook();
   Document document = new Document();
   document.Save(dataDir + "CreatingPasswordProtectedDoc_out.one", new OneSaveOptions { DocumentPassword = "pass" });

Mostra com salvar un document utilitzant l’enumeració de SaveFormat.

string inputFile = "Sample1.one";
   string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string outputFile = "SaveDocToOneNoteFormatUsingSaveFormat_out.one";
   Document document = new Document(dataDir + inputFile);
   document.Save(dataDir + outputFile, SaveFormat.One);

Mostra com salvar un document utilitzant OneSaveOptions.

string inputFile = "Sample1.one";
   string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string outputFile = "SaveDocToOneNoteFormatUsingOneSaveOptions_out.one";
   Document document = new Document(dataDir + inputFile);
   document.Save(dataDir + outputFile, new OneSaveOptions());

Mostra com obtenir el nombre de pàgina d’un document.

string dataDir = RunExamples.GetDataDir_Pages();
   Document oneFile = new Document(dataDir + "Aspose.one");
   int count = oneFile.Count();
   Console.WriteLine(count);

Mostra com guardar un document en format pdf utilitzant les configuracions predefinides.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveWithDefaultSettings_out.pdf";
   oneFile.Save(dataDir, SaveFormat.Pdf);

Mostra com guardar un document en format gif.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveToImageDefaultOptions_out.gif";
   oneFile.Save(dataDir, SaveFormat.Gif);

Mostra com configurar la qualitat d’imatge quan emmagatzema el document com a imatge en format JPEG.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document(dataDir + "Aspose.one");
   dataDir = dataDir + "SetOutputImageResolution_out.jpg";
   doc.Save(dataDir, new ImageSaveOptions(SaveFormat.Jpeg) { Quality = 100 });

Mostra com configurar una resolució d’imatge quan salva el document com a imatge.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document(dataDir + "Aspose.one");
   int resolution = 220;
   dataDir = dataDir + "SetOutputImageResolution_out.jpg";
   doc.Save(dataDir, new ImageSaveOptions(SaveFormat.Jpeg) { Resolution = resolution });

Mostra com obtenir el format de fitxers d’un document.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   var document = new Aspose.Note.Document(dataDir + "Aspose.one");
   switch (document.FileFormat)
   {
       case FileFormat.OneNote2010:
           break;
       case FileFormat.OneNoteOnline:
           break;
   }

Mostra com vincular un hiperenllaç a una imatge.

string dataDir = RunExamples.GetDataDir_Images();
   var document = new Document();
   var page = new Page(document);
   var image = new Image(document, dataDir + "image.jpg") { HyperlinkUrl = "http://image.com" };
   page.AppendChildLast(image);
   document.AppendChildLast(page);
   document.Save(dataDir + "Image with Hyperlink_out.one");

Mostra com guardar un document a un flux.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document(dataDir + "Aspose.one");
   MemoryStream dstStream = new MemoryStream();
   doc.Save(dstStream, SaveFormat.Pdf);
   dstStream.Seek(0, SeekOrigin.Begin);

Mostra com comprovar si un document està protegit amb contrasenya.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (!Document.IsEncrypted(fileName, out document))
   {
       Console.WriteLine("The document is loaded and ready to be processed.");
   }
   else
   {
       Console.WriteLine("The document is encrypted. Provide a password.");
   }

Mostra com afegir una nova secció a un notebook.

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "Notizbuch Öffnen.onetoc2");
   notebook.AppendChild(new Document(dataDir + "Neuer Abschnitt 1.one"));
   dataDir += @"\AddChildNode_out.onetoc2";
   notebook.Save(dataDir);

Mostra com comprovar si una càrrega de document fracassa perquè el format de OneNote 2007 no està suportat.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "OneNote2007.one");
   try
   {
      new Document(fileName);
   }
   catch (UnsupportedFileFormatException e)
   {
      if (e.FileFormat == FileFormat.OneNote2007)
      {
         Console.WriteLine("It looks like the provided file is in OneNote 2007 format that is not supported.");
      }
      else
      {
         throw;
      }
   }

Mostra com restaurar la versió anterior d’una pàgina.

string dataDir = RunExamples.GetDataDir_Pages();
   Document document = new Document(dataDir + "Aspose.one");
   Page page = document.FirstChild;
   Page previousPageVersion = document.GetPageHistory(page).Last();
   document.RemoveChild(page);
   document.AppendChildLast(previousPageVersion);
   document.Save(dataDir + "RollBackRevisions_out.one");

Com clonar una pàgina.

string dataDir = RunExamples.GetDataDir_Pages();
   Document document = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
   var cloned = new Document();
   cloned.AppendChildLast(document.FirstChild.Clone());
   cloned = new Document();
   cloned.AppendChildLast(document.FirstChild.Clone(true));

Mostra com guardar un document en format html mitjançant l’emmagatzematge de tots els recursos (css / fonts / imatges) a un fitxer separat.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   var document = new Document(Path.Combine(dataDir, "Aspose.one"));
   var options = new HtmlSaveOptions()
   {
      ExportCss = ResourceExportType.ExportAsStream,
      ExportFonts = ResourceExportType.ExportAsStream,
      ExportImages = ResourceExportType.ExportAsStream,
      FontFaceTypes = FontFaceType.Ttf
   };
   document.Save(dataDir + "document_out.html", options);

Mostra com guardar un document a un flux en format html amb la incorporació de tots els recursos (css / fonts / imatges).

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   var document = new Document(Path.Combine(dataDir, "Aspose.one"));
   var options = new HtmlSaveOptions()
   {
      ExportCss = ResourceExportType.ExportEmbedded,
      ExportFonts = ResourceExportType.ExportEmbedded,
      ExportImages = ResourceExportType.ExportEmbedded,
      FontFaceTypes = FontFaceType.Ttf
   };
   var r = new MemoryStream();
   document.Save(r, options);

Mostra com configurar la descripció de text per a una imatge.

string dataDir = RunExamples.GetDataDir_Images();
   var document = new Document();
   var page = new Page(document);
   var image = new Image(document, dataDir + "image.jpg")
   {
      AlternativeTextTitle = "This is an image's title!",
      AlternativeTextDescription = "And this is an image's description!"
   };
   page.AppendChildLast(image);
   document.AppendChildLast(page);
   dataDir += "ImageAlternativeText_out.one";
   document.Save(dataDir);

Mostra com obtenir meta informació sobre una pàgina.

string dataDir = RunExamples.GetDataDir_Pages();
   Aspose.Words.Document oneFile = new Aspose.Words.Document(dataDir + "Aspose.one");
   foreach (Aspose.Words.Page page in oneFile)
   {
       Console.WriteLine("LastModifiedTime: {0}", page.LastModifiedTime);
       Console.WriteLine("CreationTime: {0}", page.CreationTime);
       Console.WriteLine("Title: {0}", page.Title);
       Console.WriteLine("Level: {0}", page.Level);
       Console.WriteLine("Author: {0}", page.Author);
       Console.WriteLine();
   }

Quan les llargues pàgines de OneNote s’emmagatzemen en format pdf, es divideixen entre pàgs.La mostra mostra com configurar la lògica de divisió dels objectes localitzats en les pauses de la pàgina.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document(dataDir + "Aspose.one");
   var pdfSaveOptions = new PdfSaveOptions();
   pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(100);
   pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(400);
   dataDir = dataDir + "PageSplittUsingKeepPartAndCloneSolidObjectToNextPageAlgorithm_out.pdf";
   doc.Save(dataDir, pdfSaveOptions);

Mostra com guardar un document en format png.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   ImageSaveOptions opts = new ImageSaveOptions(SaveFormat.Png)
   {
      PageIndex = 1
   };
   dataDir += "ConvertSpecificPageToImage_out.png";
   oneFile.Save(dataDir, opts);

Mostra com editar la història de la pàgina.

string dataDir = RunExamples.GetDataDir_Pages();
   Document document = new Document(dataDir + "Aspose.one");
   Page page = document.FirstChild;
   var pageHistory = document.GetPageHistory(page);
   pageHistory.RemoveRange(0, 1);
   pageHistory[0] = new Page(document);
   if (pageHistory.Count > 1)
   {
       pageHistory[1].Title.TitleText.Text = "New Title";
       pageHistory.Add(new Page(document));
       pageHistory.Insert(1, new Page(document));
       document.Save(dataDir + "ModifyPageHistory_out.one");
   }

Mostra com comprovar si un document està protegit per una contrasenya específica.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
   {
       if (document != null)
       {
           Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
       }
       else
       {
           Console.WriteLine("The document is encrypted. Invalid password was provided.");
       }
   }
   else
   {
       Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
   }

Mostra com aplicar l’estil temàtic fosc a un document.

string dataDir = RunExamples.GetDataDir_Text();
   Document doc = new Document(Path.Combine(dataDir, "Aspose.one"));
   foreach (var page in doc)
   {
       page.BackgroundColor = Color.Black;
   }
   foreach (var node in doc.GetChildNodes<Aspose.Words.RichText>())
   {
       var c = node.ParagraphStyle.FontColor;
       if (c.IsEmpty || Math.Abs(c.R - Color.Black.R) + Math.Abs(c.G - Color.Black.G) + Math.Abs(c.B - Color.Black.B) <= 30)
       {
           node.ParagraphStyle.FontColor = Color.White;
       }
   }
   doc.Save(Path.Combine(dataDir, "AsposeDarkTheme.pdf"));

Mostra com passar pel contingut d’un notebook.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = "Open Notebook.onetoc2";
   try
   {
       var notebook = new Notebook(dataDir + fileName);
       foreach (var notebookChildNode in notebook)
       {
           Console.WriteLine(notebookChildNode.DisplayName);
           if (notebookChildNode is Document)
           {
           }
           else if (notebookChildNode is Notebook)
           {
           }
       }
   }
   catch (Exception ex)
   {
       Console.WriteLine(ex.Message);
   }

Mostra com obtenir una imatge d’un document.

string dataDir = RunExamples.GetDataDir_Images();
   Document oneFile = new Document(dataDir + "Aspose.one");
   IList<aspose.note.Image> nodes = oneFile.GetChildNodes<aspose.note.Image>();
   foreach (var image in nodes)
   {
       using (MemoryStream stream = new MemoryStream(image.Bytes))
       {
           using (Bitmap bitMap = new Bitmap(stream))
           {
               bitMap.Save(Path.Combine(dataDir, Path.GetFileName(image.FileName)));
           }
       }
   }

Mostra com guardar un document en format PDF.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   PdfSaveOptions opts = new PdfSaveOptions()
   {
       PageIndex = 0,
       PageCount = 1,
   };
   dataDir += "SaveRangeOfPagesAsPDF_out.pdf";
   oneFile.Save(dataDir, opts);

Mostra com guardar un document en format pdf utilitzant configuracions específiques.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document(dataDir + "Aspose.one");
   PdfSaveOptions opts = new PdfSaveOptions()
   {
      ImageCompression = Saving.Pdf.PdfImageCompression.Jpeg,
      JpegQuality = 90
   };
   dataDir += "Document.SaveWithOptions_out.pdf";
   doc.Save(dataDir, opts);

Mostra com enviar un document a una impressora utilitzant el diàleg de Windows estàndard amb opcions especificades.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   var document = new Aspose.Note.Document(dataDir + "Aspose.one");
   var printerSettings = new PrinterSettings()
   {
      FromPage = 0,
      ToPage = 10
   };
   printerSettings.DefaultPageSettings.Landscape = true;
   printerSettings.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(50, 50, 150, 50);
   document.Print(new PrintOptions()
   {
      PrinterSettings = printerSettings,
      Resolution = 1200,
      PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(),
      DocumentName = "Test.one"
   });

Mostra com obtenir el contingut d’un fitxer afegit.

string dataDir = RunExamples.GetDataDir_Attachments();
   Document oneFile = new Document(dataDir + "Sample1.one");
   IList<attachedfile> nodes = oneFile.GetChildNodes<attachedfile>();
   foreach (AttachedFile file in nodes)
   {
       using (Stream outputStream = new MemoryStream(file.Bytes))
       {
           using (System.IO.FileStream fileStream = System.IO.File.OpenWrite(String.Format(dataDir + file.FileName)))
           {
               CopyStream(outputStream, fileStream);
           }
       }
   }

Mostra com obtenir la meta informació de la imatge.

string dataDir = RunExamples.GetDataDir_Images();
   Document oneFile = new Document(dataDir + "Aspose.one");
   IList<aspose.note.Image> images = oneFile.GetChildNodes<aspose.note.Image>();
   foreach (Aspose.Note.Image image in images)
   {
      Console.WriteLine("Width: {0}", image.Width);
      Console.WriteLine("Height: {0}", image.Height);
      Console.WriteLine("OriginalWidth: {0}", image.OriginalWidth);
      Console.WriteLine("OriginalHeight: {0}", image.OriginalHeight);
      Console.WriteLine("FileName: {0}", image.FileName);
      Console.WriteLine("LastModifiedTime: {0}", image.LastModifiedTime);
      Console.WriteLine();
   }

Mostra com obtenir la història de la pàgina.

string dataDir = RunExamples.GetDataDir_Pages();
   Document document = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
   Page firstPage = document.FirstChild;
   foreach (Page pageRevision in document.GetPageHistory(firstPage))
   {
       Console.WriteLine("LastModifiedTime: {0}", pageRevision.LastModifiedTime);
       Console.WriteLine("CreationTime: {0}", pageRevision.CreationTime);
       Console.WriteLine("Title: {0}", pageRevision.Title);
       Console.WriteLine("Level: {0}", pageRevision.Level);
       Console.WriteLine("Author: {0}", pageRevision.Author);
       Console.WriteLine();
   }

Mostra com afegir un fitxer a un document utilitzant la ruta de fitxers.

string dataDir = RunExamples.GetDataDir_Attachments();
   Document doc = new Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   Outline outline = new Outline(doc);
   OutlineElement outlineElem = new OutlineElement(doc);
   AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt");
   outlineElem.AppendChildLast(attachedFile);
   outline.AppendChildLast(outlineElem);
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir += "AttachFileByPath_out.one";
   doc.Save(dataDir);

Mostra com crear un document i salvar-lo en format html utilitzant les opcions de default.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document();
   Page page = doc.AppendChildLast(new Page());
   ParagraphStyle textStyle = new ParagraphStyle
   {
      FontColor = Color.Black,
      FontName = "Arial",
      FontSize = 10
   };
   page.Title = new Title()
   {
      TitleText = new RichText() { Text = "Title text.", ParagraphStyle = textStyle },
      TitleDate = new RichText() { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
      TitleTime = new RichText() { Text = "12:34", ParagraphStyle = textStyle }
   };
   dataDir = dataDir + "CreateOneNoteDocAndSaveToHTML_out.html";
   doc.Save(dataDir);

Mostra com comprovar si una pàgina és un conflicte (és a dir, té canvis que OneNote no podia fusionar automàticament).

string dataDir = RunExamples.GetDataDir_Pages();
   Document doc = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
   var history = doc.GetPageHistory(doc.FirstChild);
   for (int i = 0; i < history.Count; i++)
   {
       var historyPage = history[i];
       Console.Write("{0}. Author: {1}, {2:dd.MM.yyyy hh.mm.ss}",
                     i,
                     historyPage.PageContentRevisionSummary.AuthorMostRecent,
                     historyPage.PageContentRevisionSummary.LastModifiedTime);
       Console.WriteLine(historyPage.IsConflictPage ? ", IsConflict: true" : string.Empty);
       if (historyPage.IsConflictPage)
           historyPage.IsConflictPage = false;
   }
   doc.Save(dataDir + "ConflictPageManipulation_out.one", SaveFormat.One);

Mostra com afegir una imatge del fitxer a un document amb propietats definides per l’usuari.

string dataDir = RunExamples.GetDataDir_Images();
   Document doc = new Document(dataDir + "Aspose.one");
   Aspose.Note.Page page = doc.FirstChild;
   Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
      {
         Width = 100,
         Height = 100,
         HorizontalOffset = 100,
         VerticalOffset = 400,
         Alignment = HorizontalAlignment.Right
      };
   page.AppendChildLast(image);

Mostra com afegir un fitxer d’un flux a un document.

string dataDir = RunExamples.GetDataDir_Attachments();
   Document doc = new Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   Outline outline = new Outline(doc);
   OutlineElement outlineElem = new OutlineElement(doc);
   using (var stream = File.OpenRead(dataDir + "icon.jpg"))
   {
       AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt", stream, ImageFormat.Jpeg);
       outlineElem.AppendChildLast(attachedFile);
   }
   outline.AppendChildLast(outlineElem);
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir += "AttachFileAndSetIcon_out.one";
   doc.Save(dataDir);

Quan les llargues pàgines de OneNote s’emmagatzemen en format pdf, es divideixen entre pàgs. L’exemple mostra com configurar la lògica de divisió dels objectes localitzats en les pauses de la pàgina.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document(dataDir + "Aspose.one");
   var pdfSaveOptions = new PdfSaveOptions();
   pdfSaveOptions.PageSplittingAlgorithm = new AlwaysSplitObjectsAlgorithm();
   pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm();
   pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm();
   float heightLimitOfClonedPart = 500;
   pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(heightLimitOfClonedPart);
   pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(heightLimitOfClonedPart);
   pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(100);
   pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(400);
   dataDir = dataDir + "UsingKeepSOlidObjectsAlgorithm_out.pdf";
   doc.Save(dataDir, pdfSaveOptions);

Mostra com crear un document i guardar en format html la gamma de pàgines especificades.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document();
   Page page = doc.AppendChildLast(new Page());
   ParagraphStyle textStyle = new ParagraphStyle
   {
      FontColor = Color.Black,
      FontName = "Arial",
      FontSize = 10
   };
   page.Title = new Title()
   {
      TitleText = new RichText()
      {
         Text = "Title text.",
         ParagraphStyle = textStyle
      },
      TitleDate = new RichText()
      {
         Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
         ParagraphStyle = textStyle
      },
      TitleTime = new RichText()
      {
         Text = "12:34",
         ParagraphStyle = textStyle
      }
   };
   dataDir = dataDir + "CreateAndSavePageRange_out.html";
   doc.Save(dataDir, new HtmlSaveOptions
   {
      PageCount = 1,
      PageIndex = 0
   });

Mostra com crear un document amb una pàgina titulada.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Aspose.Note.Document doc = new Aspose.Note.Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   ParagraphStyle textStyle = new ParagraphStyle
   {
      FontColor = Color.Black,
      FontName = "Arial",
      FontSize = 10
   };
   page.Title = new Title(doc)
   {
      TitleText = new RichText(doc) { Text = "Title text.", ParagraphStyle = textStyle },
      TitleDate = new RichText(doc) { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
      TitleTime = new RichText(doc) { Text = "12:34", ParagraphStyle = textStyle }
   };
   doc.AppendChildLast(page);
   dataDir += "CreateDocWithPageTitle_out.one";
   doc.Save(dataDir);

Mostra com afegir una imatge de flux a un document.

string dataDir = RunExamples.GetDataDir_Images();
   Document doc = new Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   Outline outline1 = new Outline(doc);
   OutlineElement outlineElem1 = new OutlineElement(doc);
   using (FileStream fs = File.OpenRead(dataDir + "image.jpg"))
   {
       Aspose.Note.Image image1 = new Aspose.Note.Image(doc, "Penguins.jpg", fs)
                                {
                                    Alignment = HorizontalAlignment.Right
                                };
       outlineElem1.AppendChildLast(image1);
   }
   outline1.AppendChildLast(outlineElem1);
   page.AppendChildLast(outline1);
   doc.AppendChildLast(page);
   dataDir = dataDir + "BuildDocAndInsertImageUsingImageStream_out.one";
   doc.Save(dataDir);

Mostra com afegir una imatge d’un fitxer a un document.

string dataDir = RunExamples.GetDataDir_Images();
   Document doc = new Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   Outline outline = new Outline(doc);
   OutlineElement outlineElem = new OutlineElement(doc);
   Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
                               {
                                   Alignment = HorizontalAlignment.Right
                               };
   outlineElem.AppendChildLast(image);
   outline.AppendChildLast(outlineElem);
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir = dataDir + "BuildDocAndInsertImage_out.one";
   doc.Save(dataDir);

Mostra com crear un document amb un text.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document();
   Page page = new Page(doc);
   Outline outline = new Outline(doc);
   OutlineElement outlineElem = new OutlineElement(doc);
   ParagraphStyle textStyle = new ParagraphStyle
   {
      FontColor = Color.Black,
      FontName = "Arial",
      FontSize = 10
   };
   RichText text = new RichText(doc)
   {
      Text = "Hello OneNote text!",
      ParagraphStyle = textStyle
   };
   outlineElem.AppendChildLast(text);
   outline.AppendChildLast(outlineElem);
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir += "CreateDocWithSimpleRichText_out.one";
   doc.Save(dataDir);

Mostra com guardar un document en diferents formats.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document() { AutomaticLayoutChangesDetectionEnabled = false };
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
   page.Title = new Title(doc)
   {
       TitleText = new RichText(doc) { Text = "Title text.", ParagraphStyle = textStyle },
       TitleDate = new RichText(doc) { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
       TitleTime = new RichText(doc) { Text = "12:34", ParagraphStyle = textStyle }
   };
   doc.AppendChildLast(page);
   doc.Save(dataDir + "ConsequentExportOperations_out.html");
   doc.Save(dataDir + "ConsequentExportOperations_out.pdf");
   doc.Save(dataDir + "ConsequentExportOperations_out.jpg");
   textStyle.FontSize = 11;
   doc.DetectLayoutChanges();
   doc.Save(dataDir + "ConsequentExportOperations_out.bmp");

Mostra com guardar un document en format html amb l’emmagatzematge de tots els recursos (css/fonts/imatges) mitjançant les trucades definides per l’usuari.

using System.IO;
   using Aspose.Words;
   var savingCallbacks = new UserSavingCallbacks
   {
       RootFolder = "documentFolder",
       CssFolder = "css",
       KeepCssStreamOpened = true,
       ImagesFolder = "images",
       FontsFolder = "fonts"
   };
   var options = new HtmlSaveOptions
   {
       FontFaceTypes = FontFaceType.Ttf,
       CssSavingCallback = savingCallbacks,
       FontSavingCallback = savingCallbacks,
       ImageSavingCallback = savingCallbacks
   };
   if (!Directory.Exists(savingCallbacks.RootFolder))
   {
       Directory.CreateDirectory(savingCallbacks.RootFolder);
   }
   string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   var document = new Document(Path.Combine(dataDir, "Aspose.one"));
   using (var stream = File.Create(Path.Combine(savingCallbacks.RootFolder, "document.html")))
   {
       document.Save(stream, options);
   }
   using (var writer = new StreamWriter(savingCallbacks.CssStream))
   {
       writer.WriteLine();
       writer.WriteLine("/* This line is appended to stream manually by user */");
   }

Mostra com vincular un hiperenllaç a un text.

string dataDir = RunExamples.GetDataDir_Tasks();
   Document doc = new Document();
   RichText titleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append("Title!");
   Outline outline = new Outline()
   {
       MaxWidth = 200,
       MaxHeight = 200,
       VerticalOffset = 100,
       HorizontalOffset = 100
   };
   TextStyle textStyleRed = new TextStyle
   {
       FontColor = Color.Red,
       FontName = "Arial",
       FontSize = 10
   };
   TextStyle textStyleHyperlink = new TextStyle
   {
       IsHyperlink = true,
       HyperlinkAddress = "www.google.com"
   };
   RichText text = new RichText()
       .Append("This is ", textStyleRed)
       .Append("hyperlink", textStyleHyperlink)
       .Append(". This text is not a hyperlink.", TextStyle.Default);
   OutlineElement outlineElem = new OutlineElement();
   outlineElem.AppendChildLast(text);
   outline.AppendChildLast(outlineElem);
   Title title = new Title() { TitleText = titleText };
   Page page = new Note.Page() { Title = title };
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir = dataDir + "AddHyperlink_out.one";
   doc.Save(dataDir);

Mostra com accedir al contingut d’un document utilitzant el visitant.

public static void Run()
   {
       string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
       Document doc = new Document(dataDir + "Aspose.one");
       MyOneNoteToTxtWriter myConverter = new MyOneNoteToTxtWriter();
       doc.Accept(myConverter);
       Console.WriteLine(myConverter.GetText());
       Console.WriteLine(myConverter.NodeCount);
   }
   public class MyOneNoteToTxtWriter : DocumentVisitor
   {
       public MyOneNoteToTxtWriter()
       {
           NodeCount = 0;
           IsSkipText = false;
           Builder = new StringBuilder();
       }
       public string GetText()
       {
           return Builder.ToString();
       }
       private void AppendText(string text)
       {
           if (!IsSkipText)
           {
               Builder.AppendLine(text);
           }
       }
       public override void VisitRichTextStart(RichText run)
       {
           ++NodeCount;
           AppendText(run.Text);
       }
       public override void VisitDocumentStart(Document document)
       {
           ++NodeCount;
       }
       public override void VisitPageStart(Page page)
       {
           ++NodeCount;
           AppendText($"*** Page '{page.Title?.TitleText?.Text ?? "(no title)"}' ***");
       }
       public override void VisitPageEnd(Page page)
       {
           AppendText(string.Empty);
       }
       public override void VisitTitleStart(Title title)
       {
           ++NodeCount;
       }
       public override void VisitImageStart(Image image)
       {
           ++NodeCount;
       }
       public override void VisitOutlineGroupStart(OutlineGroup outlineGroup)
       {
           ++NodeCount;
       }
       public override void VisitOutlineStart(Outline outline)
       {
           ++NodeCount;
       }
       public override void VisitOutlineElementStart(OutlineElement outlineElement)
       {
           ++NodeCount;
       }
       public Int32 NodeCount
       {
           get { return this.nodeCount; }
       }
       private readonly StringBuilder Builder;
       private bool IsSkipText;
       private int nodeCount;
   }

Constructors

Documentació ()

Inicia una nova instància de la classe Aspose.Note.Document.Crea un document OneNote blanc.

public Document()
   {
   }

El document (string)

Inicia una nova instància de la classe Aspose.Note.Document.Obre un document OneNote existent d’un arxiu.

public Document(string filePath)
   {
   }

Parameters

filePath string

El camí del fitxer.

Exceptions

UnsupportedFileFormatException

El format de document no es reconeix ni no es recolza.

FileCorruptedException

El document sembla corrupte i no es pot carregar.

IncorrectPasswordException

El document és xifrat i requereix una contrasenya per obrir, però vostè ha proporcionat una contrasenya incorrecta.

InvalidOperationException

Hi ha un problema amb el document i s’ha de notificar als desenvolupadors d’Aspose.Note.

IOException

Hi ha una excepció d’entrada / sortida.

Document (string, opcions de càrrega)

Inicia una nova instància de la classe Aspose.Note.Document.Obre un document OneNote existent d’un arxiu. permet especificar opcions addicionals com una contrasenya de xifració.

public Document(string filePath, LoadOptions loadOptions)
   {
   }

Parameters

filePath string

El camí del fitxer.

loadOptions LoadOptions

Opcions utilitzades per carregar un document. pot ser nul.

Exceptions

UnsupportedFileFormatException

El format de document no es reconeix ni no es recolza.

FileCorruptedException

El document sembla corrupte i no es pot carregar.

IncorrectPasswordException

El document és xifrat i requereix una contrasenya per obrir, però vostè ha proporcionat una contrasenya incorrecta.

InvalidOperationException

Hi ha un problema amb el document i s’ha de notificar als desenvolupadors d’Aspose.Note.

IOException

Hi ha una excepció d’entrada / sortida.

El programa (Stream)

Inicia una nova instància de la classe Aspose.Note.Document.Obre un document OneNote existent des d’un corrent.

public Document(Stream inStream)
   {
   }

Parameters

inStream Stream

El corrent.

Exceptions

UnsupportedFileFormatException

El format de document no es reconeix ni no es recolza.

FileCorruptedException

El document sembla corrupte i no es pot carregar.

IncorrectPasswordException

El document és xifrat i requereix una contrasenya per obrir, però vostè ha proporcionat una contrasenya incorrecta.

InvalidOperationException

Hi ha un problema amb el document i s’ha de notificar als desenvolupadors d’Aspose.Note.

IOException

Hi ha una excepció d’entrada / sortida.

ArgumentException

El flux no dóna suport a la lectura, és nul o ja està tancat.

Document (Stream, Opcions de càrrega)

Inicia una nova instància de la classe Aspose.Note.Document.Obre un document OneNote existent des d’un flux. permet especificar opcions addicionals com una contrasenya de xifració.

public Document(Stream inStream, LoadOptions loadOptions)
   {
   }

Parameters

inStream Stream

El corrent.

loadOptions LoadOptions

Opcions utilitzades per carregar un document. pot ser nul.

Exceptions

UnsupportedFileFormatException

El format de document no es reconeix ni no es recolza.

FileCorruptedException

El document sembla corrupte i no es pot carregar.

IncorrectPasswordException

El document és xifrat i requereix una contrasenya per obrir, però vostè ha proporcionat una contrasenya incorrecta.

InvalidOperationException

Hi ha un problema amb el document i s’ha de notificar als desenvolupadors d’Aspose.Note.

IOException

Hi ha una excepció d’entrada / sortida.

ArgumentException

El flux no dóna suport a la lectura, és nul o ja està tancat.

Properties

AutomaticLayoutChangesDetectionEnabled

Obté o s’estableix un valor que indica si Aspose.Note realitza la detecció de canvis en el disseny automàticament.El valor estàndard és ’true'.

public bool AutomaticLayoutChangesDetectionEnabled
   {
      get;
      set;
   }

Valor de la propietat

bool

Examples

Mostra com guardar un document en diferents formats.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document() { AutomaticLayoutChangesDetectionEnabled = false };
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   ParagraphStyle textStyle = new ParagraphStyle
      {
         FontColor = Color.Black,
         FontName = "Arial",
         FontSize = 10
      };
   page.Title = new Title(doc)
      {
         TitleText = new RichText(doc) { Text = "Title text.", ParagraphStyle = textStyle },
         TitleDate = new RichText(doc) { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
         TitleTime = new RichText(doc) { Text = "12:34", ParagraphStyle = textStyle }
      };
   doc.AppendChildLast(page);
   doc.Save(dataDir + "ConsequentExportOperations_out.html");
   doc.Save(dataDir + "ConsequentExportOperations_out.pdf");
   doc.Save(dataDir + "ConsequentExportOperations_out.jpg");
   textStyle.FontSize = 11;
   doc.DetectLayoutChanges();
   doc.Save(dataDir + "ConsequentExportOperations_out.bmp");

Color

Obtenir o posar el color.

public Color Color
   {
      get { return this.Color; }
      set { this.Color = value; }
   }

Valor de la propietat

Color

CreationTime

Obtenir o establir el temps de creació.

public DateTime CreationTime
   {
      get;
      set;
   }

Valor de la propietat

DateTime

DisplayName

Obtenir o posar el nom de la pantalla.

public string DisplayName
   {
      get;
      set;
   }

Valor de la propietat

string

FileFormat

Obté el format de fitxers (OneNote 2010, OneNota Online).

public FileFormat FileFormat
   {
      get;
   }

Valor de la propietat

FileFormat

Examples

Mostra com obtenir el format de fitxers d’un document.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   var document = new Aspose.Note.Document(dataDir + "Aspose.one");
   switch (document.FileFormat)
   {
       case Aspose.Words.FileFormat.OneNote2010:
           break;
       case Aspose.Words.FileFormat.OneNoteOnline:
           break;
   }

Guid

Obté l’ID globalment únic de l’objecte.

public Guid Guid
   {
      get;
   }

Valor de la propietat

Guid

Methods

Acceptació (DocumentVisitor)

Accepta el visitant del nucli.

public override void Accept(DocumentVisitor visitor)
   {
   }

Parameters

visitor DocumentVisitor

L’objecte d’una classe derivada de l’Aspose.Note.DocumentVisitor.

Examples

Mostra com accedir al contingut d’un document utilitzant el visitant.

public static void Run()
   {
       string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
       Document doc = new Document(dataDir + "Aspose.one");
       MyOneNoteToTxtWriter myConverter = new MyOneNoteToTxtWriter();
       doc.Accept(myConverter);
       Console.WriteLine(myConverter.GetText());
       Console.WriteLine(myConverter.NodeCount);
   }
   public class MyOneNoteToTxtWriter : DocumentVisitor
   {
       public MyOneNoteToTxtWriter()
       {
           nodecount = 0;
           mIsSkipText = false;
           mBuilder = new StringBuilder();
       }
       public string GetText()
       {
           return mBuilder.ToString();
       }
       private void AppendText(string text)
       {
           if (!mIsSkipText)
           {
               mBuilder.AppendLine(text);
           }
       }
       public override void VisitRichTextStart(RichText run)
       {
           ++nodecount;
           AppendText(run.Text);
       }
       public override void VisitDocumentStart(Document document)
       {
           ++nodecount;
       }
       public override void VisitPageStart(Page page)
       {
           ++nodecount;
           this.AppendText($"*** Page '{page.Title?.TitleText?.Text ?? "(no title)"}' ***");
       }
       public override void VisitPageEnd(Page page)
       {
           this.AppendText(string.Empty);
       }
       public override void VisitTitleStart(Title title)
       {
           ++nodecount;
       }
       public override void VisitImageStart(Image image)
       {
           ++nodecount;
       }
       public override void VisitOutlineGroupStart(OutlineGroup outlineGroup)
       {
           ++nodecount;
       }
       public override void VisitOutlineStart(Outline outline)
       {
           ++nodecount;
       }
       public override void VisitOutlineElementStart(OutlineElement outlineElement)
       {
           ++nodecount;
       }
       public Int32 NodeCount
       {
           get { return this.nodecount; }
       }
       private readonly StringBuilder mBuilder;
       private bool mIsSkipText;
       private Int32 nodecount;
   }

DetectLayoutChanges ()

Detecta tots els canvis realitzats en el disseny del document des de l’anterior trucada Aspose.Note.Document.DetectLayoutChanges.En el cas Aspose.Note.Document.AutomaticLayoutChangesDetectionEnabled s’estableix a veritat, utilitzada automàticament al començament de l’exportació del document.

public void DetectLayoutChanges()
   {
   }

Examples

Mostra com guardar un document en diferents formats.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document() { AutomaticLayoutChangesDetectionEnabled = false };
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   ParagraphStyle textStyle = new ParagraphStyle()
   {
      FontColor = Color.Black,
      FontName = "Arial",
      FontSize = 10
   };
   page.Title = new Title(doc)
   {
      TitleText = new RichText(doc)
      {
         Text = "Title text.",
         ParagraphStyle = textStyle
      },
      TitleDate = new RichText(doc)
      {
         Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
         ParagraphStyle = textStyle
      },
      TitleTime = new RichText(doc)
      {
         Text = "12:34",
         ParagraphStyle = textStyle
      }
   };
   doc.AppendChildLast(page);
   doc.Save(dataDir + "ConsequentExportOperations_out.html");
   doc.Save(dataDir + "ConsequentExportOperations_out.pdf");
   doc.Save(dataDir + "ConsequentExportOperations_out.jpg");
   textStyle.FontSize = 11;
   doc.DetectLayoutChanges();
   doc.Save(dataDir + "ConsequentExportOperations_out.bmp");

Història de les pàgines (Page)

Obtén l’Aspose.Note.PageHistory que conté un historial complet per a cada pàgina presentada en un document (el primer en indice 0).L’actual revisió de la pàgina es pot accedir com a Aspose.Note.PageHistory.Current i conté separadament de les versions històriques.

public PageHistory GetPageHistory(Page page)
    {
    }
I have reformatted the given C# code by:
- Properly indented the method body and comments.
- Added a single space between the opening brace, method name, and opening parenthesis.
- Added a single line between the method signature and its implementation.
- Added two spaces for each level of nesting within the method body for improved readability.

Parameters

page Page

La revisió actual d’una pàgina.

Returns

PageHistory

L’Aspose.Note.Page Història

Examples

Mostra com restaurar la versió anterior d’una pàgina.

string dataDir = RunExamples.GetDataDir_Pages();
   Document document = new Document(dataDir + "Aspose.one");
   Page page = document.FirstChild;
   Page previousPageVersion = document.GetPageHistory(page).Last();
   document.RemoveChild(page);
   document.AppendChildLast(previousPageVersion);
   document.Save(dataDir + "RollBackRevisions_out.one");

Mostra com editar la història de la pàgina.

string dataDir = RunExamples.GetDataDir_Pages();
   Document document = new Document(dataDir + "Aspose.one");
   Page page = document.FirstChild;
   var pageHistory = document.GetPageHistory(page);
   pageHistory.RemoveRange(0, 1);
   pageHistory[0] = new Page(document);
   if (pageHistory.Count > 1)
   {
       pageHistory[1].Title.TitleText.Text = "New Title";
       pageHistory.Add(new Page(document));
       pageHistory.Insert(1, new Page(document));
       document.Save(dataDir + "ModifyPageHistory_out.one");
   }

Mostra com comprovar si una pàgina és un conflicte (és a dir, té canvis que OneNote no podia fusionar automàticament).

string dataDir = RunExamples.GetDataDir_Pages();
   Document doc = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
   var history = doc.GetPageHistory(doc.FirstChild);
   for (int i = 0; i < history.Count; i++)
   {
       var historyPage = history[i];
       Console.Write("    {0}. Author: ", i);
       Console.Write("{1}, ", historyPage.PageContentRevisionSummary.AuthorMostRecent);
       Console.WriteLine("{2:dd.MM.yyyy hh.mm.ss}", historyPage.PageContentRevisionSummary.LastModifiedTime);
       Console.WriteLine(historyPage.IsConflictPage ? ", IsConflict: true" : string.Empty);
       if (historyPage.IsConflictPage)
           historyPage.IsConflictPage = false;
   }
   doc.Save(dataDir + "ConflictPageManipulation_out.one", SaveFormat.One);

Importació (Stream, PdfImportOptions, Mergeoptions)

Importa un conjunt de pàgines del document PDF proporcionat.

public Document Import(Stream stream, PdfImportOptions importOptions = null, MergeOptions mergeOptions = null)
   {
   }

Parameters

stream Stream

Un flux amb el document PDF.

importOptions PdfImportOptions

Especifica les opcions com importar pàgines del document PDF.

mergeOptions MergeOptions

Especifica les opcions com fusionar pàgines proporcionades.

Returns

Document

Retornar la referència al document.

Importació (string, PdfImportOptions, Mergeoptions)

Importa un conjunt de pàgines del document PDF proporcionat.

public Document Import(string file, PdfImportOptions importOptions = null, MergeOptions mergeOptions = null)
   {
   }

Parameters

file string

Un arxiu amb un document PDF.

importOptions PdfImportOptions

Especifica les opcions com importar pàgines del document PDF.

mergeOptions MergeOptions

Especifica les opcions com fusionar pàgines proporcionades.

Returns

Document

Retornar la referència al document.

Examples

Mostra com importar totes les pàgines d’un conjunt de documents PDF per pàgina.

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"));

Mostra com importar totes les pàgines d’un conjunt de documents PDF mentre s’insereixes per cada document PDF com a fills de la pàgina OneNote de nivell superior.

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
            .SetTitleText(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"));

Mostra com importar tots els continguts d’un conjunt de documents PDF mentre s’uneixen pàgines de cada document PDF a una sola pàgina de OneNote.

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"));

Importació (Stream, HtmlImportOptions, Mergeoptions)

Importa un conjunt de pàgines del document HTML proporcionat.

public Document Import(
       Stream stream,
       HtmlImportOptions importOptions,
       MergeOptions mergeOptions = null)
   {
   }

Parameters

stream Stream

Un flux amb el document HTML.

importOptions HtmlImportOptions

Especifica les opcions com importar pàgines del document HTML.

mergeOptions MergeOptions

Especifica les opcions com fusionar pàgines proporcionades.

Returns

Document

Retornar la referència al document.

Importació (string, HtmlImportOptions, MergeOpcions)

Importa un conjunt de pàgines del document HTML proporcionat.

public Document Import(string file, HtmlImportOptions importOptions, MergeOptions mergeOptions = null)
   {
   }

Parameters

file string

Un arxiu amb document HTML.

importOptions HtmlImportOptions

Especifica les opcions com importar pàgines del document HTML.

mergeOptions MergeOptions

Especifica les opcions com fusionar pàgines proporcionades.

Returns

Document

Retornar la referència al document.

IsEncrypted(Stream, Opcions de càrrega, Document fora)

Verifica si un document d’un flux està encryptat.Per comprovar-ho hem de carregar completament aquest document. Per tant, aquest mètode pot conduir a la pena de rendiment.

public static bool IsEncrypted(Stream stream, LoadOptions options, out Document document)
{
    document = null;
    try
    {
        document = new Document();
        document.Load(stream, options);
        return document.IsEncrypted;
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
    return false;
}

Parameters

stream Stream

El corrent.

options LoadOptions

Opcions de càrrega.

document Document

El document carregat.

Returns

bool

Retorna veritat si el document està encryptat d’una altra manera fals.

Examples

Mostra com comprovar si un document està protegit amb contrasenya.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (!Document.IsEncrypted(fileName, out document))
   {
       Console.WriteLine("The document is loaded and ready to be processed.");
   }
   else
   {
       Console.WriteLine("The document is encrypted. Provide a password.");
   }

Mostra com comprovar si un document està protegit per una contrasenya específica.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
   {
       if (document != null)
       {
           Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
       }
       else
       {
           Console.WriteLine("The document is encrypted. Invalid password was provided.");
       }
   }
   else
   {
       Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
   }

IsEncrypted(Stream, string, document fora)

Verifica si un document d’un flux està encryptat.Per comprovar-ho hem de carregar completament aquest document. Per tant, aquest mètode pot conduir a la pena de rendiment.

public static bool IsEncrypted(Stream stream, string password, out Document document)
{
    document = null;
    try
    {
        document = new Document();
        document.Load(stream, Aspose.Words.FileFormatUtil.DetectEncryptionType(stream), password);
    }
    catch (Exception ex)
    {
        return false;
    }
    return true;
}

Parameters

stream Stream

El corrent.

password string

La contrasenya per desxifrar un document.

document Document

El document carregat.

Returns

bool

Retorna veritat si el document està encryptat d’una altra manera fals.

Examples

Mostra com comprovar si un document està protegit amb contrasenya.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (!Document.IsEncrypted(fileName, out document))
   {
       Console.WriteLine("The document is loaded and ready to be processed.");
   }
   else
   {
       Console.WriteLine("The document is encrypted. Provide a password.");
   }

Mostra com comprovar si un document està protegit per una contrasenya específica.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
   {
       if (document != null)
       {
           Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
       }
       else
       {
           Console.WriteLine("The document is encrypted. Invalid password was provided.");
       }
   }
   else
   {
       Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
   }

IsEncrypted (Stream, fora del document)

Verifica si un document d’un flux està encryptat.Per comprovar-ho hem de carregar completament aquest document. Per tant, aquest mètode pot conduir a la pena de rendiment.

public static bool IsEncrypted(Stream stream, out Document document)
{
    document = null;
    try
    {
        document = new Document();
        document.Load(stream);
        return document.EncryptionSettings != null && document.EncryptionSettings.IsEncrypted;
    }
    catch
    {
        document = null;
        throw;
    }
}

Parameters

stream Stream

El corrent.

document Document

El document carregat.

Returns

bool

Retorna veritat si el document està encryptat d’una altra manera fals.

Examples

Mostra com comprovar si un document està protegit amb contrasenya.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (!Document.IsEncrypted(fileName, out document))
   {
       Console.WriteLine("The document is loaded and ready to be processed.");
   }
   else
   {
       Console.WriteLine("The document is encrypted. Provide a password.");
   }

Mostra com comprovar si un document està protegit per una contrasenya específica.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
   {
       if (document != null)
       {
           Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
       }
       else
       {
           Console.WriteLine("The document is encrypted. Invalid password was provided.");
       }
   }
   else
   {
       Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
   }

IsEncrypted(string, Opcions de càrrega, Document fora)

Verifica si un document d’un arxiu està encryptat.Per comprovar-ho hem de carregar completament aquest document. Per tant, aquest mètode pot conduir a la pena de rendiment.

public static bool IsEncrypted(string filePath, LoadOptions options, out Document document)
    {
        document = null;
        try
        {
            using (var doc = new Document(File.OpenRead(filePath), options))
            {
                document = doc;
                return false;
            }
        }
        catch (InvalidPasswordException ex)
        {
            document = null;
            return true;
        }
    }

Parameters

filePath string

El camí del fitxer.

options LoadOptions

Opcions de càrrega.

document Document

El document carregat.

Returns

bool

Retorna veritat si el document està encryptat d’una altra manera fals.

Examples

Mostra com comprovar si un document està protegit amb contrasenya.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (!Document.IsEncrypted(fileName, out document))
   {
       Console.WriteLine("The document is loaded and ready to be processed.");
   }
   else
   {
       Console.WriteLine("The document is encrypted. Provide a password.");
   }

Mostra com comprovar si un document està protegit per una contrasenya específica.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
   {
       if (document != null)
       {
           Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
       }
       else
       {
           Console.WriteLine("The document is encrypted. Invalid password was provided.");
       }
   }
   else
   {
       Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
   }

IsEncrypted (string, fora del document)

Verifica si un document d’un arxiu està encryptat.Per comprovar-ho hem de carregar completament aquest document. Per tant, aquest mètode pot conduir a la pena de rendiment.

public static bool IsEncrypted(string filePath, out Document document)
{
    document = null;
    try
    {
        Aspose.Words.Document asposeDoc = new Aspose.Words.Document(filePath);
        document = asposeDoc;
        return asposeDoc.ProtectionSettings.EncryptionInfo != null;
    }
    catch (Exception ex)
    {
    }
    document = null;
    return false;
}

Parameters

filePath string

El camí del fitxer.

document Document

El document carregat.

Returns

bool

Retorna veritat si el document està encryptat d’una altra manera fals.

Examples

Mostra com comprovar si un document està protegit amb contrasenya.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (!Document.IsEncrypted(fileName, out document))
   {
       Console.WriteLine("The document is loaded and ready to be processed.");
   }
   else
   {
       Console.WriteLine("The document is encrypted. Provide a password.");
   }

Mostra com comprovar si un document està protegit per una contrasenya específica.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
   {
       if (document != null)
       {
           Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
       }
       else
       {
           Console.WriteLine("The document is encrypted. Invalid password was provided.");
       }
   }
   else
   {
       Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
   }

IsEncrypted(string, string, document fora)

Verifica si un document d’un arxiu està encryptat.Per comprovar-ho hem de carregar completament aquest document. Per tant, aquest mètode pot conduir a la pena de rendiment.

public static bool IsEncrypted(string filePath, string password, out Document document)
{
}

Parameters

filePath string

El camí del fitxer.

password string

La contrasenya per desxifrar un document.

document Document

El document carregat.

Returns

bool

Retorna veritat si el document està encryptat d’una altra manera fals.

Examples

Mostra com comprovar si un document està protegit amb contrasenya.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (!Document.IsEncrypted(fileName, out document))
   {
       Console.WriteLine("The document is loaded and ready to be processed.");
   }
   else
   {
       Console.WriteLine("The document is encrypted. Provide a password.");
   }

Mostra com comprovar si un document està protegit per una contrasenya específica.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fileName = Path.Combine(dataDir, "Aspose.one");
   Document document;
   if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
   {
       if (document != null)
       {
           Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
       }
       else
       {
           Console.WriteLine("The document is encrypted. Invalid password was provided.");
       }
   }
   else
   {
       Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
   }

Mèxic (Ineumeracióde les opcions)

Mireu una sèrie de pàgines al document.

public Document Merge(IEnumerable<Page> pages, MergeOptions mergeOptions = null)
   {
   }

Parameters

pages IEnumerable < Page >

Un conjunt de pàgines.

mergeOptions MergeOptions

Especifica les opcions com fusionar pàgines proporcionades.

Returns

Document

Retornar la referència al document.

Examples

Mostra com importar totes les pàgines del document PDF grupant cada 5 pàgs a una sola pàgina de OneNote.

string dataDir = RunExamples.GetDataDir_Import();
   var d = new Document();
   var mergeOptions = new MergeOptions() { ImportAsSinglePage = true, PageSpacing = 100 };
   IEnumerable<Page> pages = PdfImporter.Import(Path.Combine(dataDir, "SampleGrouping.pdf"));
   while (pages.Any())
   {
       d.Merge(pages.Take(5), mergeOptions);
       pages = pages.Skip(5);
   }
   d.Save(Path.Combine(dataDir, "sample_CustomMerge.one"));

Impressió ()

Imprimir el document utilitzant la impresora estàndard.

public void Print()
   {
   }

Examples

Mostra com enviar un document a una impressora utilitzant el diàleg de Windows estàndard amb opcions de default.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   var document = new Aspose.Note.Document(dataDir + "Aspose.one");
   document.Print();

Mostra com enviar un document a una impressora utilitzant el diàleg de Windows estàndard amb opcions especificades.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   var document = new Aspose.Note.Document(dataDir + "Aspose.one");
   var printerSettings = new PrinterSettings()
   {
      FromPage = 0,
      ToPage = 10
   };
   printerSettings.DefaultPageSettings.Landscape = true;
   printerSettings.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(50, 50, 150, 50);
   document.Print(new PrintOptions()
   {
      PrinterSettings = printerSettings,
      Resolution = 1200,
      PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(),
      DocumentName = "Test.one"
   });

Impressió (Print Options)

Imprimir el document utilitzant la impresora estàndard.

public void Print(PrintOptions options)
   {
   }

Parameters

options PrintOptions

Opcions utilitzades per imprimir un document. pot ser nul.

Llegir més (string)

Salva el document OneNote a un arxiu.

public void Save(string fileName)
   {
   }

Parameters

fileName string

Si ja existeix un arxiu amb el nom complet especificat, el fitxer existent es reescriu.

Examples

Mostra com salvar un document.

string inputFile = "Sample1.one";
   string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string outputFile = "SaveDocToOneNoteFormat_out.one";
   Document doc = new Document(dataDir + inputFile);
   doc.Save(dataDir + outputFile);

Exceptions

IncorrectDocumentStructureException

L’estructura del document viola la especificació.

UnsupportedSaveFormatException

El format de salvament sol·licitat no es dóna suport.

El trànsit (Stream)

Salva el document OneNote a un flux.

public void Save(Stream stream)
   {
   }

Parameters

stream Stream

El sistema.IO.Stream on es salvarà el document.

Exceptions

IncorrectDocumentStructureException

L’estructura del document viola la especificació.

UnsupportedSaveFormatException

El format de salvament sol·licitat no es dóna suport.

Salvació (string, SaveFormat)

Salva el document OneNote a un arxiu en el format especificat.

public void Save(string fileName, Aspose.Words.SaveFormat format)
   {
   }

Parameters

fileName string

Si ja existeix un arxiu amb el nom complet especificat, el fitxer existent es reescriu.

format SaveFormat

El format en el qual guardar el document.

Examples

Mostra com salvar un document utilitzant l’enumeració de SaveFormat.

string inputFile = "Sample1.one";
   string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string outputFile = "SaveDocToOneNoteFormatUsingSaveFormat_out.one";
   Document document = new Document(dataDir + inputFile);
   document.Save(dataDir + outputFile, SaveFormat.One);

Mostra com guardar un document en format gif.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveToImageDefaultOptions_out.gif";
   oneFile.Save(dataDir, SaveFormat.Gif);

Exceptions

IncorrectDocumentStructureException

L’estructura del document viola la especificació.

UnsupportedSaveFormatException

El format de salvament sol·licitat no es dóna suport.

Salvació (Stream i SaveFormat)

Salva el document OneNote a un flux en el format especificat.

public void Save(Stream stream, SaveFormat format)
   {
   }

Parameters

stream Stream

El sistema.IO.Stream on es salvarà el document.

format SaveFormat

El format en el qual guardar el document.

Examples

Mostra com guardar un document en format pdf utilitzant les configuracions predefinides.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   string dataDirWithFileName = dataDir + "SaveWithDefaultSettings_out.pdf";
   oneFile.Save(dataDirWithFileName, SaveFormat.Pdf);

Mostra com guardar un document a un flux.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document(dataDir + "Aspose.one");
   MemoryStream dstStream = new MemoryStream();
   doc.Save(dstStream, SaveFormat.Pdf);
   dstStream.Seek(0, SeekOrigin.Begin);

Mostra com aplicar l’estil temàtic fosc a un document.

string dataDir = RunExamples.GetDataDir_Text();
   Document doc = new Document(Path.Combine(dataDir, "Aspose.one"));
   foreach (var page in doc)
   {
       page.BackgroundColor = Color.Black;
   }
   foreach (var node in doc.GetChildNodes<Aspose.Words.RichText>())
   {
       var c = node.ParagraphStyle.FontColor;
       if (c.IsEmpty || Math.Abs(c.R - Color.Black.R) + Math.Abs(c.G - Color.Black.G) + Math.Abs(c.B - Color.Black.B) <= 30)
       {
           node.ParagraphStyle.FontColor = Color.White;
       }
   }
   doc.Save(Path.Combine(dataDir, "AsposeDarkTheme.pdf"));

Exceptions

IncorrectDocumentStructureException

L’estructura del document viola la especificació.

UnsupportedSaveFormatException

El format de salvament sol·licitat no es dóna suport.

Salvació (string, SaveOptions)

Salva el document OneNote a un arxiu utilitzant les opcions especificades.

public void Save(string fileName, SaveOptions options)
{
}

Parameters

fileName string

Si ja existeix un arxiu amb el nom complet especificat, el fitxer existent es reescriu.

options SaveOptions

Especifica les opcions de com s’emmagatzema el document en el fitxer.

Examples

Mostra com salvar un document utilitzant OneSaveOptions.

string inputFile = "Sample1.one";
   string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string outputFile = "SaveDocToOneNoteFormatUsingOneSaveOptions_out.one";
   Document document = new Document(dataDir + inputFile);
   document.Save(dataDir + outputFile, new OneSaveOptions());

Mostra com guardar un document com a imatge en format Jpeg utilitzant SaveFormat.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveToJpegImageUsingSaveFormat_out.jpg";
   oneFile.Save(dataDir, SaveFormat.Jpeg);

Mostra com guardar un document com a imatge en format Bmp utilitzant ImageSaveOptions.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveToBmpImageUsingImageSaveOptions_out.bmp";
   oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Bmp));

Mostra com guardar un document en format PDF amb el disseny de la pàgina de lletra.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "OneNote.one");
   var dst = Path.Combine(dataDir, "SaveToPdfUsingLetterPageSettings.pdf");
   oneFile.Save(dst, new PdfSaveOptions() { PageSettings = PageSettings.Letter });

Mostra com guardar un document en format PDF amb el disseny de la pàgina A4 sense límit d’altura.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "OneNote.one");
   var dst = Path.Combine(dataDir, "SaveToPdfUsingA4PageSettingsWithoutHeightLimit.pdf");
   oneFile.Save(dst, new PdfSaveOptions() { PageSettings = PageSettings.A4NoHeightLimit });

Mostra com guardar un document com a imatge de graix.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveAsGrayscaleImage_out.png";
   oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
   {
      ColorMode = ColorMode.GrayScale
   });

Mostra com guardar un document com a imatge en format Tiff utilitzant la compressió PackBits.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
   var dst = Path.Combine(dataDir, "SaveToTiffUsingPackBitsCompression.tiff");
   oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
                  {
                      TiffCompression = TiffCompression.PackBits
                  });

Mostra com guardar un document com a imatge en format Tiff utilitzant la compressió Jpeg.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
   var dst = Path.Combine(dataDir, "SaveToTiffUsingJpegCompression.tiff");
   oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
   {
      TiffCompression = TiffCompression.Jpeg,
      Quality = 93
   });

Mostra com guardar un document com a imatge en format Tiff utilitzant la compressió de fax CCITT Group 3.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
   var dst = Path.Combine(dataDir, "SaveToTiffUsingCcitt3Compression.tiff");
   oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
   {
      ColorMode = ColorMode.BlackAndWhite,
      TiffCompression = TiffCompression.Ccitt3
   });

Mostra com guardar un document en format PDF.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   PdfSaveOptions opts = new PdfSaveOptions()
   {
      PageIndex = 0,
      PageCount = 1,
   };
   dataDir += "SaveRangeOfPagesAsPDF_out.pdf";
   oneFile.Save(dataDir, opts);

Mostra com guardar un document en format pdf utilitzant configuracions específiques.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document(dataDir + "Aspose.one");
   PdfSaveOptions opts = new PdfSaveOptions
   {
      ImageCompression = Saving.Pdf.PdfImageCompression.Jpeg,
      JpegQuality = 90
   };
   dataDir += "Document.SaveWithOptions_out.pdf";
   doc.Save(dataDir, opts);

Mostra com salvar un document com a imatge binària utilitzant el mètode de Otsu.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveToBinaryImageUsingOtsuMethod_out.png";
   oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
   {
      ColorMode = ColorMode.BlackAndWhite,
      BinarizationOptions = new ImageBinarizationOptions()
      {
         BinarizationMethod = BinarizationMethod.Otsu,
      }
   });

Mostra com salvar un document com a imatge binària utilitzant un límit fix.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveToBinaryImageUsingFixedThreshold_out.png";
   oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
   {
       ColorMode = ColorMode.BlackAndWhite,
       BinarizationOptions = new ImageBinarizationOptions()
       {
           BinarizationMethod = BinarizationMethod.FixedThreshold,
           BinarizationThreshold = 123
       }
   });

Exceptions

IncorrectDocumentStructureException

L’estructura del document viola la especificació.

UnsupportedSaveFormatException

El format de salvament sol·licitat no es dóna suport.

Salvació (Stream, SaveOptions)

Salva el document OneNote a un flux utilitzant les opcions especificades de salvatge.

public void Save(Stream stream, SaveOptions options)
   {
   }

Parameters

stream Stream

El sistema.IO.Stream on es salvarà el document.

options SaveOptions

Especifica les opcions de com s’emmagatzema el document en flux.

Examples

Mostra com guardar un document en format pdf utilitzant fonts de default especificats.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
   string dataDirWithOutputPath = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontName_out.pdf";
   oneFile.Save(dataDirWithOutputPath, new PdfSaveOptions()
   {
       FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFont("Times New Roman")
   });

Mostra com guardar un document en format pdf utilitzant font de default d’un fitxer.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fontFile = Path.Combine(dataDir, "geo_1.ttf");
   Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
   string outputFile = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromFile_out.pdf";
   oneFile.Save(outputFile, new PdfSaveOptions()
                              {
                                FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromFile(fontFile)
                              });

Mostra com guardar un document en format pdf utilitzant fonts predefinides d’un flux.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   string fontFile = Path.Combine(dataDir, "geo_1.ttf");
   Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
   string fullDataDir = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromStream_out.pdf";
   using (var stream = File.Open(fontFile, FileMode.Open, FileAccess.Read, FileShare.Read))
   {
       oneFile.Save(fullDataDir, new PdfSaveOptions()
       {
           FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromStream(stream)
       });
   }

Exceptions

IncorrectDocumentStructureException

L’estructura del document viola la especificació.

UnsupportedSaveFormatException

El format de salvament sol·licitat no es dóna suport.

 Català