Skip to content

Use object for Top / Left / Bottom / Right in MarginOptions #2788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 18, 2024

Conversation

campersau
Copy link
Contributor

Because:

  1. Upstream PDFMargin uses string | number
  2. PDFOptions.Width / PDFOptions.Height also use string | number upstream
  3. PdfOptions.Width / PdfOptions.Height using object
    /// <summary>
    /// Paper width, accepts values labeled with units.
    /// </summary>
    public object Width { get; set; }
    /// <summary>
    /// Paper height, accepts values labeled with units.
    /// </summary>
    public object Height { get; set; }
  4. All of these properties were already going to ConvertPrintParameterToInches
    else
    {
    if (options.Width != null)
    {
    paperWidth = ConvertPrintParameterToInches(options.Width);
    }
    if (options.Height != null)
    {
    paperHeight = ConvertPrintParameterToInches(options.Height);
    }
    }
    var marginTop = ConvertPrintParameterToInches(options.MarginOptions.Top);
    var marginLeft = ConvertPrintParameterToInches(options.MarginOptions.Left);
    var marginBottom = ConvertPrintParameterToInches(options.MarginOptions.Bottom);
    var marginRight = ConvertPrintParameterToInches(options.MarginOptions.Right);

PdfOptionsShouldBeSerializable didn't actually test Width / Height which meant that serialisation was broken by the migration to System.Text.Json.
I added a simple PrimitiveTypeConverter to support #1001


PdfOptionsShouldWorkWithMarginWithNoUnits didn't actually test the ConvertPrintParameterToInches logic so I have removed it. It was just testing what PdfOptionsShouldBeSerializable already did.


Also made MarginOptions / PaperFormat records.

This is similar to the object Width / Height in PdfOptions and all of them already got converted by ConvertPrintParameterToInches
@kblok kblok merged commit 71ff822 into hardkoded:master Oct 18, 2024
11 of 12 checks passed
@campersau campersau deleted the objectmarginoptions branch October 18, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy