Class Document

Class Document

nazivni prostor: Aspose.Note Sastav: Aspose.Note.dll (25.4.0)

Predstavlja dokument 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

naslijeđeni članovi

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

Prikazuje kako poslati dokument na štampač pomoću standardnog Windows dijaloga s privremenim opcijama.

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

Pokaži kako sačuvati dokument.

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

Pokaži kako napraviti šifrirani dokument.

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

Prikazuje kako sačuvati dokument s šifriranjem.

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

Prikazuje kako sačuvati dokument pomoću SaveFormat popisa.

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

Prikazuje kako sačuvati dokument pomoću 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());

Pokaži kako dobiti broj stranice dokumenta.

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

Prikazuje kako sačuvati dokument u PDF formatu pomoću privremenih postavki.

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

Prikazuje kako sačuvati dokument u gif formatu.

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

Pokaže kako postaviti kvalitetu slike kada sačuvate dokument kao sliku u JPEG formatu.

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

Pokaže kako postaviti rezoluciju slike kada sačuvate dokument kao sliku.

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

Prikazuje kako dobiti format datoteke dokumenta.

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;
   }

Prikazuje kako povezati hiperpovezivanje s slikom.

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

Pokaže kako sačuvati dokument u toku.

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

Pokaže kako provjeriti je li dokument zaštićen lozinkom.

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

Prikazuje kako dodati novi odjeljak u 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);

Prikazuje kako provjeriti je li dokument neuspješan jer OneNote 2007 format nije podržan.

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;
      }
   }

Prikazuje kako vratiti prethodnu verziju stranice.

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

Prikazuje kako klonirati stranicu.

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

Pokaže kako sačuvati dokument u html formatu sa čuvanjem svih resursa (css/fonts/images) u odvojenom datoteku.

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

Pokaže kako sačuvati dokument u toku u html formatu s uključivanjem svih resursa (css/fonts/images).

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

Pokaže kako postaviti opis teksta za sliku.

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

Pokaži kako dobiti meta informacije o stranici.

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();
   }

Kada su duge OneNote stranice sačuvane u PDF formatu, oni su podijeljeni po stranicama. uzorak pokazuje kako konfigurirati logiku podjele objekata koji se nalaze na razbijanjima stranice.

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

Prikazuje kako sačuvati dokument u formatu 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);

Pokaži kako urediti povijest stranice.

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

Pokaže kako provjeriti je li dokument zaštićen određenim lozinkom.

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

Prikazuje kako primijeniti Dark Theme stil na dokument.

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

Prikazuje kako proći kroz sadržaj notebooka.

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

Pokaži kako dobiti sliku iz dokumenta.

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

Prikazuje kako sačuvati dokument u PDF formatu.

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

Pokaže kako sačuvati dokument u PDF formatu pomoću određenih postavki.

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

Prikazuje kako poslati dokument na štampač pomoću standardnog Windows dijaloga s određenim opcijama.

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

Pokaže kako dobiti sadržaj priključenog datoteke.

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

Pokaže kako dobiti meta informacije slike.

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();
   }

Pokaži kako dobiti povijest stranice.

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();
   }

Prikazuje kako dodati datoteku u dokument pomoću FilePath.

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

Prikazuje kako stvoriti dokument i sačuvati ga u html formatu pomoću privremenih opcija.

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

Pokaže kako provjeriti je li stranica stranica sukoba (tj. ima promjene koje OneNote nije mogao automatski spajati).

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

Pokaže kako dodati sliku iz datoteke u dokument s korisnički definiranim svojstvima.

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

Pokaže kako dodati datoteku iz struje u dokument.

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

Kada su duge OneNote stranice sačuvane u PDF formatu, oni su podijeljeni po stranicama. primjer pokazuje kako konfigurirati logiku podjele objekata koji se nalaze na prekidima stranice.

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

Pokaže kako stvoriti dokument i sačuvati u HTML formatu određeni raspon stranica.

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

Prikazuje kako stvoriti dokument s naslovom stranice.

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

Pokaže kako dodati sliku iz struje u dokument.

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

Pokaže kako dodati sliku iz datoteke u dokument.

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

Prikazuje kako stvoriti dokument s tekstom.

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

Prikazuje kako sačuvati dokument u različitim formatima.

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

Pokaže kako sačuvati dokument u html formatu sa čuvanjem svih resursa (css/fonts/images) pomoću korisnički definiranih poziva.

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 */");
   }

Prikazuje kako povezati hiperpovezivanje s tekstom.

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

Prikazuje kako pristupiti sadržaju dokumenta pomoću posjetitelja.

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

Izvješće)

Inicijalizira novu primjenu Aspose.Note.Dokument razreda.Stvaranje bijelog OneNote dokumenta.

public Document()
   {
   }

Izvješće ( String )

Inicijalizira novu primjenu Aspose.Note.Dokument razreda.Otvori postojeći OneNote dokument iz datoteke.

public Document(string filePath)
   {
   }

Parameters

filePath string

Podaci o dosjeu.

Exceptions

UnsupportedFileFormatException

Format dokumenta nije prepoznat ili podržan.

FileCorruptedException

Izgleda da je dokument korumpiran i ne može se opterećivati.

IncorrectPasswordException

Dokument je šifriran i zahtijeva lozinku da se otvori, ali ste pružili pogrešnu lozinku.

InvalidOperationException

Postoji problem s dokumentom i treba ga obavijestiti razvijalcima Aspose.Note.

IOException

Postoji iznimka od ulaza i izlaska.

Obavijest (string, LoadOptions)

Inicijalizira novu primjenu Aspose.Note.Dokument razreda.Otvara postojeće OneNote dokument iz datoteke. omogućuje da navedete dodatne opcije kao što je lozinka za šifriranje.

public Document(string filePath, LoadOptions loadOptions)
   {
   }

Parameters

filePath string

Podaci o dosjeu.

loadOptions LoadOptions

Opcije koje se koriste za punjenje dokumenta. može biti nula.

Exceptions

UnsupportedFileFormatException

Format dokumenta nije prepoznat ili podržan.

FileCorruptedException

Izgleda da je dokument korumpiran i ne može se opterećivati.

IncorrectPasswordException

Dokument je šifriran i zahtijeva lozinku da se otvori, ali ste pružili pogrešnu lozinku.

InvalidOperationException

Postoji problem s dokumentom i treba ga obavijestiti razvijalcima Aspose.Note.

IOException

Postoji iznimka od ulaza i izlaska.

Izvješće o prijenosu (Stream)

Inicijalizira novu primjenu Aspose.Note.Dokument razreda.Otvori postojeći OneNote dokument iz struje.

public Document(Stream inStream)
   {
   }

Parameters

inStream Stream

U toku je.

Exceptions

UnsupportedFileFormatException

Format dokumenta nije prepoznat ili podržan.

FileCorruptedException

Izgleda da je dokument korumpiran i ne može se opterećivati.

IncorrectPasswordException

Dokument je šifriran i zahtijeva lozinku da se otvori, ali ste pružili pogrešnu lozinku.

InvalidOperationException

Postoji problem s dokumentom i treba ga obavijestiti razvijalcima Aspose.Note.

IOException

Postoji iznimka od ulaza i izlaska.

ArgumentException

Stream ne podržava čitanje, je nula ili je već zatvoren.

Obavijest (Stream, LoadOptions)

Inicijalizira novu primjenu Aspose.Note.Dokument razreda.Otvara postojeće OneNote dokument iz struje. omogućuje da navedete dodatne opcije kao što je lozinka za šifriranje.

public Document(Stream inStream, LoadOptions loadOptions)
   {
   }

Parameters

inStream Stream

U toku je.

loadOptions LoadOptions

Opcije koje se koriste za punjenje dokumenta. može biti nula.

Exceptions

UnsupportedFileFormatException

Format dokumenta nije prepoznat ili podržan.

FileCorruptedException

Izgleda da je dokument korumpiran i ne može se opterećivati.

IncorrectPasswordException

Dokument je šifriran i zahtijeva lozinku da se otvori, ali ste pružili pogrešnu lozinku.

InvalidOperationException

Postoji problem s dokumentom i treba ga obavijestiti razvijalcima Aspose.Note.

IOException

Postoji iznimka od ulaza i izlaska.

ArgumentException

Stream ne podržava čitanje, je nula ili je već zatvoren.

Properties

AutomaticLayoutChangesDetectionEnabled

Dobiva ili postavlja vrijednost koja ukazuje na to da li Aspose.Note obavlja otkrivanje promjena rasporeda automatski.

public bool AutomaticLayoutChangesDetectionEnabled
   {
      get;
      set;
   }

Vrijednost nekretnina

bool

Examples

Prikazuje kako sačuvati dokument u različitim formatima.

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

Uzmite ili postavite boju.

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

Vrijednost nekretnina

Color

CreationTime

Dostaje ili određuje vrijeme stvaranja.

public DateTime CreationTime
   {
      get;
      set;
   }

Vrijednost nekretnina

DateTime

DisplayName

Pronađite ili postavite ime prikaza.

public string DisplayName
   {
      get;
      set;
   }

Vrijednost nekretnina

string

FileFormat

Pronađite formatu datoteke (OneNote 2010, OneNota Online).

public FileFormat FileFormat
   {
      get;
   }

Vrijednost nekretnina

FileFormat

Examples

Prikazuje kako dobiti format datoteke dokumenta.

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

Dobiva jedinstvenu globalnu identifikaciju objekta.

public Guid Guid
   {
      get;
   }

Vrijednost nekretnina

Guid

Methods

Prihvaćanje (DokumentVisitor)

Prihvaćaju posjetitelja čvorova.

public override void Accept(DocumentVisitor visitor)
   {
   }

Parameters

visitor DocumentVisitor

Objekt klase koji proizlazi iz Aspose.Note.DocumentVisitor.

Examples

Prikazuje kako pristupiti sadržaju dokumenta pomoću posjetitelja.

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;
   }

Sljedeći Članak DetectLayoutChanges()

Otkrije sve promjene napravljene u rasporedu dokumenta od prethodnog Aspose.Note.Document.DetectLayoutChanges poziva.U slučaju Aspose.Note.Document.AutomaticLayoutChangesDetectionEnabled postavljen na istinit, koristi se automatski na početku izvoza dokumenta.

public void DetectLayoutChanges()
   {
   }

Examples

Prikazuje kako sačuvati dokument u različitim formatima.

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

Povijesna stranica (Page)

Pronađite Aspose.Note.PageHistory koji sadrži punu povijest za svaku stranicu predstavljenu u dokumentu (najprije na indeksu 0).Trenutačna revizija stranice može se pristupiti kao Aspose.Note.PageHistory.Current i sadržana odvojeno od zbirke povijesnih verzija.

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

Trenutačna revizija stranice.

Returns

PageHistory

Slijedeći članakNote.PageHistory

Examples

Prikazuje kako vratiti prethodnu verziju stranice.

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

Pokaži kako urediti povijest stranice.

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

Pokaže kako provjeriti je li stranica stranica sukoba (tj. ima promjene koje OneNote nije mogao automatski spajati).

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

Uvoz (Stream, PdfImportOptions, Mergeoptions)

Importira niz stranica iz podnesenog PDF dokumenta.

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

Parameters

stream Stream

Jedan tok s PDF dokumentom.

importOptions PdfImportOptions

Nastavi opcije kako uvoziti stranice iz PDF dokumenta.

mergeOptions MergeOptions

Nastavi opcije kako se spajati pružene stranice.

Returns

Document

Povratak upućivanja na dokument.

Uvoz (string, PdfImportOptions, Mergeoptions)

Importira niz stranica iz podnesenog PDF dokumenta.

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

Parameters

file string

Dosje s PDF dokumentom.

importOptions PdfImportOptions

Nastavi opcije kako uvoziti stranice iz PDF dokumenta.

mergeOptions MergeOptions

Nastavi opcije kako se spajati pružene stranice.

Returns

Document

Povratak upućivanja na dokument.

Examples

Prikazuje kako uvoziti sve stranice iz seta PDF dokumenata stranice po stranici.

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

Prikazuje kako uvoziti sve stranice iz niza PDF dokumenata dok stavlja stranice iz svakog PDF dokumenta kao djeca na vrhu OneNote stranice.

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

Prikazuje kako uvoziti sve sadržaje iz niza PDF dokumenata dok se stranice iz svakog PDF dokumenta spajanje na jednu stranicu 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"));

Uvoz (Stream, HtmlImportOptions, Mergeoptions)

Importira niz stranica iz pruženog HTML dokumenta.

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

Parameters

stream Stream

Slijedeći tekst s HTML dokumentom.

importOptions HtmlImportOptions

Označuje opcije kako uvoziti stranice iz HTML dokumenta.

mergeOptions MergeOptions

Nastavi opcije kako se spajati pružene stranice.

Returns

Document

Povratak upućivanja na dokument.

Uvoz(string, HtmlImportOptions, Mergeoptions)

Importira niz stranica iz pruženog HTML dokumenta.

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

Parameters

file string

Dosje s HTML dokumentom.

importOptions HtmlImportOptions

Označuje opcije kako uvoziti stranice iz HTML dokumenta.

mergeOptions MergeOptions

Nastavi opcije kako se spajati pružene stranice.

Returns

Document

Povratak upućivanja na dokument.

IsEncrypted(Stream, LoadOptions, izlazak iz dokumenta)

Provjerite je li dokument iz struje šifrovan.Da bismo to provjerili, moramo u potpunosti preuzeti ovaj dokument. tako da ova metoda može dovesti do kazne za izvršenje.

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

U toku je.

options LoadOptions

Opcije za opterećenje.

document Document

Preporučen dokument.

Returns

bool

Povratak je istinit ako je dokument šifrovan drugačije lažan.

Examples

Pokaže kako provjeriti je li dokument zaštićen lozinkom.

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

Pokaže kako provjeriti je li dokument zaštićen određenim lozinkom.

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, izlazak iz dokumenta)

Provjerite je li dokument iz struje šifrovan.Da bismo to provjerili, moramo u potpunosti preuzeti ovaj dokument. tako da ova metoda može dovesti do kazne za izvršenje.

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

U toku je.

password string

Lozinka za dešifriranje dokumenta.

document Document

Preporučen dokument.

Returns

bool

Povratak je istinit ako je dokument šifrovan drugačije lažan.

Examples

Pokaže kako provjeriti je li dokument zaštićen lozinkom.

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

Pokaže kako provjeriti je li dokument zaštićen određenim lozinkom.

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, izlazak iz dokumenta)

Provjerite je li dokument iz struje šifrovan.Da bismo to provjerili, moramo u potpunosti preuzeti ovaj dokument. tako da ova metoda može dovesti do kazne za izvršenje.

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

U toku je.

document Document

Preporučen dokument.

Returns

bool

Povratak je istinit ako je dokument šifrovan drugačije lažan.

Examples

Pokaže kako provjeriti je li dokument zaštićen lozinkom.

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

Pokaže kako provjeriti je li dokument zaštićen određenim lozinkom.

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, LoadOptions, izlazak iz dokumenta)

Provjerite je li dokument iz datoteke šifrovan.Da bismo to provjerili, moramo u potpunosti preuzeti ovaj dokument. tako da ova metoda može dovesti do kazne za izvršenje.

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

Podaci o dosjeu.

options LoadOptions

Opcije za opterećenje.

document Document

Preporučen dokument.

Returns

bool

Povratak je istinit ako je dokument šifrovan drugačije lažan.

Examples

Pokaže kako provjeriti je li dokument zaštićen lozinkom.

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

Pokaže kako provjeriti je li dokument zaštićen određenim lozinkom.

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, izlazak iz dokumenta)

Provjerite je li dokument iz datoteke šifrovan.Da bismo to provjerili, moramo u potpunosti preuzeti ovaj dokument. tako da ova metoda može dovesti do kazne za izvršenje.

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

Podaci o dosjeu.

document Document

Preporučen dokument.

Returns

bool

Povratak je istinit ako je dokument šifrovan drugačije lažan.

Examples

Pokaže kako provjeriti je li dokument zaštićen lozinkom.

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

Pokaže kako provjeriti je li dokument zaštićen određenim lozinkom.

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, izlazak dokumenta)

Provjerite je li dokument iz datoteke šifrovan.Da bismo to provjerili, moramo u potpunosti preuzeti ovaj dokument. tako da ova metoda može dovesti do kazne za izvršenje.

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

Parameters

filePath string

Podaci o dosjeu.

password string

Lozinka za dešifriranje dokumenta.

document Document

Preporučen dokument.

Returns

bool

Povratak je istinit ako je dokument šifrovan drugačije lažan.

Examples

Pokaže kako provjeriti je li dokument zaštićen lozinkom.

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

Pokaže kako provjeriti je li dokument zaštićen određenim lozinkom.

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

Sjedinjene Države (Inenumerable)Uspješna opcija)

Miriše niz stranica u dokument.

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

Parameters

pages IEnumerable < Page >

Postoji niz stranica.

mergeOptions MergeOptions

Nastavi opcije kako se spajati pružene stranice.

Returns

Document

Povratak upućivanja na dokument.

Examples

Prikazuje kako uvoziti sve stranice iz PDF dokumenta skuplja svakih 5 stranica na jednu stranicu 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"));

Knjiga ( )

Pritisnite dokument pomoću privremenog štampača.

public void Print()
   {
   }

Examples

Prikazuje kako poslati dokument na štampač pomoću standardnog Windows dijaloga s privremenim opcijama.

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

Prikazuje kako poslati dokument na štampač pomoću standardnog Windows dijaloga s određenim opcijama.

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

Opcije za tiskanje (Print Options)

Pritisnite dokument pomoću privremenog štampača.

public void Print(PrintOptions options)
   {
   }

Parameters

options PrintOptions

Opcije koje se koriste za tiskanje dokumenta. može biti nula.

Sljedeći Članak Save (string)

Shrani OneNote dokument u datoteku.

public void Save(string fileName)
   {
   }

Parameters

fileName string

Ako datoteka s određenim punim imenom već postoji, postojeće je dosje prepisano.

Examples

Pokaži kako sačuvati dokument.

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

Struktura dokumenta krši specifikaciju.

UnsupportedSaveFormatException

Zatraženi format spašavanja nije podržan.

Sljedeći članakSave (Stream)

Sačuvajte OneNote dokument u toku.

public void Save(Stream stream)
   {
   }

Parameters

stream Stream

System.IO.Stream gdje će se dokument sačuvati.

Exceptions

IncorrectDocumentStructureException

Struktura dokumenta krši specifikaciju.

UnsupportedSaveFormatException

Zatraženi format spašavanja nije podržan.

Savijeti (string, SaveFormat)

Shrani dokument OneNote na datoteku u određenom formatu.

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

Parameters

fileName string

Ako datoteka s određenim punim imenom već postoji, postojeće je dosje prepisano.

format SaveFormat

Format u kojem treba sačuvati dokument.

Examples

Prikazuje kako sačuvati dokument pomoću SaveFormat popisa.

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

Prikazuje kako sačuvati dokument u gif formatu.

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

Exceptions

IncorrectDocumentStructureException

Struktura dokumenta krši specifikaciju.

UnsupportedSaveFormatException

Zatraženi format spašavanja nije podržan.

Sačuvaj (Stream i SaveFormat)

Shrani dokument OneNote u toku u određenom formatu.

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

Parameters

stream Stream

System.IO.Stream gdje će se dokument sačuvati.

format SaveFormat

Format u kojem treba sačuvati dokument.

Examples

Prikazuje kako sačuvati dokument u PDF formatu pomoću privremenih postavki.

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

Pokaže kako sačuvati dokument u toku.

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

Prikazuje kako primijeniti Dark Theme stil na dokument.

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

Struktura dokumenta krši specifikaciju.

UnsupportedSaveFormatException

Zatraženi format spašavanja nije podržan.

Save(string, opcije za spašavanje)

Shrani dokument OneNote u datoteku pomoću određenih opcija spašavanja.

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

Parameters

fileName string

Ako datoteka s određenim punim imenom već postoji, postojeće je dosje prepisano.

options SaveOptions

Nastavi opcije kako se dokument čuva u datoteci.

Examples

Prikazuje kako sačuvati dokument pomoću 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());

Prikazuje kako sačuvati dokument kao sliku u JPEG formatu pomoću SaveFormata.

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

Prikazuje kako sačuvati dokument kao sliku u Bmp formatu pomoću ImageSaveOptions.

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

Prikazuje kako sačuvati dokument u PDF formatu s postavkom stranice pisma.

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

Prikazuje kako sačuvati dokument u PDF formatu s A4 rasporedom stranice bez ograničenja visine.

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

Prikazuje kako sačuvati dokument kao grayscale sliku.

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

Prikazuje kako sačuvati dokument kao sliku u Tiff formatu pomoću kompresije 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
                  });

Prikazuje kako sačuvati dokument kao sliku u Tiff formatu pomoću Jpeg kompresije.

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

Prikazuje kako sačuvati dokument kao sliku u Tiff formatu pomoću CCITT Grupa 3 faks kompresije.

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

Prikazuje kako sačuvati dokument u PDF formatu.

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

Pokaže kako sačuvati dokument u PDF formatu pomoću određenih postavki.

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

Prikazuje kako sačuvati dokument kao binarnu sliku pomoću Metode 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,
      }
   });

Pokaže kako sačuvati dokument kao binarnu sliku pomoću fiksnog praga.

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

Struktura dokumenta krši specifikaciju.

UnsupportedSaveFormatException

Zatraženi format spašavanja nije podržan.

Save (Save opcije i prijenos)

Shrani dokument OneNote u tok pomoću određenih opcija spašavanja.

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

Parameters

stream Stream

System.IO.Stream gdje će se dokument sačuvati.

options SaveOptions

Nastavi opcije kako se dokument čuva u toku.

Examples

Pokaže kako sačuvati dokument u PDF formatu pomoću određenog podrazumevanog pisma.

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

Prikazuje kako sačuvati dokument u PDF formatu pomoću podrazumevane fontove iz datoteke.

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

Pokaže kako sačuvati dokument u PDF formatu pomoću podrazumevane fontove iz struje.

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

Struktura dokumenta krši specifikaciju.

UnsupportedSaveFormatException

Zatraženi format spašavanja nije podržan.

 Hrvatski