Exemplo n.º 1
0
        /// <summary>
        ///  Returns the given command and value as a formatted switch for use with the GhostScript API
        /// </summary>
        /// <param name="command">  The command. </param>
        /// <param name="value">    The value. </param>
        /// <returns>
        ///  The format switch.
        /// </returns>
        public static string GetFormattedArgument(GhostScriptCommand command, object value)
        {
            string commandName;
            string operatorChar;
            string commandValue;

            // reformat some values depending on their type
            if (value != null)
            {
                if (value is Enum)
                {
                    value = (int)value;
                }
                else if (value is bool)
                {
                    value = (bool)value ? "true" : "false";
                }
            }

            // and work out how the names/values will be combined
            commandName  = GhostScriptAPI.GetCommandName(command);
            operatorChar = value == null || string.IsNullOrEmpty(commandName) || command == GhostScriptCommand.Resolution ? string.Empty : "=";
            commandValue = value == null ? string.Empty : value.ToString();

            return(commandName + operatorChar + commandValue);
        }
Exemplo n.º 2
0
        public static string GetFormattedArgument(GhostScriptCommand command, object value)
        {
            string commandName;
            string operatorChar;
            string commandValue;

            if (value != null)
            {
                if (value is Enum)
                {
                    value = (int)value;
                }
                else if (value is bool)
                {
                    value = (bool)value ? "true" : "false";
                }
            }

            commandName  = GhostScriptAPI.GetCommandName(command);
            operatorChar = value == null || string.IsNullOrEmpty(commandName) || command == GhostScriptCommand.Resolution ? string.Empty : "=";
            commandValue = value == null ? string.Empty : value.ToString();

            return(commandName + operatorChar + commandValue);
        }
Exemplo n.º 3
0
        /// <summary>
        ///  Returns the GhostScript command name for the given enumerated command
        /// </summary>
        /// <exception cref="ArgumentException">  Thrown when one or more arguments have unsupported or illegal values. </exception>
        /// <param name="command">  The command. </param>
        /// <returns>
        ///  The name of the specified command required for use with the GhostScript API.
        /// </returns>
        public static string GetCommandName(GhostScriptCommand command)
        {
            string result;

              switch (command)
              {
            case GhostScriptCommand.ColorScreen:
              result = "dCOLORSCREEN";
              break;
            case GhostScriptCommand.DitherPPI:
              result = "dDITHERPPI";
              break;
            case GhostScriptCommand.Interpolate:
              result = "dDOINTERPOLATE";
              break;
            case GhostScriptCommand.NoInterpolate:
              result = "dNOINTERPOLATE";
              break;
            case GhostScriptCommand.TextAlphaBits:
              result = "dTextAlphaBits";
              break;
            case GhostScriptCommand.GraphicsAlphaBits:
              result = "dGraphicsAlphaBits";
              break;
            case GhostScriptCommand.AlignToPixels:
              result = "dAlignToPixels";
              break;
            case GhostScriptCommand.GridToFitTT:
              result = "dGridFitTT";
              break;
            case GhostScriptCommand.UseCIEColor:
              result = "dUseCIEColor";
              break;
            case GhostScriptCommand.NoCIE:
              result = "dNOCIE";
              break;
            case GhostScriptCommand.NoSubstituteDeviceColors:
              result = "dNOSUBSTDEVICECOLORS";
              break;
            case GhostScriptCommand.NoPSICC:
              result = "dNOPSICC";
              break;
            case GhostScriptCommand.NoTransparency:
              result = "dNOTRANSPARENCY";
              break;
            case GhostScriptCommand.NoTN5044:
              result = "dNO_TN5044";
              break;
            case GhostScriptCommand.DoPS:
              result = "dDOPS";
              break;
            case GhostScriptCommand.FixedMedia:
              result = "dFIXEDMEDIA";
              break;
            case GhostScriptCommand.FixedResolution:
              result = "dFIXEDRESOLUTION";
              break;
            case GhostScriptCommand.Orient1:
              result = "dORIENT1";
              break;
            case GhostScriptCommand.DeviceWidthPoints:
              result = "dDEVICEWIDTHPOINTS";
              break;
            case GhostScriptCommand.DeviceHeightPoint:
              result = "dDEVICEHEIGHTPOINTS";
              break;
            case GhostScriptCommand.DefaultPaperSize:
              result = "sDEFAULTPAPERSIZE";
              break;
            case GhostScriptCommand.DiskFonts:
              result = "dDISKFONTS";
              break;
            case GhostScriptCommand.LocalFonts:
              result = "dLOCALFONTS";
              break;
            case GhostScriptCommand.NoCCFonts:
              result = "dNOCCFONTS";
              break;
            case GhostScriptCommand.NoFontMap:
              result = "dNOFONTMAP";
              break;
            case GhostScriptCommand.NoFontPath:
              result = "dNOFONTPATH";
              break;
            case GhostScriptCommand.NoPlatformFonts:
              result = "dNOPLATFONTS";
              break;
            case GhostScriptCommand.NoNativeFontMap:
              result = "dNONATIVEFONTMAP";
              break;
            case GhostScriptCommand.FontMap:
              result = "sFONTMAP";
              break;
            case GhostScriptCommand.FontPath:
              result = "sFONTPATH";
              break;
            case GhostScriptCommand.SubstituteFont:
              result = "sSUBSTFONT";
              break;
            case GhostScriptCommand.OldCFFParser:
              result = "dOLDCFF";
              break;
            case GhostScriptCommand.GenericResourceDirectory:
              result = "sGenericResourceDir";
              break;
            case GhostScriptCommand.FontResourceDirectory:
              result = "sFontResourceDir";
              break;
            case GhostScriptCommand.Batch:
              result = "dBATCH";
              break;
            case GhostScriptCommand.NoPagePrompt:
              result = "dNOPAGEPROMPT";
              break;
            case GhostScriptCommand.NoPause:
              result = "dNOPAUSE";
              break;
            case GhostScriptCommand.NoPrompt:
              result = "dNOPROMPT";
              break;
            case GhostScriptCommand.Silent:
              result = "q";
              break;
            case GhostScriptCommand.Quiet:
              result = "dQUIET";
              break;
            case GhostScriptCommand.ShortErrors:
              result = "dSHORTERRORS";
              break;
            case GhostScriptCommand.StandardOut:
              result = "sstdout";
              break;
            case GhostScriptCommand.TTYPause:
              result = "dTTYPAUSE";
              break;
            case GhostScriptCommand.NoDisplay:
              result = "dNODISPLAY";
              break;
            case GhostScriptCommand.Device:
              result = "sDEVICE";
              break;
            case GhostScriptCommand.OutputFile:
              result = "sOutputFile";
              break;
            case GhostScriptCommand.IgnoreMultipleCopies:
              result = "d.IgnoreNumCopies";
              break;
            case GhostScriptCommand.EPSCrop:
              result = "dEPSCrop";
              break;
            case GhostScriptCommand.EPPSFitPage:
              result = "dEPSFitPage";
              break;
            case GhostScriptCommand.NoEPS:
              result = "dNOEPS";
              break;
            case GhostScriptCommand.DefaultGrayProfile:
              result = "sDefaultGrayProfile";
              break;
            case GhostScriptCommand.DefaultRGBProfile:
              result = "sDefaultRGBProfile";
              break;
            case GhostScriptCommand.DefaultCMYKProfile:
              result = "sDefaultCMYKProfile";
              break;
            case GhostScriptCommand.DeviceNProfile:
              result = "sDeviceNProfile";
              break;
            case GhostScriptCommand.ProofProfile:
              result = "sProofProfile";
              break;
            case GhostScriptCommand.DeviceLinkProfile:
              result = "sDeviceLinkProfile";
              break;
            case GhostScriptCommand.NamedProfile:
              result = "sNamedProfile";
              break;
            case GhostScriptCommand.OutputICCProfile:
              result = "sOutputICCProfile";
              break;
            case GhostScriptCommand.RenderIntent:
              result = "sRenderIntent";
              break;
            case GhostScriptCommand.GraphicICCProfile:
              result = "sGraphicICCProfile";
              break;
            case GhostScriptCommand.GraphicIntent:
              result = "sGraphicIntent";
              break;
            case GhostScriptCommand.ImageICCProfile:
              result = "sImageICCProfile";
              break;
            case GhostScriptCommand.ImageIntent:
              result = "sImageIntent";
              break;
            case GhostScriptCommand.TextICCProfile:
              result = "sTextICCProfile";
              break;
            case GhostScriptCommand.TextIntent:
              result = "sTextIntent";
              break;
            case GhostScriptCommand.OverrideICC:
              result = "dOverrideICC";
              break;
            case GhostScriptCommand.OverrideRI:
              result = "dOverrideRI";
              break;
            case GhostScriptCommand.SourceObjectICC:
              result = "sSourceObjectICC";
              break;
            case GhostScriptCommand.DeviceGrayToK:
              result = "dDeviceGrayToK";
              break;
            case GhostScriptCommand.ICCProfilesDirectory:
              result = "sICCProfilesDir";
              break;
            case GhostScriptCommand.DelayBind:
              result = "dDELAYBIND";
              break;
            case GhostScriptCommand.PdfMarks:
              result = "dDOPDFMARKS";
              break;
            case GhostScriptCommand.JobServer:
              result = "dJOBSERVER";
              break;
            case GhostScriptCommand.NoBind:
              result = "dNOBIND";
              break;
            case GhostScriptCommand.NoCache:
              result = "dNOCACHE";
              break;
            case GhostScriptCommand.NoGC:
              result = "dNOGC";
              break;
            case GhostScriptCommand.NoOuterSave:
              result = "dNOOUTERSAVE";
              break;
            case GhostScriptCommand.NoSafer:
              result = "dNOSAFER";
              break;
            case GhostScriptCommand.Safer:
              result = "dSAFER";
              break;
            case GhostScriptCommand.Strict:
              result = "dSTRICT";
              break;
            case GhostScriptCommand.SystemDictionaryWritable:
              result = "dWRITESYSTEMDICT";
              break;
            case GhostScriptCommand.FirstPage:
              result = "dFirstPage";
              break;
            case GhostScriptCommand.LastPage:
              result = "dLastPage";
              break;
            case GhostScriptCommand.PDFFitPage:
              result = "dPDFFitPage";
              break;
            case GhostScriptCommand.Printed:
              result = "dPrinted";
              break;
            case GhostScriptCommand.UseCropBox:
              result = "dUseCropBox";
              break;
            case GhostScriptCommand.UseTrimBox:
              result = "dUseTrimBox";
              break;
            case GhostScriptCommand.PDFPassword:
              result = "sPDFPassword";
              break;
            case GhostScriptCommand.ShowAnnotations:
              result = "dShowAnnots";
              break;
            case GhostScriptCommand.ShowAcroForm:
              result = "dShowAcroForm";
              break;
            case GhostScriptCommand.NoUserInit:
              result = "dNoUserUnit";
              break;
            case GhostScriptCommand.RenderTTNotDef:
              result = "dRENDERTTNOTDEF";
              break;
            case GhostScriptCommand.Resolution:
              result = "r";
              break;
            case GhostScriptCommand.PaperSize:
              result = "sPAPERSIZE";
              break;
            case GhostScriptCommand.InputFile:
              result = string.Empty;
              break;
            default:
              throw new ArgumentException("Invalid command", "command");
              }

              if (!string.IsNullOrEmpty(result))
            result = "-" + result;

              return result;
        }
Exemplo n.º 4
0
        /// <summary>
        ///  Returns the given command and value as a formatted switch for use with the GhostScript API
        /// </summary>
        /// <param name="command">  The command. </param>
        /// <param name="value">    The value. </param>
        /// <returns>
        ///  The format switch.
        /// </returns>
        public static string GetFormattedArgument(GhostScriptCommand command, object value)
        {
            string commandName;
              string operatorChar;
              string commandValue;

              // reformat some values depending on their type
              if (value != null)
              {
            if (value is Enum)
              value = (int)value;
            else if (value is bool)
              value = (bool)value ? "true" : "false";
              }

              // and work out how the names/values will be combined
              commandName = GhostScriptAPI.GetCommandName(command);
              operatorChar = value == null || string.IsNullOrEmpty(commandName) || command == GhostScriptCommand.Resolution ? string.Empty : "=";
              commandValue = value == null ? string.Empty : value.ToString();

              return commandName + operatorChar + commandValue;
        }
Exemplo n.º 5
0
        /// <summary>
        ///  Returns the GhostScript command name for the given enumerated command
        /// </summary>
        /// <exception cref="ArgumentException">  Thrown when one or more arguments have unsupported or illegal values. </exception>
        /// <param name="command">  The command. </param>
        /// <returns>
        ///  The name of the specified command required for use with the GhostScript API.
        /// </returns>
        public static string GetCommandName(GhostScriptCommand command)
        {
            string result;

            switch (command)
            {
            case GhostScriptCommand.ColorScreen:
                result = "dCOLORSCREEN";
                break;

            case GhostScriptCommand.DitherPPI:
                result = "dDITHERPPI";
                break;

            case GhostScriptCommand.Interpolate:
                result = "dDOINTERPOLATE";
                break;

            case GhostScriptCommand.NoInterpolate:
                result = "dNOINTERPOLATE";
                break;

            case GhostScriptCommand.TextAlphaBits:
                result = "dTextAlphaBits";
                break;

            case GhostScriptCommand.GraphicsAlphaBits:
                result = "dGraphicsAlphaBits";
                break;

            case GhostScriptCommand.AlignToPixels:
                result = "dAlignToPixels";
                break;

            case GhostScriptCommand.GridToFitTT:
                result = "dGridFitTT";
                break;

            case GhostScriptCommand.UseCIEColor:
                result = "dUseCIEColor";
                break;

            case GhostScriptCommand.NoCIE:
                result = "dNOCIE";
                break;

            case GhostScriptCommand.NoSubstituteDeviceColors:
                result = "dNOSUBSTDEVICECOLORS";
                break;

            case GhostScriptCommand.NoPSICC:
                result = "dNOPSICC";
                break;

            case GhostScriptCommand.NoTransparency:
                result = "dNOTRANSPARENCY";
                break;

            case GhostScriptCommand.NoTN5044:
                result = "dNO_TN5044";
                break;

            case GhostScriptCommand.DoPS:
                result = "dDOPS";
                break;

            case GhostScriptCommand.FixedMedia:
                result = "dFIXEDMEDIA";
                break;

            case GhostScriptCommand.FixedResolution:
                result = "dFIXEDRESOLUTION";
                break;

            case GhostScriptCommand.Orient1:
                result = "dORIENT1";
                break;

            case GhostScriptCommand.DeviceWidthPoints:
                result = "dDEVICEWIDTHPOINTS";
                break;

            case GhostScriptCommand.DeviceHeightPoint:
                result = "dDEVICEHEIGHTPOINTS";
                break;

            case GhostScriptCommand.DefaultPaperSize:
                result = "sDEFAULTPAPERSIZE";
                break;

            case GhostScriptCommand.DiskFonts:
                result = "dDISKFONTS";
                break;

            case GhostScriptCommand.LocalFonts:
                result = "dLOCALFONTS";
                break;

            case GhostScriptCommand.NoCCFonts:
                result = "dNOCCFONTS";
                break;

            case GhostScriptCommand.NoFontMap:
                result = "dNOFONTMAP";
                break;

            case GhostScriptCommand.NoFontPath:
                result = "dNOFONTPATH";
                break;

            case GhostScriptCommand.NoPlatformFonts:
                result = "dNOPLATFONTS";
                break;

            case GhostScriptCommand.NoNativeFontMap:
                result = "dNONATIVEFONTMAP";
                break;

            case GhostScriptCommand.FontMap:
                result = "sFONTMAP";
                break;

            case GhostScriptCommand.FontPath:
                result = "sFONTPATH";
                break;

            case GhostScriptCommand.SubstituteFont:
                result = "sSUBSTFONT";
                break;

            case GhostScriptCommand.OldCFFParser:
                result = "dOLDCFF";
                break;

            case GhostScriptCommand.GenericResourceDirectory:
                result = "sGenericResourceDir";
                break;

            case GhostScriptCommand.FontResourceDirectory:
                result = "sFontResourceDir";
                break;

            case GhostScriptCommand.Batch:
                result = "dBATCH";
                break;

            case GhostScriptCommand.NoPagePrompt:
                result = "dNOPAGEPROMPT";
                break;

            case GhostScriptCommand.NoPause:
                result = "dNOPAUSE";
                break;

            case GhostScriptCommand.NoPrompt:
                result = "dNOPROMPT";
                break;

            case GhostScriptCommand.Silent:
                result = "q";
                break;

            case GhostScriptCommand.Quiet:
                result = "dQUIET";
                break;

            case GhostScriptCommand.ShortErrors:
                result = "dSHORTERRORS";
                break;

            case GhostScriptCommand.StandardOut:
                result = "sstdout";
                break;

            case GhostScriptCommand.TTYPause:
                result = "dTTYPAUSE";
                break;

            case GhostScriptCommand.NoDisplay:
                result = "dNODISPLAY";
                break;

            case GhostScriptCommand.Device:
                result = "sDEVICE";
                break;

            case GhostScriptCommand.OutputFile:
                result = "sOutputFile";
                break;

            case GhostScriptCommand.IgnoreMultipleCopies:
                result = "d.IgnoreNumCopies";
                break;

            case GhostScriptCommand.EPSCrop:
                result = "dEPSCrop";
                break;

            case GhostScriptCommand.EPPSFitPage:
                result = "dEPSFitPage";
                break;

            case GhostScriptCommand.NoEPS:
                result = "dNOEPS";
                break;

            case GhostScriptCommand.DefaultGrayProfile:
                result = "sDefaultGrayProfile";
                break;

            case GhostScriptCommand.DefaultRGBProfile:
                result = "sDefaultRGBProfile";
                break;

            case GhostScriptCommand.DefaultCMYKProfile:
                result = "sDefaultCMYKProfile";
                break;

            case GhostScriptCommand.DeviceNProfile:
                result = "sDeviceNProfile";
                break;

            case GhostScriptCommand.ProofProfile:
                result = "sProofProfile";
                break;

            case GhostScriptCommand.DeviceLinkProfile:
                result = "sDeviceLinkProfile";
                break;

            case GhostScriptCommand.NamedProfile:
                result = "sNamedProfile";
                break;

            case GhostScriptCommand.OutputICCProfile:
                result = "sOutputICCProfile";
                break;

            case GhostScriptCommand.RenderIntent:
                result = "sRenderIntent";
                break;

            case GhostScriptCommand.GraphicICCProfile:
                result = "sGraphicICCProfile";
                break;

            case GhostScriptCommand.GraphicIntent:
                result = "sGraphicIntent";
                break;

            case GhostScriptCommand.ImageICCProfile:
                result = "sImageICCProfile";
                break;

            case GhostScriptCommand.ImageIntent:
                result = "sImageIntent";
                break;

            case GhostScriptCommand.TextICCProfile:
                result = "sTextICCProfile";
                break;

            case GhostScriptCommand.TextIntent:
                result = "sTextIntent";
                break;

            case GhostScriptCommand.OverrideICC:
                result = "dOverrideICC";
                break;

            case GhostScriptCommand.OverrideRI:
                result = "dOverrideRI";
                break;

            case GhostScriptCommand.SourceObjectICC:
                result = "sSourceObjectICC";
                break;

            case GhostScriptCommand.DeviceGrayToK:
                result = "dDeviceGrayToK";
                break;

            case GhostScriptCommand.ICCProfilesDirectory:
                result = "sICCProfilesDir";
                break;

            case GhostScriptCommand.DelayBind:
                result = "dDELAYBIND";
                break;

            case GhostScriptCommand.PdfMarks:
                result = "dDOPDFMARKS";
                break;

            case GhostScriptCommand.JobServer:
                result = "dJOBSERVER";
                break;

            case GhostScriptCommand.NoBind:
                result = "dNOBIND";
                break;

            case GhostScriptCommand.NoCache:
                result = "dNOCACHE";
                break;

            case GhostScriptCommand.NoGC:
                result = "dNOGC";
                break;

            case GhostScriptCommand.NoOuterSave:
                result = "dNOOUTERSAVE";
                break;

            case GhostScriptCommand.NoSafer:
                result = "dNOSAFER";
                break;

            case GhostScriptCommand.Safer:
                result = "dSAFER";
                break;

            case GhostScriptCommand.Strict:
                result = "dSTRICT";
                break;

            case GhostScriptCommand.SystemDictionaryWritable:
                result = "dWRITESYSTEMDICT";
                break;

            case GhostScriptCommand.FirstPage:
                result = "dFirstPage";
                break;

            case GhostScriptCommand.LastPage:
                result = "dLastPage";
                break;

            case GhostScriptCommand.PDFFitPage:
                result = "dPDFFitPage";
                break;

            case GhostScriptCommand.Printed:
                result = "dPrinted";
                break;

            case GhostScriptCommand.UseCropBox:
                result = "dUseCropBox";
                break;

            case GhostScriptCommand.UseTrimBox:
                result = "dUseTrimBox";
                break;

            case GhostScriptCommand.PDFPassword:
                result = "sPDFPassword";
                break;

            case GhostScriptCommand.ShowAnnotations:
                result = "dShowAnnots";
                break;

            case GhostScriptCommand.ShowAcroForm:
                result = "dShowAcroForm";
                break;

            case GhostScriptCommand.NoUserInit:
                result = "dNoUserUnit";
                break;

            case GhostScriptCommand.RenderTTNotDef:
                result = "dRENDERTTNOTDEF";
                break;

            case GhostScriptCommand.Resolution:
                result = "r";
                break;

            case GhostScriptCommand.PaperSize:
                result = "sPAPERSIZE";
                break;

            case GhostScriptCommand.InputFile:
                result = string.Empty;
                break;

            default:
                throw new ArgumentException("Invalid command", "command");
            }

            if (!string.IsNullOrEmpty(result))
            {
                result = "-" + result;
            }

            return(result);
        }