using System.ComponentModel.DataAnnotations;
namespace HtmlToPdfService.Api.Models;
///
/// HTML 转图片请求
///
public class ConvertHtmlToImageRequest
{
///
/// HTML 内容
///
[Required(ErrorMessage = "HTML 内容不能为空")]
public string Html { get; set; } = string.Empty;
///
/// 页面加载后额外等待时间(毫秒),用于等待动画或延迟渲染
///
public int? DelayAfterLoad { get; set; }
///
/// 图片选项
///
public ImageOptionsDto? Options { get; set; }
///
/// 回调配置
///
public CallbackOptionsDto? Callback { get; set; }
///
/// 是否保存本地副本
///
public bool? SaveLocal { get; set; }
}
///
/// URL 转图片请求
///
public class ConvertUrlToImageRequest
{
///
/// URL 地址
///
[Required(ErrorMessage = "URL 不能为空")]
[Url(ErrorMessage = "URL 格式不正确")]
public string Url { get; set; } = string.Empty;
///
/// 等待条件:load, domcontentloaded, networkidle0, networkidle2
///
public string? WaitUntil { get; set; }
///
/// 页面加载超时(毫秒)
///
public int? Timeout { get; set; }
///
/// 页面加载后额外等待时间(毫秒),用于等待动画或延迟渲染
///
public int? DelayAfterLoad { get; set; }
///
/// 图片选项
///
public ImageOptionsDto? Options { get; set; }
///
/// 回调配置
///
public CallbackOptionsDto? Callback { get; set; }
///
/// 是否保存本地副本
///
public bool? SaveLocal { get; set; }
}
///
/// 图片选项 DTO
///
public class ImageOptionsDto
{
///
/// 图片格式:png, jpeg, webp
///
public string Format { get; set; } = "png";
///
/// 图片质量 (0-100),仅对 jpeg 和 webp 有效
///
public int? Quality { get; set; }
///
/// 是否全页截图(默认 true)
///
public bool FullPage { get; set; } = true;
///
/// 视口宽度(像素)
///
public int? Width { get; set; }
///
/// 视口高度(像素)
///
public int? Height { get; set; }
///
/// 截图区域(可选)
///
public ClipAreaDto? Clip { get; set; }
///
/// 是否省略背景(生成透明背景,仅 png 支持)
///
public bool? OmitBackground { get; set; }
}
///
/// 截图区域
///
public class ClipAreaDto
{
///
/// X 坐标
///
public decimal X { get; set; }
///
/// Y 坐标
///
public decimal Y { get; set; }
///
/// 宽度
///
public decimal Width { get; set; }
///
/// 高度
///
public decimal Height { get; set; }
}