<commit_before>﻿namespace Shark.PdfConvert
{
    using System;
    using System.Text;
    using System.IO;
    using System.Diagnostics;
    using System.Linq;

    /// <summary>
    /// Pdf Conversion wrapping the WkHtmlToPdf tool
    /// </summary>
    public class PdfConvert
    {
        private static string BuildOptions(PdfConversionSettings config,
            string temporaryContentFilePath,
            string temporaryPdfFilePath,
            string temporaryCoverFilePath,
            string temporaryHeaderFilePath,
            string temporaryFooterFilePath)
        {
            StringBuilder options = new StringBuilder();

            // GLOBAL OPTIONS
            if (string.IsNullOrWhiteSpace(config.CustomWkHtmlArgs))
            {
                if (config.Grayscale) options.Append("--grayscale ");
                if (config.LowQuality) options.Append("--lowquality ");
                if (config.Margins.Bottom != null) options.AppendFormat("--margin-bottom {0} ", config.Margins.Bottom);
                if (config.Margins.Top != null) options.AppendFormat("--margin-top {0} ", config.Margins.Top);
                if (config.Margins.Left != null) options.AppendFormat("--margin-left {0} ", config.Margins.Left);
                if (config.Margins.Right != null) options.AppendFormat("--margin-right {0} ", config.Margins.Right);

                if (config.Size != PdfPageSize.Default) options.AppendFormat("--page-size {0} ", config.Size.ToString());
                if (config.PageWidth != null) options.AppendFormat("--page-width {0}", config.PageWidth.ToString());
                if (config.PageHeight != null) options.AppendFormat("--page-height {0}", config.PageHeight.ToString());

                if (config.Orientation != PdfPageOrientation.Default) options.AppendFormat("--orientation {0} ", config.Orientation.ToString());
                if (string.IsNullOrWhiteSpace(config.Title) == false) options.AppendFormat("--title \"{0}\" ", config.Title.Replace("\"", ""));
            }
            else
            {
                options.Append(config.CustomWkHtmlArgs);
                options.Append(" ");
            }

            // COVER<commit_msg>- Fixed PageWidth and PageSize options<commit_after>﻿namespace Shark.PdfConvert
{
    using System;
    using System.Text;
    using System.IO;
    using System.Diagnostics;
    using System.Linq;

    /// <summary>
    /// Pdf Conversion wrapping the WkHtmlToPdf tool
    /// </summary>
    public class PdfConvert
    {
        private static string BuildOptions(PdfConversionSettings config,
            string temporaryContentFilePath,
            string temporaryPdfFilePath,
            string temporaryCoverFilePath,
            string temporaryHeaderFilePath,
            string temporaryFooterFilePath)
        {
            StringBuilder options = new StringBuilder();

            // GLOBAL OPTIONS
            if (string.IsNullOrWhiteSpace(config.CustomWkHtmlArgs))
            {
                if (config.Grayscale) options.Append("--grayscale ");
                if (config.LowQuality) options.Append("--lowquality ");
                if (config.Margins.Bottom != null) options.AppendFormat("--margin-bottom {0} ", config.Margins.Bottom);
                if (config.Margins.Top != null) options.AppendFormat("--margin-top {0} ", config.Margins.Top);
                if (config.Margins.Left != null) options.AppendFormat("--margin-left {0} ", config.Margins.Left);
                if (config.Margins.Right != null) options.AppendFormat("--margin-right {0} ", config.Margins.Right);

                if (config.Size != PdfPageSize.Default) options.AppendFormat("--page-size {0} ", config.Size.ToString());
                if (config.PageWidth != null) options.AppendFormat("--page-width {0} ", config.PageWidth.ToString());
                if (config.PageHeight != null) options.AppendFormat("--page-height {0} ", config.PageHeight.ToString());

                if (config.Orientation != PdfPageOrientation.Default) options.AppendFormat("--orientation {0} ", config.Orientation.ToString());
                if (string.IsNullOrWhiteSpace(config.Title) == false) options.AppendFormat("--title \"{0}\" ", config.Title.Replace("\"", ""));
            }
            else
            {
                options.Append(config.CustomWkHtmlArgs);
                options.Append(" ");
            }

            // COVER
{'fraction_non_alphanumeric': 0.13063165044147612, 'fraction_numerical': 0.004075164138555581, 'mean_word_length': 2.217771303714494, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6520921', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1128, 'n_words': 224}