using QuestPDF.Elements;
using QuestPDF.Infrastructure;
namespace QuestPDF.Fluent
{
public static class DynamicComponentExtensions
{
///
/// Represents a dynamically generated section of the document.
/// Components are page-aware, understand their positioning, can dynamically construct other content elements, and assess their dimensions, enabling complex layout creations.
/// Learn more
///
///
///
/// Consider an invoice that presents all purchased items in a table format.
/// Instead of just showing the final total price under the table, the requirement is to display the cumulative prices on each separate page.
///
/// Using the dynamic component, you can manually assemble the table, count how many items are visible on each page, calculate the price sum for items visible on each page, and then render the result under each sub-table.
///
public static void Dynamic(this IContainer element, IDynamicComponent dynamicElement)
{
var componentProxy = DynamicComponentProxy.CreateFrom(dynamicElement);
element.Element(new DynamicHost(componentProxy));
}
///
/// Represents a section of the document dynamically created based on its inner state.
/// Components are page-aware, understand their positioning, can dynamically construct other content elements, and assess their dimensions, enabling complex layout creations.
/// Learn more
///
///
///
/// Consider an invoice that presents all purchased items in a table format.
/// Instead of just showing the final total price under the table, the requirement is to display the cumulative prices on each separate page.
///
/// Using the dynamic component, you can manually assemble the table, count how many items are visible on each page, calculate the price sum for items visible on each page, and then render the result under each sub-table.
///
public static void Dynamic(this IContainer element, IDynamicComponent dynamicElement) where TState : struct
{
var componentProxy = DynamicComponentProxy.CreateFrom(dynamicElement);
element.DebugPointer(DebugPointerType.Dynamic, dynamicElement.GetType().Name).Element(new DynamicHost(componentProxy));
}
///
/// Allows to inject the unattached content created by the method within the Dynamic component.
///
public static void Element(this IContainer element, IDynamicElement child)
{
ElementExtensions.Element(element, child);
}
}
}