// Copyright (c) 2025 Vuplex Inc. All rights reserved.
//
// Licensed under the Vuplex Commercial Software Library License, you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// https://vuplex.com/commercial-library-license
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using UnityEngine;
namespace Vuplex.WebView {
///
/// Margin type enum for StandalonePdfOptions.MarginType.
///
public enum StandalonePdfMarginType {
///
/// Default margins of 1cm (~0.4 inches).
///
Default,
///
/// No margins.
///
None,
///
/// Custom margins specified with StandalonePdfOptions.MarginTop, MarginRight, MarginBottom, and MarginLeft.
///
Custom
}
///
/// Optional PDF formatting settings that can be passed to StandaloneWebView.CreatePdf().
///
[Serializable]
public class StandalonePdfOptions {
///
/// Set to true for landscape mode or false for portrait mode. The default is false.
///
public bool Landscape;
///
/// The bottom margin in inches. Only used if MarginType is set to StandalonePdfMarginType.Custom.
///
public float MarginBottom;
///
/// The left margin in inches. Only used if MarginType is set to StandalonePdfMarginType.Custom.
///
public float MarginLeft;
///
/// The right margin in inches. Only used if MarginType is set to StandalonePdfMarginType.Custom.
///
public float MarginRight;
///
/// The top margin in inches. Only used if MarginType is set to StandalonePdfMarginType.Custom.
///
public float MarginTop;
///
/// The margin type. The default is StandalonePdfMarginType.Default.
///
public StandalonePdfMarginType MarginType = StandalonePdfMarginType.Default;
///
/// Paper ranges to print, one based, e.g., "1-5, 8, 11-13". Pages are printed
/// in the document order, not in the order specified, and no more than once.
/// Defaults to empty string, which implies the entire document is printed.
/// The page numbers are quietly capped to actual page count of the document,
/// and ranges beyond the end of the document are ignored. If this results in
/// no pages to print, an error is reported. It is an error to specify a range
/// with start greater than end.
///
public string PageRanges = "";
///
/// Output paper height in inches. If either PaperWidth or PaperHeight is less than or
/// equal to zero, then the default paper size (letter, 8.5 x 11 inches) will
/// be used.
///
public float PaperHeight;
///
/// Output paper width in inches. If either PaperWidth or PaperHeight is less than or
/// equal to zero, then the default paper size (letter, 8.5 x 11 inches) will
/// be used.
///
public float PaperWidth;
///
/// Set to true to prefer page size as defined by CSS. Defaults to false,
/// in which case the content will be scaled to fit the paper size.
///
public bool PreferCssPageSize;
///
/// Set to true to print background graphics. The default is false.
///
public bool PrintBackground;
///
/// The percentage to scale the PDF by before printing (e.g. .5 is 50%).
/// If this value is less than or equal to zero the default value of 1.0
/// will be used.
///
public float Scale;
public string ToJson() => JsonUtility.ToJson(this);
public override string ToString() => ToJson();
}
}