Class KeepPartAndCloneSolidObjectToNextPageAlgorithm

Class KeepPartAndCloneSolidObjectToNextPageAlgorithm

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

Adds object’s top part to the bottom of the page and clones full object to the next page in case it doesn’t fit in original page.

public class KeepPartAndCloneSolidObjectToNextPageAlgorithm : PageSplittingAlgorithm
{
    protected override void SplitContent(
        IDocumentPart documentPart,
        Aspose.Words.PageInfo sourcePageInfo,
        int sourcePageNumber,
        Aspose.Words.PageInfo destinationPageInfo,
        int destinationPageNumber)
    {
        if (destinationPageInfo.IsBroken())
            return;
        var solidObjects = documentPart.GetChildNodes(NodeType.Shape, true)
            .OfType<Aspose.Words.Shape>()
            .Where(so => so.HasTextFrame && !so.IsLineFormatApplied);
        foreach (var solidObject in solidObjects)
        {
            var textRun = solidObject.TextFrame.TextRuns[0];
            var clonedSolidObject = solidObject.Clone();
            documentPart.InsertChild(clonedSolidObject, 0);
            textRun.Text = string.Empty;
        }
    }
}

Inheritance

object PageSplittingAlgorithm KeepPartAndCloneSolidObjectToNextPageAlgorithm

Inherited Members

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

Examples

When long OneNote pages are saved in pdf format they are split across pages. The sample 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 KeepPartAndCloneSolidObjectToNextPageAlgorithm(100);
   string outputFilePath = dataDir + "PageSplittUsingKeepPartAndCloneSolidObjectToNextPageAlgorithm_out.pdf";
   doc.Save(outputFilePath, pdfSaveOptions);

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();
   float heightLimitOfClonedPart = 500;
   pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(heightLimitOfClonedPart);
   pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(100);
   pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(400);
   dataDir += "UsingKeepSOlidObjectsAlgorithm_out.pdf";
   doc.Save(dataDir);

Constructors

KeepPartAndCloneSolidObjectToNextPageAlgorithm()

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

public KeepPartAndCloneSolidObjectToNextPageAlgorithm()
   {
   }

KeepPartAndCloneSolidObjectToNextPageAlgorithm(float)

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

public KeepPartAndCloneSolidObjectToNextPageAlgorithm(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