Class KeepSolidObjectsAlgorithm

Class KeepSolidObjectsAlgorithm

Namespace: Aspose.Note.Saving
Assembly: Aspose.Note.dll (25.6.0)

Shifts full object to the next page in case it doesn’t fit in original page.

public class KeepSolidObjectsAlgorithm : PageSplittingAlgorithm
{
    private readonly double _minimumPageHeight;
    public KeepSolidObjectsAlgorithm(double minimumPageHeight)
    {
        _minimumPageHeight = minimumPageHeight;
    }
    protected override void PrepareDocument(Document doc)
    {
    }
    protected override PageInfo BreakAfter(Section section, SectionBreak breakType)
    {
        if (section.Body != null && section.Body.Paragraphs.Count > 0)
        {
            var lastParagraph = section.Body.Paragraphs[section.Body.Paragraphs.Count - 1];
            if (lastParagraph.HasChild(NodeType.Shape) || lastParagraph.HasChild(NodeType.Table))
            {
                return null;
            }
        }
    }
}

Inheritance

object PageSplittingAlgorithm KeepSolidObjectsAlgorithm

Inherited Members

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Shows how to save notebook in pdf format with specified options.

string dataDir = RunExamples.GetDataDir_NoteBook();
    var notebook = new Notebook(dataDir + "Notizbuch Öffnen.onetoc2");
    var notebookSaveOptions = new NotebookPdfSaveOptions();
    var documentSaveOptions = notebookSaveOptions.DocumentSaveOptions;
    documentSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm();
    dataDir += "ConvertToPDF_out.pdf";
    notebook.Save(dataDir, notebookSaveOptions);

Shows how to sent document to a printer using standard Windows dialog with specified options.

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

When long OneNote pages are saved in pdf format they are split across pages. The example shows how to configure the splitting logic of objects located on page’s breaks.

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

Constructors

KeepSolidObjectsAlgorithm()

Initializes a new instance of the Aspose.Note.Saving.KeepSolidObjectsAlgorithm class using default height limit of cloned part.

public KeepSolidObjectsAlgorithm()
   {
   }

KeepSolidObjectsAlgorithm(float)

Initializes a new instance of the Aspose.Note.Saving.KeepSolidObjectsAlgorithm class using specific height limit of cloned part.

public KeepSolidObjectsAlgorithm(float heightLimitOfClonedPart)
   {
   }

Parameters

heightLimitOfClonedPart float

The max height of cloned part.

Fields

DefaultHeightLimitOfClonedPart

The default max size of cloned part.

public const float DefaultHeightLimitOfClonedPart = 200;

Field Value

float

Properties

HeightLimitOfClonedPart

Gets the height limit of cloned part.

public float HeightLimitOfClonedPart
   {
      get
      {
      }
   }

Property Value

float

 English