public static ToValue ( PdfVersions id ) : double | ||
id | PdfVersions | |
return | double |
/* ----------------------------------------------------------------- */ /// /// ConfigureCommonImage /// /// <summary> /// 画像に関わるオプションを設定します。 /// </summary> /// /// <remarks> /// 全てのファイルタイプ共通の設定です。 /// </remarks> /// /* ----------------------------------------------------------------- */ private void ConfigureCommonImage(UserSetting setting, Ghostscript.Converter gs) { gs.AddOption("ColorConversionStrategy", setting.Grayscale ? "/Gray" : "/RGB"); gs.AddOption("DownsampleColorImages", true); gs.AddOption("DownsampleGrayImages", true); gs.AddOption("DownsampleMonoImages", true); // 解像度 var resolution = Parameter.ToValue(setting.Resolution); var mono = resolution < 300 ? 300 : 1200; gs.AddOption("ColorImageResolution", resolution); gs.AddOption("GrayImageResolution", resolution); gs.AddOption("MonoImageResolution", mono); // 画像圧縮 gs.AddOption("AutoFilterColorImages", false); gs.AddOption("AutoFilterGrayImages", false); gs.AddOption("AutoFilterMonoImages", false); gs.AddOption("ColorImageFilter", "/" + setting.ImageFilter.ToString()); gs.AddOption("GrayImageFilter", "/" + setting.ImageFilter.ToString()); gs.AddOption("MonoImageFilter", "/" + setting.ImageFilter.ToString()); // ダウンサンプリング if (setting.DownSampling != Parameter.DownSamplings.None) { gs.AddOption("ColorImageDownsampleType", "/" + setting.DownSampling.ToString()); gs.AddOption("GrayImageDownsampleType", "/" + setting.DownSampling.ToString()); gs.AddOption("MonoImageDownsampleType", "/" + setting.DownSampling.ToString()); } }
/* ----------------------------------------------------------------- */ /// /// Configure /// /// <summary> /// Ghostscript オブジェクトを生成し、必要な設定を行います。 /// </summary> /// /* ----------------------------------------------------------------- */ private Ghostscript.Converter Configure(UserSetting setting, string src, string dest) { var gs = new Ghostscript.Converter(_messages); if (!string.IsNullOrEmpty(setting.LibPath)) { gs.AddInclude(IoEx.Path.Combine(setting.LibPath, "lib")); } gs.Device = Parameter.GetDevice(setting.FileType, setting.Grayscale); gs.Resolution = Parameter.ToValue(setting.Resolution); if (setting.Orientation == Parameter.Orientations.Auto) { gs.AutoRotatePages = true; } else { gs.Orientation = (int)setting.Orientation; } ConfigureCommonImage(setting, gs); if (Parameter.IsImageType(setting.FileType)) { ConfigureBitmap(setting, gs); } else { ConfigureDocument(setting, gs); } gs.AddSource(src); gs.Destination = dest; return(gs); }
/* ----------------------------------------------------------------- */ /// /// GetString /// /// <summary> /// PDFVersions の各値に対応する文字列を取得します。 /// </summary> /// /* ----------------------------------------------------------------- */ public static string GetString(Parameter.PdfVersions id) { if (id == Parameter.PdfVersions.VerPDFA) { return(""); //"PDF/A"; } else if (id == Parameter.PdfVersions.VerPDFX) { return(""); //"PDF/X"; } return(Parameter.ToValue(id).ToString()); }
/* ----------------------------------------------------------------- */ /// /// ConfigurePdf /// /// <summary> /// PDF ファイルに変換するために必要なオプションを設定します。 /// </summary> /// /* ----------------------------------------------------------------- */ private void ConfigurePdf(UserSetting setting, Ghostscript.Converter gs) { gs.AddOption("CompatibilityLevel", Parameter.ToValue(setting.PDFVersion)); gs.AddOption("UseFlateCompression", true); if (setting.PDFVersion == Parameter.PdfVersions.VerPDFA) { ConfigurePdfA(setting, gs); } if (setting.PDFVersion == Parameter.PdfVersions.VerPDFX) { ConfigurePdfX(setting, gs); } }
/* ----------------------------------------------------------------- */ /// /// GetString /// /// <summary> /// FileTypes の各値に対応する文字列を取得します。 /// </summary> /// /* ----------------------------------------------------------------- */ public static string GetString(Parameter.FileTypes id) { return(Parameter.ToValue(id)); }
/* ----------------------------------------------------------------- */ /// /// GetString /// /// <summary> /// Resolutions の各値に対応する文字列を取得します。 /// </summary> /// /* ----------------------------------------------------------------- */ public static string GetString(Parameter.Resolutions id) { return(Parameter.ToValue(id).ToString()); }