From 2009653fb06d53f4b62fb8a78a686a74e898d70c Mon Sep 17 00:00:00 2001 From: jsneedles Date: Sun, 1 Mar 2026 14:02:55 -0500 Subject: [PATCH] Add more image params --- Directory.Build.props | 2 +- src/HtmlCssToImage/Models/MediaType.cs | 16 ++++++++++++++ .../Requests/CreateImageCommonOptions.cs | 19 +++++++++++++++++ .../Models/Requests/CreateTemplateRequest.cs | 19 +++++++++++++++++ src/HtmlCssToImage/Models/Template.cs | 21 +++++++++++++++++++ 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 src/HtmlCssToImage/Models/MediaType.cs diff --git a/Directory.Build.props b/Directory.Build.props index a8c00bb..1586d17 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 0.0.9 + 0.1.0 Code Happy, LLC Code Happy, LLC HTML/CSS To Image API diff --git a/src/HtmlCssToImage/Models/MediaType.cs b/src/HtmlCssToImage/Models/MediaType.cs new file mode 100644 index 0000000..b01148c --- /dev/null +++ b/src/HtmlCssToImage/Models/MediaType.cs @@ -0,0 +1,16 @@ +namespace HtmlCssToImage.Models; + +/// +/// Represents the different types of media for rendering purposes. +/// +public enum MediaType +{ + /// + /// Directs the browser to render the content for printing. + /// + print, + /// + /// Directs the browser to render the content on a screen. + /// + screen +} \ No newline at end of file diff --git a/src/HtmlCssToImage/Models/Requests/CreateImageCommonOptions.cs b/src/HtmlCssToImage/Models/Requests/CreateImageCommonOptions.cs index 7f0a050..df20464 100644 --- a/src/HtmlCssToImage/Models/Requests/CreateImageCommonOptions.cs +++ b/src/HtmlCssToImage/Models/Requests/CreateImageCommonOptions.cs @@ -71,4 +71,23 @@ public abstract class CreateImageCommonOptions /// public string? Timezone { get; set; } + /// + /// Gets or sets a value indicating whether the viewport should be rendered as if it's being viewed from a mobile device. + /// + public bool? ViewportMobile { get; set; } + + /// + /// Gets or sets a value indicating whether the viewport should be in landscape orientation. + /// + public bool? ViewportLandscape { get; set; } + + /// + /// Gets or sets a value indicating whether touch interactions are enabled within the viewport. + /// + public bool? ViewportTouch { get; set; } + /// + /// Gets or sets the media type to use for rendering. + /// + public MediaType? MediaType { get; set; } + } \ No newline at end of file diff --git a/src/HtmlCssToImage/Models/Requests/CreateTemplateRequest.cs b/src/HtmlCssToImage/Models/Requests/CreateTemplateRequest.cs index 3c941a7..7704ad5 100644 --- a/src/HtmlCssToImage/Models/Requests/CreateTemplateRequest.cs +++ b/src/HtmlCssToImage/Models/Requests/CreateTemplateRequest.cs @@ -93,4 +93,23 @@ public class CreateTemplateRequest /// [JsonConverter(typeof(GoogleFontsJsonConverter))] public string[]? GoogleFonts { get; set; } + + /// + /// Gets or sets a value indicating whether the viewport should be rendered as if it's being viewed from a mobile device. + /// + public bool? ViewportMobile { get; set; } + + /// + /// Gets or sets a value indicating whether the viewport should be in landscape orientation. + /// + public bool? ViewportLandscape { get; set; } + + /// + /// Gets or sets a value indicating whether touch interactions are enabled within the viewport. + /// + public bool? ViewportTouch { get; set; } + /// + /// Gets or sets the media type to use for rendering. + /// + public MediaType? MediaType { get; set; } } \ No newline at end of file diff --git a/src/HtmlCssToImage/Models/Template.cs b/src/HtmlCssToImage/Models/Template.cs index 8c99cd1..0bacf2b 100644 --- a/src/HtmlCssToImage/Models/Template.cs +++ b/src/HtmlCssToImage/Models/Template.cs @@ -125,4 +125,25 @@ public class Template /// typically provided in standard IANA timezone format (e.g., "America/New_York"). /// public string? Timezone { get; init; } + + /// + /// Gets or sets a value indicating whether the viewport should be rendered as if it's being viewed from a mobile device. + /// + public bool? ViewportMobile { get; set; } + + /// + /// Gets or sets a value indicating whether the viewport should be in landscape orientation. + /// + public bool? ViewportLandscape { get; set; } + + /// + /// Gets or sets a value indicating whether touch interactions are enabled within the viewport. + /// + public bool? ViewportTouch { get; set; } + /// + /// Gets or sets the media type to use for rendering. + /// + public MediaType? MediaType { get; set; } + + } \ No newline at end of file