Skip to content
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

Added support for .Net 4.5 #27

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Vixed build
  • Loading branch information
pieroviano committed Dec 3, 2022
commit 93d35467977feb69b0b6f4240b05d593eb656224
8 changes: 8 additions & 0 deletions itext/itext.io/itext/io/source/GroupedRandomAccessSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,20 @@ public virtual void Close() {
}
else {
ILogger logger = ITextLogManager.GetLogger(typeof(iText.IO.Source.GroupedRandomAccessSource));
#if NET45
logger.LogError(0, ex, iText.IO.Logs.IoLogMessageConstant.ONE_OF_GROUPED_SOURCES_CLOSING_FAILED);
#else
logger.LogError(ex, iText.IO.Logs.IoLogMessageConstant.ONE_OF_GROUPED_SOURCES_CLOSING_FAILED);
#endif
}
}
catch (Exception ex) {
ILogger logger = ITextLogManager.GetLogger(typeof(iText.IO.Source.GroupedRandomAccessSource));
#if NET45
logger.LogError(0, ex, iText.IO.Logs.IoLogMessageConstant.ONE_OF_GROUPED_SOURCES_CLOSING_FAILED);
#else
logger.LogError(ex, iText.IO.Logs.IoLogMessageConstant.ONE_OF_GROUPED_SOURCES_CLOSING_FAILED);
#endif
}
}
if (firstThrownIOExc != null) {
Expand Down
20 changes: 20 additions & 0 deletions itext/itext.kernel/itext/kernel/pdf/PdfDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,11 @@ public virtual void Close() {
}
catch (Exception e) {
ILogger logger = ITextLogManager.GetLogger(typeof(iText.Kernel.Pdf.PdfDocument));
#if NET45
logger.LogError(0, e, iText.IO.Logs.IoLogMessageConstant.PDF_WRITER_CLOSING_FAILED);
#else
logger.LogError(e, iText.IO.Logs.IoLogMessageConstant.PDF_WRITER_CLOSING_FAILED);
#endif
}
}
if (reader != null && IsCloseReader()) {
Expand All @@ -915,7 +919,11 @@ public virtual void Close() {
}
catch (Exception e) {
ILogger logger = ITextLogManager.GetLogger(typeof(iText.Kernel.Pdf.PdfDocument));
#if NET45
logger.LogError(0, e, iText.IO.Logs.IoLogMessageConstant.PDF_READER_CLOSING_FAILED);
#else
logger.LogError(e, iText.IO.Logs.IoLogMessageConstant.PDF_READER_CLOSING_FAILED);
#endif
}
}
}
Expand Down Expand Up @@ -1856,7 +1864,11 @@ public virtual PdfFont GetDefaultFont() {
}
catch (System.IO.IOException e) {
ILogger logger = ITextLogManager.GetLogger(typeof(iText.Kernel.Pdf.PdfDocument));
#if NET45
logger.LogError(0, e, iText.IO.Logs.IoLogMessageConstant.EXCEPTION_WHILE_CREATING_DEFAULT_FONT);
#else
logger.LogError(e, iText.IO.Logs.IoLogMessageConstant.EXCEPTION_WHILE_CREATING_DEFAULT_FONT);
#endif
defaultFont = null;
}
}
Expand Down Expand Up @@ -2228,7 +2240,11 @@ protected internal virtual void UpdateXmpMetadata() {
}
catch (XMPException e) {
ILogger logger = ITextLogManager.GetLogger(typeof(iText.Kernel.Pdf.PdfDocument));
#if NET45
logger.LogError(0, e, iText.IO.Logs.IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA);
#else
logger.LogError(e, iText.IO.Logs.IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA);
#endif
}
}

Expand Down Expand Up @@ -2345,7 +2361,11 @@ protected internal virtual void TryInitTagStructure(PdfDictionary str) {
structTreeRoot = null;
structParentIndex = -1;
ILogger logger = ITextLogManager.GetLogger(typeof(iText.Kernel.Pdf.PdfDocument));
#if NET45
logger.LogError(0, ex, iText.IO.Logs.IoLogMessageConstant.TAG_STRUCTURE_INIT_FAILED);
#else
logger.LogError(ex, iText.IO.Logs.IoLogMessageConstant.TAG_STRUCTURE_INIT_FAILED);
#endif
}
}

Expand Down
4 changes: 4 additions & 0 deletions itext/itext.kernel/itext/kernel/pdf/PdfReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,11 @@ protected internal virtual void ReadPdf() {
catch (Exception ex) {
if (PdfReader.StrictnessLevel.CONSERVATIVE.IsStricter(this.GetStrictnessLevel())) {
ILogger logger = ITextLogManager.GetLogger(typeof(iText.Kernel.Pdf.PdfReader));
#if NET45
logger.LogError(0, ex, iText.IO.Logs.IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT);
#else
logger.LogError(ex, iText.IO.Logs.IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT);
#endif
RebuildXref();
}
else {
Expand Down
8 changes: 8 additions & 0 deletions itext/itext.pdfa/itext/pdfa/PdfADocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ protected override void AddCustomMetadataExtensions(XMPMeta xmpMeta) {
}
catch (XMPException exc) {
ILogger logger = ITextLogManager.GetLogger(typeof(iText.Pdfa.PdfADocument));
#if NET45
logger.LogError(0, exc, iText.IO.Logs.IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA);
#else
logger.LogError(exc, iText.IO.Logs.IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA);
#endif
}
}
}
Expand All @@ -306,7 +310,11 @@ protected override void UpdateXmpMetadata() {
}
catch (XMPException e) {
ILogger logger = ITextLogManager.GetLogger(typeof(iText.Pdfa.PdfADocument));
#if NET45
logger.LogError(0, e, iText.IO.Logs.IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA);
#else
logger.LogError(e, iText.IO.Logs.IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA);
#endif
}
}

Expand Down
4 changes: 4 additions & 0 deletions itext/itext.sign/itext/signatures/CertificateVerification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,11 @@ public static bool VerifyTimestampCertificates(TimeStampToken ts, List<X509Certi

private static void LogExceptionMessages(IList<Exception> exceptionsThrown) {
foreach (Exception ex in exceptionsThrown) {
#if NET45
LOGGER.LogError(0, ex, ex.Message == null ? SignLogMessageConstant.EXCEPTION_WITHOUT_MESSAGE : ex.Message);
#else
LOGGER.LogError(ex, ex.Message == null ? SignLogMessageConstant.EXCEPTION_WITHOUT_MESSAGE : ex.Message);
#endif
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,13 @@ public static IList<CssRuleSet> ParseRuleSet(String selectorStr, String properti
ruleSets.Add(new CssRuleSet(new CssSelector(currentSelectorStr), declarations));
}
catch (Exception exc) {
#if NET45
logger.LogError(0, exc, MessageFormatUtil.Format(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant
.ERROR_PARSING_CSS_SELECTOR, currentSelectorStr));
#else
logger.LogError(exc, MessageFormatUtil.Format(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant
.ERROR_PARSING_CSS_SELECTOR, currentSelectorStr));
#endif
//if any separated selector has errors, all others become invalid.
//in this case we just clear map, it is the easies way to support this.
declarations.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,13 @@ public virtual byte[] RetrieveBytesFromResource(String src) {
return retriever.GetByteArrayByUrl(url);
}
catch (Exception e) {
#if NET45
logger.LogError(0, e, MessageFormatUtil.Format(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNABLE_TO_RETRIEVE_STREAM_WITH_GIVEN_BASE_URI
, uriResolver.GetBaseUri(), src));
#else
logger.LogError(e, MessageFormatUtil.Format(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNABLE_TO_RETRIEVE_STREAM_WITH_GIVEN_BASE_URI
, uriResolver.GetBaseUri(), src));
#endif
return null;
}
}
Expand All @@ -229,8 +234,13 @@ public virtual Stream RetrieveResourceAsInputStream(String src) {
return retriever.GetInputStreamByUrl(url);
}
catch (Exception e) {
#if NET45
logger.LogError(0, e, MessageFormatUtil.Format(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNABLE_TO_RETRIEVE_STREAM_WITH_GIVEN_BASE_URI
, uriResolver.GetBaseUri(), src));
#else
logger.LogError(e, MessageFormatUtil.Format(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNABLE_TO_RETRIEVE_STREAM_WITH_GIVEN_BASE_URI
, uriResolver.GetBaseUri(), src));
#endif
return null;
}
}
Expand Down
16 changes: 15 additions & 1 deletion itext/itext.svg/itext/svg/css/impl/SvgStyleResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ public SvgStyleResolver(SvgProcessorContext context) {
}
}
catch (System.IO.IOException e) {
#if NET45
LOGGER.LogWarning(0, e, SvgLogMessageConstant.ERROR_INITIALIZING_DEFAULT_CSS);
#else
LOGGER.LogWarning(e, SvgLogMessageConstant.ERROR_INITIALIZING_DEFAULT_CSS);
#endif
this.css = new CssStyleSheet();
}
this.resourceResolver = context.GetResourceResolver();
Expand Down Expand Up @@ -287,8 +291,13 @@ private void ProcessXLink(IAttribute attr, IDictionary<String, String> attribute
xlinkValue = this.resourceResolver.ResolveAgainstBaseUri(attr.GetValue()).ToExternalForm();
}
catch (UriFormatException mue) {
LOGGER.LogError(mue, iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNABLE_TO_RESOLVE_IMAGE_URL
#if NET45
LOGGER.LogError(0, mue, iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNABLE_TO_RESOLVE_IMAGE_URL
);
#else
LOGGER.LogError(mue, iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNABLE_TO_RESOLVE_IMAGE_URL
);
#endif
}
}
attributesMap.Put(attr.GetKey(), xlinkValue);
Expand Down Expand Up @@ -341,8 +350,13 @@ private void CollectCssDeclarations(INode rootNode, ResourceResolver resourceRes
}
}
catch (Exception exc) {
#if NET45
LOGGER.LogError(0, exc, iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNABLE_TO_PROCESS_EXTERNAL_CSS_FILE
);
#else
LOGGER.LogError(exc, iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNABLE_TO_PROCESS_EXTERNAL_CSS_FILE
);
#endif
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,13 @@ protected internal override void DoDraw(SvgDrawContext context) {
inverseMatrix = translation.CreateInverse();
}
catch (NoninvertibleTransformException ex) {
ITextLogManager.GetLogger(typeof(UseSvgNodeRenderer)).LogWarning(ex, SvgLogMessageConstant.NONINVERTIBLE_TRANSFORMATION_MATRIX_USED_IN_CLIP_PATH
#if NET45
ITextLogManager.GetLogger(typeof(UseSvgNodeRenderer)).LogWarning(0, ex, SvgLogMessageConstant.NONINVERTIBLE_TRANSFORMATION_MATRIX_USED_IN_CLIP_PATH
);
#else
ITextLogManager.GetLogger(typeof(UseSvgNodeRenderer)).LogWarning(ex, SvgLogMessageConstant.NONINVERTIBLE_TRANSFORMATION_MATRIX_USED_IN_CLIP_PATH
);
#endif
}
}
}
Expand Down