From 93a7c54b90add42d2cc5b11bd5c2473d84d7ea74 Mon Sep 17 00:00:00 2001 From: Sangeetha Divya Date: Wed, 30 Apr 2025 11:34:47 +0530 Subject: [PATCH] removed duplicate constants --- itext/itext.io/itext/io/util/ImageHandlerUtil.cs | 8 ++------ itext/itext.kernel/itext/kernel/pdf/PdfReader.cs | 2 +- .../exceptions/StyledXMLParserException.cs | 3 --- .../styledxmlparser/resolver/resource/UriEncodeUtil.cs | 2 +- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/itext/itext.io/itext/io/util/ImageHandlerUtil.cs b/itext/itext.io/itext/io/util/ImageHandlerUtil.cs index 807d7f462..cac5fcfae 100644 --- a/itext/itext.io/itext/io/util/ImageHandlerUtil.cs +++ b/itext/itext.io/itext/io/util/ImageHandlerUtil.cs @@ -48,10 +48,6 @@ public sealed class ImageHandlerUtil { public const String GS_ENVIRONMENT_VARIABLE_IS_NOT_SPECIFIED = "Ghostscript command is not specified. Set the " + GHOSTSCRIPT_ENVIRONMENT_VARIABLE + " environment variable to a CLI command that can run the Ghostscript application. See BUILDING.MD in the root of the repository for more details."; - private const String GHOSTSCRIPT_FAILED = "GhostScript failed for ."; - - private const String CANNOT_OPEN_OUTPUT_DIRECTORY = "Cannot open output directory for ."; - private const String GHOSTSCRIPT_PARAMS = " -dSAFER -dNOPAUSE -dBATCH -sDEVICE=png16m -r150 -sOutputFile='' ''"; private const String COMPARE_PARAMS = " '' '' ''"; @@ -108,14 +104,14 @@ public void RunGhostScriptImageGeneration(String pdf, String outDir, String imag throw new ImageHandlerUtil.ImageHandlerExecutionException(this, GS_ENVIRONMENT_VARIABLE_IS_NOT_SPECIFIED); } if (!FileUtil.DirectoryExists(outDir)) { - throw new ImageHandlerUtil.ImageHandlerExecutionException(this, CANNOT_OPEN_OUTPUT_DIRECTORY.Replace("" + throw new ImageHandlerUtil.ImageHandlerExecutionException(this, iText.IO.Exceptions.IoExceptionMessageConstant.CANNOT_OPEN_OUTPUT_DIRECTORY.Replace("" , pdf)); } pageNumber = (pageNumber == null) ? "" : "-sPageList=".Replace("", pageNumber); String currGsParams = GHOSTSCRIPT_PARAMS.Replace("", pageNumber).Replace("", outDir + image).Replace("", pdf); if (!SystemUtil.RunProcessAndWait(gsExec, currGsParams)) { - throw new ImageHandlerUtil.ImageHandlerExecutionException(this, GHOSTSCRIPT_FAILED.Replace("", pdf + throw new ImageHandlerUtil.ImageHandlerExecutionException(this, iText.IO.Exceptions.IoExceptionMessageConstant.GHOSTSCRIPT_FAILED.Replace("", pdf )); } } diff --git a/itext/itext.kernel/itext/kernel/pdf/PdfReader.cs b/itext/itext.kernel/itext/kernel/pdf/PdfReader.cs index 2f17fe177..3805a5da4 100644 --- a/itext/itext.kernel/itext/kernel/pdf/PdfReader.cs +++ b/itext/itext.kernel/itext/kernel/pdf/PdfReader.cs @@ -1781,7 +1781,7 @@ public virtual int Get(long offset) { public virtual int Get(long offset, byte[] bytes, int off, int len) { if (buffer == null) { - throw new InvalidOperationException("Already closed"); + throw new InvalidOperationException(iText.IO.Exceptions.IoExceptionMessageConstant.ALREADY_CLOSED); } if (offset >= buffer.Size()) { return -1; diff --git a/itext/itext.styledxmlparser/itext/styledxmlparser/exceptions/StyledXMLParserException.cs b/itext/itext.styledxmlparser/itext/styledxmlparser/exceptions/StyledXMLParserException.cs index 0ac6db911..a05fb5343 100644 --- a/itext/itext.styledxmlparser/itext/styledxmlparser/exceptions/StyledXMLParserException.cs +++ b/itext/itext.styledxmlparser/itext/styledxmlparser/exceptions/StyledXMLParserException.cs @@ -41,9 +41,6 @@ public class StyledXMLParserException : ITextException { /// Message in case the font provider doesn't know about any fonts. public const String FontProviderContainsZeroFonts = "Font Provider contains zero fonts. At least one font shall be present"; - /// The Constant UnsupportedEncodingException. - public const String UnsupportedEncodingException = "Unsupported encoding exception."; - /// /// Creates a new /// diff --git a/itext/itext.styledxmlparser/itext/styledxmlparser/resolver/resource/UriEncodeUtil.cs b/itext/itext.styledxmlparser/itext/styledxmlparser/resolver/resource/UriEncodeUtil.cs index 5659b4d05..cf1d359eb 100644 --- a/itext/itext.styledxmlparser/itext/styledxmlparser/resolver/resource/UriEncodeUtil.cs +++ b/itext/itext.styledxmlparser/itext/styledxmlparser/resolver/resource/UriEncodeUtil.cs @@ -116,7 +116,7 @@ public static String Encode(String s, String enc) BinaryWriter charArrayWriter = new BinaryWriter(new MemoryStream()); if (enc == null) { - throw new StyledXMLParserException(StyledXMLParserException.UnsupportedEncodingException); + throw new StyledXMLParserException(IO.Exceptions.IoExceptionMessageConstant.UNSUPPORTED_ENCODING_EXCEPTION); } charset = EncodingUtil.GetEncoding(enc); int i = 0;