Fixed Image API for Dynamic components
This commit is contained in:
@@ -101,7 +101,7 @@ namespace QuestPDF.Drawing
|
|||||||
|
|
||||||
ApplyInheritedAndGlobalTexStyle(content, TextStyle.Default);
|
ApplyInheritedAndGlobalTexStyle(content, TextStyle.Default);
|
||||||
ApplyContentDirection(content, settings.ContentDirection);
|
ApplyContentDirection(content, settings.ContentDirection);
|
||||||
ApplyDefaultImageConfiguration(content, settings);
|
ApplyDefaultImageConfiguration(content, settings.ImageRasterDpi, settings.ImageCompressionQuality);
|
||||||
|
|
||||||
var debuggingState = Settings.EnableDebugging ? ApplyDebugging(content) : null;
|
var debuggingState = Settings.EnableDebugging ? ApplyDebugging(content) : null;
|
||||||
|
|
||||||
@@ -228,20 +228,26 @@ namespace QuestPDF.Drawing
|
|||||||
ApplyContentDirection(child, direction);
|
ApplyContentDirection(child, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void ApplyDefaultImageConfiguration(this Element? content, DocumentSettings settings)
|
internal static void ApplyDefaultImageConfiguration(this Element? content, int imageRasterDpi, ImageCompressionQuality imageCompressionQuality)
|
||||||
{
|
{
|
||||||
content.VisitChildren(x =>
|
content.VisitChildren(x =>
|
||||||
{
|
{
|
||||||
if (x is QuestPDF.Elements.Image image)
|
if (x is QuestPDF.Elements.Image image)
|
||||||
{
|
{
|
||||||
image.TargetDpi ??= settings.ImageRasterDpi;
|
image.TargetDpi ??= imageRasterDpi;
|
||||||
image.CompressionQuality ??= settings.ImageCompressionQuality;
|
image.CompressionQuality ??= imageCompressionQuality;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x is QuestPDF.Elements.DynamicImage dynamicImage)
|
if (x is QuestPDF.Elements.DynamicImage dynamicImage)
|
||||||
{
|
{
|
||||||
dynamicImage.TargetDpi ??= settings.ImageRasterDpi;
|
dynamicImage.TargetDpi ??= imageRasterDpi;
|
||||||
dynamicImage.CompressionQuality ??= settings.ImageCompressionQuality;
|
dynamicImage.CompressionQuality ??= imageCompressionQuality;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x is DynamicHost dynamicHost)
|
||||||
|
{
|
||||||
|
dynamicHost.ImageTargetDpi ??= imageRasterDpi;
|
||||||
|
dynamicHost.ImageCompressionQuality ??= imageCompressionQuality;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ namespace QuestPDF.Elements
|
|||||||
internal TextStyle TextStyle { get; set; } = TextStyle.Default;
|
internal TextStyle TextStyle { get; set; } = TextStyle.Default;
|
||||||
public ContentDirection ContentDirection { get; set; }
|
public ContentDirection ContentDirection { get; set; }
|
||||||
|
|
||||||
|
internal int? ImageTargetDpi { get; set; }
|
||||||
|
internal ImageCompressionQuality? ImageCompressionQuality { get; set; }
|
||||||
|
|
||||||
public DynamicHost(DynamicComponentProxy child)
|
public DynamicHost(DynamicComponentProxy child)
|
||||||
{
|
{
|
||||||
Child = child;
|
Child = child;
|
||||||
@@ -58,6 +61,9 @@ namespace QuestPDF.Elements
|
|||||||
TextStyle = TextStyle,
|
TextStyle = TextStyle,
|
||||||
ContentDirection = ContentDirection,
|
ContentDirection = ContentDirection,
|
||||||
|
|
||||||
|
ImageTargetDpi = ImageTargetDpi.Value,
|
||||||
|
ImageCompressionQuality = ImageCompressionQuality.Value,
|
||||||
|
|
||||||
PageNumber = PageContext.CurrentPage,
|
PageNumber = PageContext.CurrentPage,
|
||||||
TotalPages = PageContext.GetLocation(Infrastructure.PageContext.DocumentLocation).PageEnd,
|
TotalPages = PageContext.GetLocation(Infrastructure.PageContext.DocumentLocation).PageEnd,
|
||||||
AvailableSize = availableSize
|
AvailableSize = availableSize
|
||||||
@@ -79,7 +85,10 @@ namespace QuestPDF.Elements
|
|||||||
|
|
||||||
internal TextStyle TextStyle { get; set; }
|
internal TextStyle TextStyle { get; set; }
|
||||||
internal ContentDirection ContentDirection { get; set; }
|
internal ContentDirection ContentDirection { get; set; }
|
||||||
|
|
||||||
|
internal int ImageTargetDpi { get; set; }
|
||||||
|
internal ImageCompressionQuality ImageCompressionQuality { get; set; }
|
||||||
|
|
||||||
public int PageNumber { get; internal set; }
|
public int PageNumber { get; internal set; }
|
||||||
public int TotalPages { get; internal set; }
|
public int TotalPages { get; internal set; }
|
||||||
public Size AvailableSize { get; internal set; }
|
public Size AvailableSize { get; internal set; }
|
||||||
@@ -91,6 +100,7 @@ namespace QuestPDF.Elements
|
|||||||
|
|
||||||
container.ApplyInheritedAndGlobalTexStyle(TextStyle);
|
container.ApplyInheritedAndGlobalTexStyle(TextStyle);
|
||||||
container.ApplyContentDirection(ContentDirection);
|
container.ApplyContentDirection(ContentDirection);
|
||||||
|
container.ApplyDefaultImageConfiguration(ImageTargetDpi, ImageCompressionQuality);
|
||||||
|
|
||||||
container.InjectDependencies(PageContext, Canvas);
|
container.InjectDependencies(PageContext, Canvas);
|
||||||
container.VisitChildren(x => (x as IStateResettable)?.ResetState());
|
container.VisitChildren(x => (x as IStateResettable)?.ResetState());
|
||||||
|
|||||||
Reference in New Issue
Block a user