diff --git a/itext.tests/itext.sign.tests/itext/signatures/IssuingCertificateRetrieverTest.cs b/itext.tests/itext.sign.tests/itext/signatures/IssuingCertificateRetrieverTest.cs new file mode 100644 index 0000000000..f7ab08a14a --- /dev/null +++ b/itext.tests/itext.sign.tests/itext/signatures/IssuingCertificateRetrieverTest.cs @@ -0,0 +1,63 @@ +/* +This file is part of the iText (R) project. +Copyright (c) 1998-2024 Apryse Group NV +Authors: Apryse Software. + +This program is offered under a commercial and under the AGPL license. +For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + +AGPL licensing: +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ +using System; +using System.Collections.Generic; +using iText.Commons.Bouncycastle.Cert; +using iText.Commons.Utils; +using iText.Signatures.Testutils; +using iText.Signatures.Validation; +using iText.Signatures.Validation.Mocks; +using iText.Test; + +namespace iText.Signatures { +//\cond DO_NOT_DOCUMENT + internal class IssuingCertificateRetrieverTest : ExtendedITextTest { + private static readonly String CERTS_SRC = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext + .CurrentContext.TestDirectory) + "/resources/itext/signatures/certs/"; + + private static readonly char[] PASSWORD = "testpassphrase".ToCharArray(); + + [NUnit.Framework.Test] + public virtual void TestResourceRetrieverUsage() { + IX509Certificate[] cert = PemFileHelper.ReadFirstChain(CERTS_SRC + "intermediate.pem"); + IList urlsCalled = new List(); + MockResourceRetriever mockRetriever = new MockResourceRetriever(); + mockRetriever.OnGetInputStreamByUrl((u) => { + urlsCalled.Add(u); + try { + return FileUtil.GetInputStreamForFile(CERTS_SRC + "root.pem"); + } + catch (System.IO.IOException e) { + throw new Exception("Error reading certificate.", e); + } + } + ); + ValidatorChainBuilder builder = new ValidatorChainBuilder().WithResourceRetriever(() => mockRetriever); + builder.GetCertificateRetriever().RetrieveIssuerCertificate(cert[0]); + NUnit.Framework.Assert.AreEqual(1, urlsCalled.Count); + NUnit.Framework.Assert.AreEqual("http://test.example.com/example-ca/certs/ca/ca.crt", urlsCalled[0].ToString + ()); + } + } +//\endcond +} diff --git a/itext.tests/itext.sign.tests/itext/signatures/testutils/client/TestOcspClientWrapper.cs b/itext.tests/itext.sign.tests/itext/signatures/testutils/client/TestOcspClientWrapper.cs index e920b505a4..acc7653b8c 100644 --- a/itext.tests/itext.sign.tests/itext/signatures/testutils/client/TestOcspClientWrapper.cs +++ b/itext.tests/itext.sign.tests/itext/signatures/testutils/client/TestOcspClientWrapper.cs @@ -29,17 +29,22 @@ You should have received a copy of the GNU Affero General Public License using iText.Signatures; namespace iText.Signatures.Testutils.Client { - public class TestOcspClientWrapper : IOcspClient { + public class TestOcspClientWrapper : IOcspClient, IOcspClientBouncyCastle { private static readonly IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.GetFactory (); private readonly IList calls = new List(); + private readonly IList basicCalls = new List(); + private readonly IOcspClient wrappedClient; private Func onGetEncoded; + private Func onGetBasicPOcspResponse; + public TestOcspClientWrapper(IOcspClient wrappedClient) { this.wrappedClient = wrappedClient; } @@ -70,12 +75,36 @@ public virtual byte[] GetEncoded(IX509Certificate checkCert, IX509Certificate is return calls; } + public virtual IList GetBasicResponceCalls() { + return basicCalls; + } + public virtual iText.Signatures.Testutils.Client.TestOcspClientWrapper OnGetEncodedDo(Func callBack) { onGetEncoded = callBack; return this; } + public virtual IBasicOcspResponse GetBasicOCSPResp(IX509Certificate checkCert, IX509Certificate issuerCert + , String url) { + TestOcspClientWrapper.BasicOCSPCall call = new TestOcspClientWrapper.BasicOCSPCall(checkCert, issuerCert, + url); + basicCalls.Add(call); + if (onGetBasicPOcspResponse != null) { + return onGetBasicPOcspResponse.Invoke(call); + } + if (wrappedClient is IOcspClientBouncyCastle) { + return ((IOcspClientBouncyCastle)wrappedClient).GetBasicOCSPResp(checkCert, issuerCert, url); + } + throw new Exception("TestOcspClientWrapper for IOcspClientBouncyCastle was expected here."); + } + + public virtual iText.Signatures.Testutils.Client.TestOcspClientWrapper OnGetBasicOCSPRespDo(Func callback) { + onGetBasicPOcspResponse = callback; + return this; + } + public class OcspClientCall { public readonly IX509Certificate checkCert; @@ -95,5 +124,19 @@ public virtual void SetResponce(IBasicOcspResponse basicOCSPResp) { response = basicOCSPResp; } } + + public class BasicOCSPCall { + public readonly IX509Certificate checkCert; + + public readonly IX509Certificate issuerCert; + + public readonly String url; + + public BasicOCSPCall(IX509Certificate checkCert, IX509Certificate issuerCert, String url) { + this.checkCert = checkCert; + this.issuerCert = issuerCert; + this.url = url; + } + } } } diff --git a/itext.tests/itext.sign.tests/itext/signatures/validation/RevocationDataValidatorTest.cs b/itext.tests/itext.sign.tests/itext/signatures/validation/RevocationDataValidatorTest.cs index a497b715b9..5ea1883c13 100644 --- a/itext.tests/itext.sign.tests/itext/signatures/validation/RevocationDataValidatorTest.cs +++ b/itext.tests/itext.sign.tests/itext/signatures/validation/RevocationDataValidatorTest.cs @@ -411,7 +411,7 @@ public virtual void CrlEncodingErrorTest() { parameters.SetFreshness(ValidatorContexts.All(), CertificateSources.All(), TimeBasedContexts.All(), TimeSpan.FromDays (2)); RevocationDataValidator validator = validatorChainBuilder.BuildRevocationDataValidator(); - validator.AddCrlClient(new _ICrlClient_557(crl)).Validate(report, baseContext, checkCert, TimeTestUtil.TEST_DATE_TIME + validator.AddCrlClient(new _ICrlClient_561(crl)).Validate(report, baseContext, checkCert, TimeTestUtil.TEST_DATE_TIME ); AssertValidationReport.AssertThat(report, (a) => a.HasStatus(ValidationReport.ValidationResult.INDETERMINATE ).HasLogItem((la) => la.WithCheckName(RevocationDataValidator.REVOCATION_DATA_CHECK).WithMessage(MessageFormatUtil @@ -420,8 +420,8 @@ public virtual void CrlEncodingErrorTest() { ))); } - private sealed class _ICrlClient_557 : ICrlClient { - public _ICrlClient_557(byte[] crl) { + private sealed class _ICrlClient_561 : ICrlClient { + public _ICrlClient_561(byte[] crl) { this.crl = crl; } @@ -519,7 +519,7 @@ public virtual void ResponsesFromValidationClientArePassedTest() { mockCrlValidator.OnCallDo((c) => NUnit.Framework.Assert.AreEqual(crlGeneration, c.responseGenerationDate)); ValidationReport report = new ValidationReport(); RevocationDataValidator validator = validatorChainBuilder.GetRevocationDataValidator(); - ValidationOcspClient ocspClient = new _ValidationOcspClient_676(); + ValidationOcspClient ocspClient = new _ValidationOcspClient_680(); TestOcspResponseBuilder ocspBuilder = new TestOcspResponseBuilder(responderCert, ocspRespPrivateKey); byte[] ocspResponseBytes = new TestOcspClient().AddBuilderForCertIssuer(caCert, ocspBuilder).GetEncoded(checkCert , caCert, null); @@ -527,7 +527,7 @@ public virtual void ResponsesFromValidationClientArePassedTest() { )); ocspClient.AddResponse(basicOCSPResp, ocspGeneration, TimeBasedContext.HISTORICAL); validator.AddOcspClient(ocspClient); - ValidationCrlClient crlClient = new _ValidationCrlClient_691(); + ValidationCrlClient crlClient = new _ValidationCrlClient_695(); TestCrlBuilder crlBuilder = new TestCrlBuilder(caCert, caPrivateKey, checkDate); byte[] crlResponseBytes = new List(new TestCrlClient().AddBuilderForCertIssuer(crlBuilder).GetEncoded (checkCert, null))[0]; @@ -537,8 +537,8 @@ public virtual void ResponsesFromValidationClientArePassedTest() { validator.Validate(report, baseContext, checkCert, checkDate); } - private sealed class _ValidationOcspClient_676 : ValidationOcspClient { - public _ValidationOcspClient_676() { + private sealed class _ValidationOcspClient_680 : ValidationOcspClient { + public _ValidationOcspClient_680() { } public override byte[] GetEncoded(IX509Certificate checkCert, IX509Certificate issuerCert, String url) { @@ -547,8 +547,8 @@ public override byte[] GetEncoded(IX509Certificate checkCert, IX509Certificate i } } - private sealed class _ValidationCrlClient_691 : ValidationCrlClient { - public _ValidationCrlClient_691() { + private sealed class _ValidationCrlClient_695 : ValidationCrlClient { + public _ValidationCrlClient_695() { } public override ICollection GetEncoded(IX509Certificate checkCert, String url) { @@ -614,18 +614,18 @@ public virtual void TimeBasedContextProperlySetOnlineClientsTest() { RevocationDataValidator validator = validatorChainBuilder.GetRevocationDataValidator(); TestOcspResponseBuilder ocspBuilder = new TestOcspResponseBuilder(responderCert, ocspRespPrivateKey); TestOcspClient testOcspClient = new TestOcspClient().AddBuilderForCertIssuer(caCert, ocspBuilder); - OcspClientBouncyCastle ocspClient = new _OcspClientBouncyCastle_770(testOcspClient); + OcspClientBouncyCastle ocspClient = new _OcspClientBouncyCastle_774(testOcspClient); validator.AddOcspClient(ocspClient); TestCrlBuilder crlBuilder = new TestCrlBuilder(caCert, caPrivateKey, checkDate); TestCrlClient testCrlClient = new TestCrlClient().AddBuilderForCertIssuer(crlBuilder); - CrlClientOnline crlClient = new _CrlClientOnline_780(testCrlClient); + CrlClientOnline crlClient = new _CrlClientOnline_784(testCrlClient); validator.AddCrlClient(crlClient); validator.Validate(report, baseContext.SetTimeBasedContext(TimeBasedContext.HISTORICAL), checkCert, checkDate ); } - private sealed class _OcspClientBouncyCastle_770 : OcspClientBouncyCastle { - public _OcspClientBouncyCastle_770(TestOcspClient testOcspClient) { + private sealed class _OcspClientBouncyCastle_774 : OcspClientBouncyCastle { + public _OcspClientBouncyCastle_774(TestOcspClient testOcspClient) { this.testOcspClient = testOcspClient; } @@ -636,8 +636,8 @@ public override byte[] GetEncoded(IX509Certificate checkCert, IX509Certificate r private readonly TestOcspClient testOcspClient; } - private sealed class _CrlClientOnline_780 : CrlClientOnline { - public _CrlClientOnline_780(TestCrlClient testCrlClient) { + private sealed class _CrlClientOnline_784 : CrlClientOnline { + public _CrlClientOnline_784(TestCrlClient testCrlClient) { this.testCrlClient = testCrlClient; } @@ -802,5 +802,40 @@ public virtual void CrlClientGetEncodedFailureTest() { ).HasLogItem((l) => l.WithMessage(RevocationDataValidator.CRL_CLIENT_FAILURE, (p) => crlClient.ToString ()))); } + + [NUnit.Framework.Test] + public virtual void TestCrlClientInjection() { + TestCrlClient testCrlClient = new TestCrlClient(); + TestCrlClientWrapper mockCrlClient = new TestCrlClientWrapper(testCrlClient); + validatorChainBuilder.WithCrlClient(() => mockCrlClient); + testCrlClient.AddBuilderForCertIssuer(caCert, caPrivateKey); + ValidationReport report = new ValidationReport(); + ValidationContext context = new ValidationContext(ValidatorContext.CERTIFICATE_CHAIN_VALIDATOR, CertificateSource + .SIGNER_CERT, TimeBasedContext.HISTORICAL); + validatorChainBuilder.BuildRevocationDataValidator().Validate(report, context, checkCert, TimeTestUtil.TEST_DATE_TIME + ); + NUnit.Framework.Assert.AreEqual(1, mockCrlClient.GetCalls().Count); + } + + [NUnit.Framework.Test] + public virtual void TestOcspClientInjection() { + DateTime checkDate = TimeTestUtil.TEST_DATE_TIME; + TestOcspResponseBuilder builder = new TestOcspResponseBuilder(responderCert, ocspRespPrivateKey); + builder.SetProducedAt(checkDate.AddDays(5)); + builder.SetThisUpdate(DateTimeUtil.GetCalendar(checkDate.AddDays(5))); + builder.SetNextUpdate(DateTimeUtil.GetCalendar(checkDate.AddDays(10))); + TestOcspClientWrapper mockOcspClient = new TestOcspClientWrapper(new TestOcspClient().AddBuilderForCertIssuer + (caCert, builder)); + validatorChainBuilder.WithOcspClient(() => mockOcspClient); + mockParameters.AddRevocationOnlineFetchingResponse(SignatureValidationProperties.OnlineFetching.ALWAYS_FETCH + ); + certificateRetriever.AddKnownCertificates(JavaUtil.ArraysAsList(caCert, trustedOcspResponderCert)); + ValidationReport report = new ValidationReport(); + ValidationContext context = new ValidationContext(ValidatorContext.CERTIFICATE_CHAIN_VALIDATOR, CertificateSource + .SIGNER_CERT, TimeBasedContext.HISTORICAL); + validatorChainBuilder.BuildRevocationDataValidator().Validate(report, context, checkCert, TimeTestUtil.TEST_DATE_TIME + ); + NUnit.Framework.Assert.AreEqual(2, mockOcspClient.GetBasicResponceCalls().Count); + } } } diff --git a/itext.tests/itext.sign.tests/itext/signatures/validation/mocks/MockResourceRetriever.cs b/itext.tests/itext.sign.tests/itext/signatures/validation/mocks/MockResourceRetriever.cs new file mode 100644 index 0000000000..7886ce106e --- /dev/null +++ b/itext.tests/itext.sign.tests/itext/signatures/validation/mocks/MockResourceRetriever.cs @@ -0,0 +1,51 @@ +/* +This file is part of the iText (R) project. +Copyright (c) 1998-2024 Apryse Group NV +Authors: Apryse Software. + +This program is offered under a commercial and under the AGPL license. +For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + +AGPL licensing: +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ +using System; +using System.IO; +using iText.StyledXmlParser.Resolver.Resource; + +namespace iText.Signatures.Validation.Mocks { + public class MockResourceRetriever : IResourceRetriever { + private Func getByteArrayByUrlHandler = (u) => null; + + private Func getInputStreamByUrlHandler = (u) => null; + + public virtual Stream GetInputStreamByUrl(Uri url) { + return getInputStreamByUrlHandler.Invoke(url); + } + + public virtual byte[] GetByteArrayByUrl(Uri url) { + return getByteArrayByUrlHandler.Invoke(url); + } + + public virtual MockResourceRetriever OnGetInputStreamByUrl(Func handler) { + getInputStreamByUrlHandler = handler; + return this; + } + + public virtual MockResourceRetriever OnGetByteArrayByUrl(Func handler) { + getByteArrayByUrlHandler = handler; + return this; + } + } +} diff --git a/itext.tests/itext.svg.tests/itext/svg/css/AttributesRelativeUnitTest.cs b/itext.tests/itext.svg.tests/itext/svg/css/AttributesRelativeUnitTest.cs index 22a8bb17d9..0b8e35711d 100644 --- a/itext.tests/itext.svg.tests/itext/svg/css/AttributesRelativeUnitTest.cs +++ b/itext.tests/itext.svg.tests/itext/svg/css/AttributesRelativeUnitTest.cs @@ -21,6 +21,8 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ using System; +using iText.Kernel.Geom; +using iText.Svg.Processors.Impl; using iText.Svg.Renderers; using iText.Test; @@ -66,5 +68,140 @@ public virtual void ImageAttributesExUnitsTest() { public virtual void ImageAttributesPercentUnitsTest() { ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "imageAttributesPercentUnits"); } + + //-------------- Nested svg + [NUnit.Framework.Test] + public virtual void NestedSvgWidthPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "nestedSvgWidthPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void NestedSvgXPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "nestedSvgXPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void NestedSvgHeightPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "nestedSvgHeightPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void NestedSvgYPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "nestedSvgYPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void NestedSvgWidthEmTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "nestedSvgWidthEmTest"); + } + + [NUnit.Framework.Test] + public virtual void NestedSvgAllPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "nestedSvgAllPercentTest"); + } + + //-------------- Top level svg + [NUnit.Framework.Test] + public virtual void SvgWidthPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "svgWidthPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void SvgViewboxWidthPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "svgViewboxWidthPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void SvgHeightPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "svgHeightPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void SvgWidthAndHeightEmAndRemTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "svgWidthAndHeightEmAndRemTest"); + } + + //-------------- use + [NUnit.Framework.Test] + public virtual void UseXPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "useXPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void UseYPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "useYPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void UseXAndYEmAndRemTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "useXAndYEmAndRemTest"); + } + + [NUnit.Framework.Test] + public virtual void UseWidthPercentTest() { + // TODO DEVSIX-4566 Processing of width&height attributes in use tag are not currently supported + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "useWidthPercentTest"); + } + + //-------------- symbol + [NUnit.Framework.Test] + public virtual void SymbolXPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "symbolXPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void SymbolYPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "symbolYPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void SymbolXAndYEmAndRemTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "symbolXAndYEmAndRemTest"); + } + + [NUnit.Framework.Test] + public virtual void SymbolWidthAndHeightPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "symbolWidthAndHeightPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void SymbolWidthAndHeightEmAndRemTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "symbolWidthAndHeightEmAndRemTest"); + } + + //-------------- misc + [NUnit.Framework.Test] + public virtual void LinePercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "linePercentTest"); + } + + [NUnit.Framework.Test] + public virtual void DiffViewBoxAndPortPercent1Test() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "diffViewBoxAndPortPercent1Test"); + } + + [NUnit.Framework.Test] + public virtual void DiffViewBoxAndPortPercent2Test() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "diffViewBoxAndPortPercent2Test"); + } + + [NUnit.Framework.Test] + public virtual void NoViewBoxAndViewPortPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "noViewBoxAndViewPortPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void NoViewBoxPercentTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "noViewBoxPercentTest"); + } + + [NUnit.Framework.Test] + public virtual void ViewportFromConverterPropertiesTest() { + SvgConverterProperties properties = new SvgConverterProperties(); + properties.SetCustomViewport(new Rectangle(500, 500)); + // It is expected that the result is different with browser. In + // browsers the result should be bigger but with the same proportions + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "viewportFromConverterPropertiesTest", properties); + } } } diff --git a/itext.tests/itext.svg.tests/itext/svg/css/SvgStyleResolverIntegrationTest.cs b/itext.tests/itext.svg.tests/itext/svg/css/SvgStyleResolverIntegrationTest.cs index 0b77ae8895..a4bcd9b9ae 100644 --- a/itext.tests/itext.svg.tests/itext/svg/css/SvgStyleResolverIntegrationTest.cs +++ b/itext.tests/itext.svg.tests/itext/svg/css/SvgStyleResolverIntegrationTest.cs @@ -132,7 +132,6 @@ public virtual void ValidLocalFontTest() { [NUnit.Framework.Test] public virtual void FontWeightTest() { - //TODO DEVSIX-2079: change compare file after fix ConvertAndCompare(sourceFolder, destinationFolder, "fontWeightTest"); } diff --git a/itext.tests/itext.svg.tests/itext/svg/renderers/RelativePositionsTest.cs b/itext.tests/itext.svg.tests/itext/svg/renderers/RelativePositionsTest.cs index c3fe8dad8e..7ef0da018b 100644 --- a/itext.tests/itext.svg.tests/itext/svg/renderers/RelativePositionsTest.cs +++ b/itext.tests/itext.svg.tests/itext/svg/renderers/RelativePositionsTest.cs @@ -43,7 +43,6 @@ public virtual void RelativePositionsBasic1Test() { ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "relativePositionsBasic"); } - //TODO DEVSIX-5740: Update cmp file after supporting [NUnit.Framework.Test] public virtual void RelativePositionsBasic2Test() { ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "relativePositionsBasic2"); diff --git a/itext.tests/itext.svg.tests/itext/svg/renderers/SvgImageRendererTest.cs b/itext.tests/itext.svg.tests/itext/svg/renderers/SvgImageRendererTest.cs index bf13351754..357417f446 100644 --- a/itext.tests/itext.svg.tests/itext/svg/renderers/SvgImageRendererTest.cs +++ b/itext.tests/itext.svg.tests/itext/svg/renderers/SvgImageRendererTest.cs @@ -59,7 +59,7 @@ public virtual void SvgWithSvgTest() { INode parsedSvg = SvgConverter.Parse(FileUtil.GetInputStreamForFile(svgFileName)); ISvgProcessorResult result = new DefaultSvgProcessor().Process(parsedSvg, null); ISvgNodeRenderer topSvgRenderer = result.GetRootRenderer(); - Rectangle wh = SvgCssUtils.ExtractWidthAndHeight(topSvgRenderer, 0.0F, 0.0F); + Rectangle wh = SvgCssUtils.ExtractWidthAndHeight(topSvgRenderer, 0.0F, new SvgDrawContext(null, null)); SvgImageXObject svgImageXObject = new SvgImageXObject(wh, result, new ResourceResolver(SOURCE_FOLDER)); SvgImage svgImage = new SvgImage(svgImageXObject); document.Add(svgImage); @@ -80,7 +80,7 @@ public virtual void CustomSvgImageTest() { ISvgProcessorResult result = new DefaultSvgProcessor().Process(parsedSvg, new SvgConverterProperties().SetBaseUri (svgFileName)); ISvgNodeRenderer topSvgRenderer = result.GetRootRenderer(); - Rectangle wh = SvgCssUtils.ExtractWidthAndHeight(topSvgRenderer, 0.0F, 0.0F); + Rectangle wh = SvgCssUtils.ExtractWidthAndHeight(topSvgRenderer, 0.0F, new SvgDrawContext(null, null)); SvgImageXObject svgImageXObject = new SvgImageXObject(wh, result, new ResourceResolver(SOURCE_FOLDER)); SvgImage svgImage = new SvgImage(svgImageXObject); document.Add(svgImage); @@ -101,7 +101,7 @@ public virtual void NoSpecifiedWidthHeightImageTest() { ISvgProcessorResult result = new DefaultSvgProcessor().Process(parsedSvg, new SvgConverterProperties().SetBaseUri (svgFileName)); ISvgNodeRenderer topSvgRenderer = result.GetRootRenderer(); - Rectangle wh = SvgCssUtils.ExtractWidthAndHeight(topSvgRenderer, 0.0F, 0.0F); + Rectangle wh = SvgCssUtils.ExtractWidthAndHeight(topSvgRenderer, 0.0F, new SvgDrawContext(null, null)); document.Add(new SvgImage(new SvgImageXObject(wh, result, new ResourceResolver(SOURCE_FOLDER)))); } NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, DESTINATION_FOLDER diff --git a/itext.tests/itext.svg.tests/itext/svg/renderers/SvgIntegrationTest.cs b/itext.tests/itext.svg.tests/itext/svg/renderers/SvgIntegrationTest.cs index 2214b3e76b..726ee74da1 100644 --- a/itext.tests/itext.svg.tests/itext/svg/renderers/SvgIntegrationTest.cs +++ b/itext.tests/itext.svg.tests/itext/svg/renderers/SvgIntegrationTest.cs @@ -43,14 +43,14 @@ public virtual void Convert(Stream svg, Stream pdfOutputStream) { } public virtual void Convert(String svg, String output) { - Convert(svg, output, PageSize.DEFAULT); + Convert(svg, output, PageSize.DEFAULT, new SvgConverterProperties()); } - public virtual void Convert(String svg, String output, PageSize size) { + public virtual void Convert(String svg, String output, PageSize size, SvgConverterProperties properties) { using (PdfDocument doc = new PdfDocument(new PdfWriter(output, new WriterProperties().SetCompressionLevel( 0)))) { doc.AddNewPage(size); - ISvgConverterProperties properties = new SvgConverterProperties().SetBaseUri(svg); + properties.SetBaseUri(svg); SvgConverter.DrawOnDocument(FileUtil.GetInputStreamForFile(svg), doc, 1, properties); } } @@ -99,8 +99,19 @@ public virtual void ConvertAndCompare(String src, String dest, String fileName) ConvertAndCompare(src, dest, fileName, PageSize.DEFAULT); } + public virtual void ConvertAndCompare(String src, String dest, String fileName, SvgConverterProperties properties + ) { + ConvertAndCompare(src, dest, fileName, PageSize.DEFAULT, properties); + } + public virtual void ConvertAndCompare(String src, String dest, String fileName, PageSize size) { - Convert(src + fileName + ".svg", dest + fileName + ".pdf", size); + Convert(src + fileName + ".svg", dest + fileName + ".pdf", size, new SvgConverterProperties()); + Compare(fileName, src, dest); + } + + public virtual void ConvertAndCompare(String src, String dest, String fileName, PageSize size, SvgConverterProperties + properties) { + Convert(src + fileName + ".svg", dest + fileName + ".pdf", size, properties); Compare(fileName, src, dest); } diff --git a/itext.tests/itext.svg.tests/itext/svg/renderers/impl/SimpleSvgTagSvgNodeRendererIntegrationTest.cs b/itext.tests/itext.svg.tests/itext/svg/renderers/impl/SimpleSvgTagSvgNodeRendererIntegrationTest.cs index e42b88a064..7c0e2b8ef2 100644 --- a/itext.tests/itext.svg.tests/itext/svg/renderers/impl/SimpleSvgTagSvgNodeRendererIntegrationTest.cs +++ b/itext.tests/itext.svg.tests/itext/svg/renderers/impl/SimpleSvgTagSvgNodeRendererIntegrationTest.cs @@ -23,10 +23,8 @@ You should have received a copy of the GNU Affero General Public License using System; using iText.Commons.Utils; using iText.StyledXmlParser.Exceptions; -using iText.Svg.Logs; using iText.Svg.Renderers; using iText.Test; -using iText.Test.Attributes; namespace iText.Svg.Renderers.Impl { [NUnit.Framework.Category("IntegrationTest")] @@ -48,23 +46,16 @@ public virtual void EverythingPresentAndValidTest() { } [NUnit.Framework.Test] - //TODO: change cmp file after DEVSIX-3123 fixed - [LogMessage(SvgLogMessageConstant.MISSING_HEIGHT)] public virtual void AbsentHeight() { ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "absentHeight"); } [NUnit.Framework.Test] - //TODO: change cmp file after DEVSIX-3123 fixed - [LogMessage(SvgLogMessageConstant.MISSING_WIDTH)] public virtual void AbsentWidth() { ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "absentWidth"); } [NUnit.Framework.Test] - //TODO: change cmp file after DEVSIX-3123 fixed - [LogMessage(SvgLogMessageConstant.MISSING_WIDTH)] - [LogMessage(SvgLogMessageConstant.MISSING_HEIGHT)] public virtual void AbsentWidthAndHeight() { ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "absentWidthAndHeight"); } @@ -100,14 +91,12 @@ public virtual void InvalidWidth() { [NUnit.Framework.Test] public virtual void InvalidX() { - NUnit.Framework.Assert.Catch(typeof(StyledXMLParserException), () => ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER - , "invalidX")); + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "invalidX"); } [NUnit.Framework.Test] public virtual void InvalidY() { - NUnit.Framework.Assert.Catch(typeof(StyledXMLParserException), () => ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER - , "invalidY")); + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "invalidY"); } [NUnit.Framework.Test] diff --git a/itext.tests/itext.svg.tests/itext/svg/renderers/impl/SvgTagSvgNodeRendererUnitTest.cs b/itext.tests/itext.svg.tests/itext/svg/renderers/impl/SvgTagSvgNodeRendererUnitTest.cs index 0d6fe8a7a6..66954bd0fa 100644 --- a/itext.tests/itext.svg.tests/itext/svg/renderers/impl/SvgTagSvgNodeRendererUnitTest.cs +++ b/itext.tests/itext.svg.tests/itext/svg/renderers/impl/SvgTagSvgNodeRendererUnitTest.cs @@ -20,6 +20,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ +using System; +using System.Collections.Generic; using System.IO; using iText.Kernel.Geom; using iText.Kernel.Pdf; @@ -43,6 +45,7 @@ public virtual void CalculateNestedViewportSameAsParentTest() { context.PushCanvas(canvas); context.AddViewPort(expected); SvgTagSvgNodeRenderer parent = new SvgTagSvgNodeRenderer(); + parent.SetAttributesAndStyles(new Dictionary()); SvgTagSvgNodeRenderer renderer = new SvgTagSvgNodeRenderer(); renderer.SetParent(parent); Rectangle actual = renderer.CalculateViewPort(context); diff --git a/itext.tests/itext.svg.tests/itext/svg/renderers/impl/SymbolTest.cs b/itext.tests/itext.svg.tests/itext/svg/renderers/impl/SymbolTest.cs index d0c4af3a05..7f0a1a38fb 100644 --- a/itext.tests/itext.svg.tests/itext/svg/renderers/impl/SymbolTest.cs +++ b/itext.tests/itext.svg.tests/itext/svg/renderers/impl/SymbolTest.cs @@ -25,7 +25,6 @@ You should have received a copy of the GNU Affero General Public License using iText.Svg.Processors.Impl; using iText.Svg.Renderers; using iText.Test; -using iText.Test.Attributes; namespace iText.Svg.Renderers.Impl { [NUnit.Framework.Category("IntegrationTest")] @@ -64,23 +63,22 @@ public virtual void HeightPxAttrTest() { } [NUnit.Framework.Test] - [LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNKNOWN_ABSOLUTE_METRIC_LENGTH_PARSED - )] public virtual void HeightPercentsAttrTest() { - // TODO DEVSIX-4388 The handling of width and height attributes with percentages is not currently supported ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "heightPercentsAttrTest"); } + [NUnit.Framework.Test] + public virtual void HeightEmTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "heightEmTest"); + } + [NUnit.Framework.Test] public virtual void WidthPxAttrTest() { ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "widthPxAttrTest"); } [NUnit.Framework.Test] - [LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNKNOWN_ABSOLUTE_METRIC_LENGTH_PARSED - )] public virtual void WidthPercentsAttrTest() { - // TODO DEVSIX-4388 The handling of width and height attributes with percentages is not currently supported ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "widthPercentsAttrTest"); } @@ -90,15 +88,13 @@ public virtual void WidthHeightAttrPxTest() { } [NUnit.Framework.Test] - [LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNKNOWN_ABSOLUTE_METRIC_LENGTH_PARSED - , Count = 2)] public virtual void WidthHeightAttrPercentsPxTest() { - // TODO DEVSIX-4388 The handling of width and height attributes with percentages is not currently supported ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "widthHeightAttrPercentsPxTest"); } [NUnit.Framework.Test] public virtual void PreserveAspectRatioViewBoxTest() { + // TODO DEVSIX-3537 Processing of preserveAspectRatio attribute with offsets x and y is not currently supported ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "preserveAspectRatioViewBoxTest"); } @@ -169,29 +165,20 @@ public virtual void UseHeightWidthAllUnitsTest() { } [NUnit.Framework.Test] - [LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNKNOWN_ABSOLUTE_METRIC_LENGTH_PARSED - )] public virtual void UseSymbolHeightWidthAllUnitsTest() { - // TODO DEVSIX-4388 The handling of width and height attributes with percentages is not currently supported // TODO DEVSIX-4566 Processing of width&height attributes in use tag are not currently supported ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "useSymbolHeightWidthAllUnitsTest", properties ); } [NUnit.Framework.Test] - [LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNKNOWN_ABSOLUTE_METRIC_LENGTH_PARSED - , Count = 2)] public virtual void UseSymbolXYContrudictionAllUnitsTest() { - // TODO DEVSIX-4388 The handling of x and y attributes with percentages is not currently supported ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "useSymbolXYContrudictionAllUnitsTest", properties ); } [NUnit.Framework.Test] - [LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNKNOWN_ABSOLUTE_METRIC_LENGTH_PARSED - , Count = 4)] public virtual void UseSymbolCoordinatesContrudictionTest() { - // TODO DEVSIX-2654 Percent values are not correctly processed ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "useSymbolCoordinatesContrudiction", properties ); } diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_diffViewBoxAndPortPercent1Test.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_diffViewBoxAndPortPercent1Test.pdf new file mode 100644 index 0000000000..de788ea817 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_diffViewBoxAndPortPercent1Test.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_diffViewBoxAndPortPercent2Test.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_diffViewBoxAndPortPercent2Test.pdf new file mode 100644 index 0000000000..cde55d3ec0 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_diffViewBoxAndPortPercent2Test.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_imageAttributesEmUnits.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_imageAttributesEmUnits.pdf index 04c96ea56b..42cd3612e8 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_imageAttributesEmUnits.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_imageAttributesEmUnits.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_imageAttributesExUnits.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_imageAttributesExUnits.pdf index 0db7f088d4..1309d96eb0 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_imageAttributesExUnits.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_imageAttributesExUnits.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_imageAttributesPercentUnits.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_imageAttributesPercentUnits.pdf index 337233ee47..9c16791b06 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_imageAttributesPercentUnits.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_imageAttributesPercentUnits.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_linePercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_linePercentTest.pdf new file mode 100644 index 0000000000..7e646bc7c1 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_linePercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgAllPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgAllPercentTest.pdf new file mode 100644 index 0000000000..f17732b9ab Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgAllPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgHeightPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgHeightPercentTest.pdf new file mode 100644 index 0000000000..0645307a16 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgHeightPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgWidthEmTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgWidthEmTest.pdf new file mode 100644 index 0000000000..d39520d948 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgWidthEmTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgWidthPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgWidthPercentTest.pdf new file mode 100644 index 0000000000..4c846f9a07 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgWidthPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgXPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgXPercentTest.pdf new file mode 100644 index 0000000000..52a4599cb5 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgXPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgYPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgYPercentTest.pdf new file mode 100644 index 0000000000..e478f6795f Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_nestedSvgYPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_noViewBoxAndViewPortPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_noViewBoxAndViewPortPercentTest.pdf new file mode 100644 index 0000000000..e058420eb3 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_noViewBoxAndViewPortPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_noViewBoxPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_noViewBoxPercentTest.pdf new file mode 100644 index 0000000000..a0bbad20ed Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_noViewBoxPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_rectangleAttributesEmUnits.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_rectangleAttributesEmUnits.pdf index 3fac7cb214..0f324ae3a9 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_rectangleAttributesEmUnits.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_rectangleAttributesEmUnits.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_rectangleAttributesExUnits.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_rectangleAttributesExUnits.pdf index e5e3ba1f62..48d7d41cdd 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_rectangleAttributesExUnits.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_rectangleAttributesExUnits.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_rectangleAttributesPercentUnits.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_rectangleAttributesPercentUnits.pdf index 0af8df146d..4beb272cf8 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_rectangleAttributesPercentUnits.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_rectangleAttributesPercentUnits.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_svgHeightPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_svgHeightPercentTest.pdf new file mode 100644 index 0000000000..f2a94a4907 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_svgHeightPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_svgViewboxWidthPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_svgViewboxWidthPercentTest.pdf new file mode 100644 index 0000000000..081a52bfd8 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_svgViewboxWidthPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_svgWidthAndHeightEmAndRemTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_svgWidthAndHeightEmAndRemTest.pdf new file mode 100644 index 0000000000..5df804c8b0 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_svgWidthAndHeightEmAndRemTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_svgWidthPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_svgWidthPercentTest.pdf new file mode 100644 index 0000000000..95176cc9f5 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_svgWidthPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolWidthAndHeightEmAndRemTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolWidthAndHeightEmAndRemTest.pdf new file mode 100644 index 0000000000..3d480f270e Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolWidthAndHeightEmAndRemTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolWidthAndHeightPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolWidthAndHeightPercentTest.pdf new file mode 100644 index 0000000000..e0d1ecc310 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolWidthAndHeightPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolXAndYEmAndRemTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolXAndYEmAndRemTest.pdf new file mode 100644 index 0000000000..75bd2fdbdd Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolXAndYEmAndRemTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolXPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolXPercentTest.pdf new file mode 100644 index 0000000000..6411025c8a Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolXPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolYPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolYPercentTest.pdf new file mode 100644 index 0000000000..077c448813 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_symbolYPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_useWidthPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_useWidthPercentTest.pdf new file mode 100644 index 0000000000..2a7b67bbf2 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_useWidthPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_useXAndYEmAndRemTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_useXAndYEmAndRemTest.pdf new file mode 100644 index 0000000000..b0a62dc66f Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_useXAndYEmAndRemTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_useXPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_useXPercentTest.pdf new file mode 100644 index 0000000000..2e83fb9c27 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_useXPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_useYPercentTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_useYPercentTest.pdf new file mode 100644 index 0000000000..7ab3460847 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_useYPercentTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_viewportFromConverterPropertiesTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_viewportFromConverterPropertiesTest.pdf new file mode 100644 index 0000000000..c255769b3a Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/cmp_viewportFromConverterPropertiesTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/diffViewBoxAndPortPercent1Test.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/diffViewBoxAndPortPercent1Test.svg new file mode 100644 index 0000000000..6012965182 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/diffViewBoxAndPortPercent1Test.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/diffViewBoxAndPortPercent2Test.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/diffViewBoxAndPortPercent2Test.svg new file mode 100644 index 0000000000..31c69793c3 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/diffViewBoxAndPortPercent2Test.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/linePercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/linePercentTest.svg new file mode 100644 index 0000000000..0bfd9583c3 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/linePercentTest.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgAllPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgAllPercentTest.svg new file mode 100644 index 0000000000..01523b19a9 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgAllPercentTest.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgHeightPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgHeightPercentTest.svg new file mode 100644 index 0000000000..700b75413d --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgHeightPercentTest.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgWidthEmTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgWidthEmTest.svg new file mode 100644 index 0000000000..431c3d1815 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgWidthEmTest.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgWidthPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgWidthPercentTest.svg new file mode 100644 index 0000000000..47de0c3a5f --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgWidthPercentTest.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgXPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgXPercentTest.svg new file mode 100644 index 0000000000..82ab30e45a --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgXPercentTest.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgYPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgYPercentTest.svg new file mode 100644 index 0000000000..3d1b3270b7 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/nestedSvgYPercentTest.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/noViewBoxAndViewPortPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/noViewBoxAndViewPortPercentTest.svg new file mode 100644 index 0000000000..378eb0275a --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/noViewBoxAndViewPortPercentTest.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/noViewBoxPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/noViewBoxPercentTest.svg new file mode 100644 index 0000000000..200900d23e --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/noViewBoxPercentTest.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/svgHeightPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/svgHeightPercentTest.svg new file mode 100644 index 0000000000..50fe9ed7a0 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/svgHeightPercentTest.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/svgViewboxWidthPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/svgViewboxWidthPercentTest.svg new file mode 100644 index 0000000000..6ed8ca1468 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/svgViewboxWidthPercentTest.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/svgWidthAndHeightEmAndRemTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/svgWidthAndHeightEmAndRemTest.svg new file mode 100644 index 0000000000..2a31507eaf --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/svgWidthAndHeightEmAndRemTest.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/svgWidthPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/svgWidthPercentTest.svg new file mode 100644 index 0000000000..7a23366afd --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/svgWidthPercentTest.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolWidthAndHeightEmAndRemTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolWidthAndHeightEmAndRemTest.svg new file mode 100644 index 0000000000..2d64137d8e --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolWidthAndHeightEmAndRemTest.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolWidthAndHeightPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolWidthAndHeightPercentTest.svg new file mode 100644 index 0000000000..c4079b4274 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolWidthAndHeightPercentTest.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolXAndYEmAndRemTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolXAndYEmAndRemTest.svg new file mode 100644 index 0000000000..df0550da30 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolXAndYEmAndRemTest.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolXPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolXPercentTest.svg new file mode 100644 index 0000000000..ccad59fbe4 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolXPercentTest.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolYPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolYPercentTest.svg new file mode 100644 index 0000000000..9096463e85 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/symbolYPercentTest.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/useWidthPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/useWidthPercentTest.svg new file mode 100644 index 0000000000..fd87741228 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/useWidthPercentTest.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/useXAndYEmAndRemTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/useXAndYEmAndRemTest.svg new file mode 100644 index 0000000000..9139e9c039 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/useXAndYEmAndRemTest.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/useXPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/useXPercentTest.svg new file mode 100644 index 0000000000..2f3fb6ca4b --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/useXPercentTest.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/useYPercentTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/useYPercentTest.svg new file mode 100644 index 0000000000..32d629241c --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/useYPercentTest.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/viewportFromConverterPropertiesTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/viewportFromConverterPropertiesTest.svg new file mode 100644 index 0000000000..6ed8ca1468 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/AttributesRelativeUnitTest/viewportFromConverterPropertiesTest.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/FontRelativeUnitTest/cmp_markerFontSizeInheritanceFromDifsTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/FontRelativeUnitTest/cmp_markerFontSizeInheritanceFromDifsTest.pdf index 1bcf284af9..d418785977 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/FontRelativeUnitTest/cmp_markerFontSizeInheritanceFromDifsTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/FontRelativeUnitTest/cmp_markerFontSizeInheritanceFromDifsTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryColor.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryColor.pdf index d95f90a8d4..3b3ad1e3b6 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryColor.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryColor.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryColorGamut.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryColorGamut.pdf index 1a7348601f..db6081c609 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryColorGamut.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryColorGamut.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryDisplayBrowser.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryDisplayBrowser.pdf index b81b1d01ee..9ca5ce762c 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryDisplayBrowser.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryDisplayBrowser.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryHeight.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryHeight.pdf index 2d6f0713f9..e1dde4db92 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryHeight.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryHeight.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMaxHeight.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMaxHeight.pdf index 3bbaa8c50c..4dec441732 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMaxHeight.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMaxHeight.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMaxWidth.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMaxWidth.pdf index 25d03e4ae2..4e588fe63e 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMaxWidth.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMaxWidth.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinColor.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinColor.pdf index 3b6006dfc7..20c1c68a2f 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinColor.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinColor.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinHeight.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinHeight.pdf index 0e6afa7424..2386e2b252 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinHeight.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinHeight.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinWidth.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinWidth.pdf index 25d03e4ae2..469c8ca8af 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinWidth.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinWidth.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinWidth2.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinWidth2.pdf index 25d03e4ae2..1c98606504 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinWidth2.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryMinWidth2.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryNot.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryNot.pdf index 17e1c5564a..785010522e 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryNot.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryNot.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOnly.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOnly.pdf index 5b86fe7298..3d87dd4567 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOnly.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOnly.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOnlyAnd.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOnlyAnd.pdf index 51acf4452f..9e317c3b7a 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOnlyAnd.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOnlyAnd.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOrientationLandscape.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOrientationLandscape.pdf index 25d03e4ae2..2b92ca2663 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOrientationLandscape.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOrientationLandscape.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOrientationPortrait.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOrientationPortrait.pdf index 25d03e4ae2..aa5a44d771 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOrientationPortrait.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryOrientationPortrait.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryPrint.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryPrint.pdf index 25ae974cbf..adc5004a64 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryPrint.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryPrint.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryRatio.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryRatio.pdf index 904951dc24..826a52c380 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryRatio.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryRatio.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryRatioSingleVal.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryRatioSingleVal.pdf index 6d988d2aac..fcd380df98 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryRatioSingleVal.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryRatioSingleVal.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryResolution.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryResolution.pdf index a622d6e329..5dab54c651 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryResolution.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryResolution.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryScreen.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryScreen.pdf index fdf6cd9544..79709bb45d 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryScreen.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryScreen.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryWidth.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryWidth.pdf index 416b868000..192f70d285 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryWidth.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/MediaTest/cmp_mediaQueryWidth.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/SvgStyleResolver/cmp_fontWeightTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/css/SvgStyleResolver/cmp_fontWeightTest.pdf index 5da5b14209..ca5ae8cccf 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/css/SvgStyleResolver/cmp_fontWeightTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/css/SvgStyleResolver/cmp_fontWeightTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/css/SvgStyleResolver/fontWeightTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/css/SvgStyleResolver/fontWeightTest.svg index 1d6950e4e6..d365a22531 100644 --- a/itext.tests/itext.svg.tests/resources/itext/svg/css/SvgStyleResolver/fontWeightTest.svg +++ b/itext.tests/itext.svg.tests/resources/itext/svg/css/SvgStyleResolver/fontWeightTest.svg @@ -7,6 +7,12 @@ font-style: normal; src: url('web-fonts/droid-serif-regular.ttf') format('truetype'); } + @font-face { + font-family: 'Droid Serif'; + font-weight: 700; + font-style: bold; + src: url('web-fonts/droid-serif-bold.ttf') format('truetype'); + } diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgFillColor.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgFillColor.pdf index 60cd77341e..4cae1a7620 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgFillColor.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgFillColor.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgFillStrokeColor.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgFillStrokeColor.pdf index d7ad7daa42..4d5c530e21 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgFillStrokeColor.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgFillStrokeColor.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgSimpleShapesColor.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgSimpleShapesColor.pdf index 831791d99e..77c9b16232 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgSimpleShapesColor.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgSimpleShapesColor.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgStrokeColor.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgStrokeColor.pdf index a7625bfe54..8783849a07 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgStrokeColor.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/cmp_svgStrokeColor.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/svgFillColor.svg b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/svgFillColor.svg index 38f825ad88..e601f08a4d 100644 --- a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/svgFillColor.svg +++ b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/DeviceCmykTest/svgFillColor.svg @@ -1,4 +1,4 @@ - + + diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/OuterZeroCoordinatesViewBox.svg b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/OuterZeroCoordinatesViewBox.svg index 1a9ebf97f7..65179b4d3b 100644 --- a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/OuterZeroCoordinatesViewBox.svg +++ b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/OuterZeroCoordinatesViewBox.svg @@ -1,4 +1,4 @@ - + diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/cmp_InnerZeroCoordinatesViewBox.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/cmp_InnerZeroCoordinatesViewBox.pdf index 34da723c2c..a84c3c8b97 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/cmp_InnerZeroCoordinatesViewBox.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/cmp_InnerZeroCoordinatesViewBox.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/cmp_MultipleViewBoxes.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/cmp_MultipleViewBoxes.pdf index fa26a4125b..38b3e1f66e 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/cmp_MultipleViewBoxes.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/cmp_MultipleViewBoxes.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/cmp_OuterZeroCoordinatesViewBox.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/cmp_OuterZeroCoordinatesViewBox.pdf index 1d8ad93c93..7906b659b7 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/cmp_OuterZeroCoordinatesViewBox.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/cmp_OuterZeroCoordinatesViewBox.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RelativePositionsTest/cmp_relativePositionsBasic2.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RelativePositionsTest/cmp_relativePositionsBasic2.pdf index ab8fec65a4..c28e544a25 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RelativePositionsTest/cmp_relativePositionsBasic2.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RelativePositionsTest/cmp_relativePositionsBasic2.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RelativePositionsTest/cmp_relativePositionsListValuesNoY.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RelativePositionsTest/cmp_relativePositionsListValuesNoY.pdf index 33be1a1c9d..c958f9ffc5 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RelativePositionsTest/cmp_relativePositionsListValuesNoY.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RelativePositionsTest/cmp_relativePositionsListValuesNoY.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentHeight.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentHeight.pdf index e674b1e7d5..4df344700f 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentHeight.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentHeight.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentWHViewboxPresent.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentWHViewboxPresent.pdf index 48495e9583..30c1d0c94b 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentWHViewboxPresent.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentWHViewboxPresent.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentWidth.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentWidth.pdf index 92f0de4f28..5c10c7cdaf 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentWidth.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentWidth.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentWidthAndHeight.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentWidthAndHeight.pdf index 0fac911e7b..30ab89307c 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentWidthAndHeight.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentWidthAndHeight.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_invalidX.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_invalidX.pdf new file mode 100644 index 0000000000..c35086e0aa Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_invalidX.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_invalidY.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_invalidY.pdf new file mode 100644 index 0000000000..627a2442b4 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_invalidY.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_bothStyleAttrTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_bothStyleAttrTest.pdf index 1ec8f58c56..5a0b6e7211 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_bothStyleAttrTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_bothStyleAttrTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_classAttrTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_classAttrTest.pdf index 1d64aa6464..5cab2b1108 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_classAttrTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_classAttrTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_displayAttrWithNoUseTagTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_displayAttrWithNoUseTagTest.pdf index 3478b85dac..f05fb5e384 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_displayAttrWithNoUseTagTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_displayAttrWithNoUseTagTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_displayNoneAttrTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_displayNoneAttrTest.pdf index 0a39a812a6..1a1dc9f7bb 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_displayNoneAttrTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_displayNoneAttrTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_heightEmTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_heightEmTest.pdf new file mode 100644 index 0000000000..44956e4456 Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_heightEmTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_heightPercentsAttrTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_heightPercentsAttrTest.pdf index 5425e71924..27c662df63 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_heightPercentsAttrTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_heightPercentsAttrTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_heightPxAttrTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_heightPxAttrTest.pdf index 2dcff2b44d..95927d494d 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_heightPxAttrTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_heightPxAttrTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_opacityAttrTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_opacityAttrTest.pdf index af57b65e5d..aa8d52d0f2 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_opacityAttrTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_opacityAttrTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_preserveAspectRatioViewBoxTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_preserveAspectRatioViewBoxTest.pdf index 7eb1469bae..ba3d3ac874 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_preserveAspectRatioViewBoxTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_preserveAspectRatioViewBoxTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_simpleSymbolTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_simpleSymbolTest.pdf index 164bccbce2..596e1be035 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_simpleSymbolTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_simpleSymbolTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_styleAttrInUseTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_styleAttrInUseTest.pdf index 0960f64f91..43e4007d6a 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_styleAttrInUseTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_styleAttrInUseTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_styleAttrTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_styleAttrTest.pdf index 924c12d39d..2f3aa56667 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_styleAttrTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_styleAttrTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useSymbolCoordinatesContrudiction.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useSymbolCoordinatesContrudiction.pdf index 72422eebed..263099d341 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useSymbolCoordinatesContrudiction.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useSymbolCoordinatesContrudiction.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useSymbolHeightWidthAllUnitsTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useSymbolHeightWidthAllUnitsTest.pdf index d0109e4bfb..276ebed879 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useSymbolHeightWidthAllUnitsTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useSymbolHeightWidthAllUnitsTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useSymbolXYContrudictionAllUnitsTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useSymbolXYContrudictionAllUnitsTest.pdf index c471f77419..10147655d8 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useSymbolXYContrudictionAllUnitsTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useSymbolXYContrudictionAllUnitsTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useTagFirstSymbolAfterTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useTagFirstSymbolAfterTest.pdf index 0226362616..ca503ce979 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useTagFirstSymbolAfterTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_useTagFirstSymbolAfterTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_visibilityAttrTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_visibilityAttrTest.pdf index 595f29fcf3..729c07c39b 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_visibilityAttrTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_visibilityAttrTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_widthHeightAttrPercentsPxTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_widthHeightAttrPercentsPxTest.pdf index 34309ea35a..82826e2bc4 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_widthHeightAttrPercentsPxTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_widthHeightAttrPercentsPxTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_widthPercentsAttrTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_widthPercentsAttrTest.pdf index c51d1c021d..08e6c65c5c 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_widthPercentsAttrTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_widthPercentsAttrTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_widthPxAttrTest.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_widthPxAttrTest.pdf index acf5deb765..b10b2b9ca6 100644 Binary files a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_widthPxAttrTest.pdf and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/cmp_widthPxAttrTest.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/heightEmTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/heightEmTest.svg new file mode 100644 index 0000000000..63d672f5cb --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/heightEmTest.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/heightPercentsAttrTest.svg b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/heightPercentsAttrTest.svg index 7595e9e81d..c393746363 100644 --- a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/heightPercentsAttrTest.svg +++ b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/SymbolTest/heightPercentsAttrTest.svg @@ -1,8 +1,8 @@ - - + - + \ No newline at end of file diff --git a/itext/itext.sign/itext.sign.csproj b/itext/itext.sign/itext.sign.csproj index b1f45cc7a4..04f2dee329 100644 --- a/itext/itext.sign/itext.sign.csproj +++ b/itext/itext.sign/itext.sign.csproj @@ -26,7 +26,8 @@ - + + 1701;1702;1591;1570;1572;1573;1574;1580;1584;1658 diff --git a/itext/itext.sign/itext/signatures/IOcspClientBouncyCastle.cs b/itext/itext.sign/itext/signatures/IOcspClientBouncyCastle.cs new file mode 100644 index 0000000000..7cd08ddc08 --- /dev/null +++ b/itext/itext.sign/itext/signatures/IOcspClientBouncyCastle.cs @@ -0,0 +1,54 @@ +/* +This file is part of the iText (R) project. +Copyright (c) 1998-2024 Apryse Group NV +Authors: Apryse Software. + +This program is offered under a commercial and under the AGPL license. +For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + +AGPL licensing: +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ +using System; +using iText.Commons.Bouncycastle.Asn1.Ocsp; +using iText.Commons.Bouncycastle.Cert; + +namespace iText.Signatures { + /// Interface for the Online Certificate Status Protocol (OCSP) Client. + /// + /// Interface for the Online Certificate Status Protocol (OCSP) Client. + /// With a method returning parsed IBasicOCSPResp instead of encoded response. + /// + public interface IOcspClientBouncyCastle : IOcspClient { + /// Gets OCSP response. + /// + /// Gets OCSP response. + /// + /// If required, + /// + /// can be checked using + /// + /// class. + /// + /// the certificate to check + /// parent certificate + /// to get the verification + /// + /// + /// + /// an OCSP response wrapper + /// + IBasicOcspResponse GetBasicOCSPResp(IX509Certificate checkCert, IX509Certificate rootCert, String url); + } +} diff --git a/itext/itext.sign/itext/signatures/IssuingCertificateRetriever.cs b/itext/itext.sign/itext/signatures/IssuingCertificateRetriever.cs index 8d58e41bbc..418d392260 100644 --- a/itext/itext.sign/itext/signatures/IssuingCertificateRetriever.cs +++ b/itext/itext.sign/itext/signatures/IssuingCertificateRetriever.cs @@ -33,6 +33,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Commons.Utils.Collections; using iText.Signatures.Logs; using iText.Signatures.Validation; +using iText.StyledXmlParser.Resolver.Resource; namespace iText.Signatures { /// @@ -50,15 +51,30 @@ public class IssuingCertificateRetriever : IIssuingCertificateRetriever { private readonly IDictionary> knownCertificates = new Dictionary>(); + private readonly IResourceRetriever resourceRetriever; + /// /// Creates /// /// instance. /// public IssuingCertificateRetriever() { + this.resourceRetriever = new DefaultResourceRetriever(); + } + + /// + /// Creates + /// + /// instance. + /// + /// + /// an @{link IResourceRetriever} instance to use for performing http + /// requests. + /// + public IssuingCertificateRetriever(IResourceRetriever resourceRetriever) { + this.resourceRetriever = resourceRetriever; } - // Empty constructor. /// /// /// @@ -389,7 +405,7 @@ public virtual bool IsCertificateTrusted(IX509Certificate certificate) { /// . /// protected internal virtual Stream GetIssuerCertByURI(String uri) { - return SignUtils.GetHttpResponse(new Uri(uri)); + return resourceRetriever.GetInputStreamByUrl(new Uri(uri)); } /// Parses certificates represented as byte array. diff --git a/itext/itext.sign/itext/signatures/OcspClientBouncyCastle.cs b/itext/itext.sign/itext/signatures/OcspClientBouncyCastle.cs index d488045608..b3f003e26b 100644 --- a/itext/itext.sign/itext/signatures/OcspClientBouncyCastle.cs +++ b/itext/itext.sign/itext/signatures/OcspClientBouncyCastle.cs @@ -34,7 +34,7 @@ You should have received a copy of the GNU Affero General Public License namespace iText.Signatures { /// OcspClient implementation using BouncyCastle. - public class OcspClientBouncyCastle : IOcspClient { + public class OcspClientBouncyCastle : IOcspClientBouncyCastle { private static readonly IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.GetFactory (); @@ -51,24 +51,7 @@ public OcspClientBouncyCastle() { } // Empty constructor in order for default one to not be removed if another one is added. - /// Gets OCSP response. - /// - /// Gets OCSP response. - /// - /// If required, - /// - /// can be checked using - /// - /// class. - /// - /// the certificate to check - /// parent certificate - /// to get the verification - /// - /// - /// - /// an OCSP response wrapper - /// + /// public virtual IBasicOcspResponse GetBasicOCSPResp(IX509Certificate checkCert, IX509Certificate rootCert, String url) { try { diff --git a/itext/itext.sign/itext/signatures/validation/RevocationDataValidator.cs b/itext/itext.sign/itext/signatures/validation/RevocationDataValidator.cs index 11aed3377f..5be659e4c6 100644 --- a/itext/itext.sign/itext/signatures/validation/RevocationDataValidator.cs +++ b/itext/itext.sign/itext/signatures/validation/RevocationDataValidator.cs @@ -116,6 +116,8 @@ public class RevocationDataValidator { private readonly CRLValidator crlValidator; + private readonly ValidatorChainBuilder builder; + /// /// Creates new /// @@ -132,6 +134,7 @@ protected internal RevocationDataValidator(ValidatorChainBuilder builder) { this.crlValidator = builder.GetCRLValidator(); this.crlClients.AddAll(this.properties.GetCrlClients()); this.ocspClients.AddAll(this.properties.GetOcspClients()); + this.builder = builder; } /// @@ -139,6 +142,14 @@ protected internal RevocationDataValidator(ValidatorChainBuilder builder) { /// /// to be used for CRL responses receiving. /// + /// + /// Add + /// + /// to be used for CRL responses receiving. + /// These clients will be used regardless of the + /// + /// settings + /// /// /// /// @@ -158,6 +169,14 @@ public virtual iText.Signatures.Validation.RevocationDataValidator AddCrlClient( /// /// to be used for OCSP responses receiving. /// + /// + /// Add + /// + /// to be used for OCSP responses receiving. + /// These clients will be used regardless of the + /// + /// settings + /// /// /// /// @@ -388,8 +407,7 @@ private void ValidateRevocationData(ValidationReport report, ValidationContext c if (SignatureValidationProperties.OnlineFetching.ALWAYS_FETCH == onlineFetching) { foreach (IX509Certificate issuerCert in issuerCerts) { SafeCalling.OnRuntimeExceptionLog(() => { - IBasicOcspResponse basicOCSPResp = new OcspClientBouncyCastle().GetBasicOCSPResp(certificate, issuerCert, - null); + IBasicOcspResponse basicOCSPResp = builder.GetOcspClient().GetBasicOCSPResp(certificate, issuerCert, null); FillOcspResponses(ocspResponses, basicOCSPResp, DateTimeUtil.GetCurrentUtcTime(), TimeBasedContext.PRESENT ); } @@ -410,7 +428,7 @@ private void ValidateRevocationData(ValidationReport report, ValidationContext c SignatureValidationProperties.OnlineFetching onlineFetching = properties.GetRevocationOnlineFetching(context .SetValidatorContext(ValidatorContext.CRL_VALIDATOR)); if (SignatureValidationProperties.OnlineFetching.ALWAYS_FETCH == onlineFetching) { - crlResponses.AddAll(RetrieveAllCRLResponsesUsingClient(report, certificate, new CrlClientOnline())); + crlResponses.AddAll(RetrieveAllCRLResponsesUsingClient(report, certificate, builder.GetCrlClient())); } // Sort all the CRL responses available based on the most recent revocation data. return crlResponses.Sorted((o1, o2) => o2.crl.GetThisUpdate().CompareTo(o1.crl.GetThisUpdate())).ToList(); @@ -423,16 +441,15 @@ private void TryToFetchRevInfoOnline(ValidationReport report, ValidationContext .SetValidatorContext(ValidatorContext.CRL_VALIDATOR)); if (SignatureValidationProperties.OnlineFetching.FETCH_IF_NO_OTHER_DATA_AVAILABLE == crlOnlineFetching) { // Sort all the CRL responses available based on the most recent revocation data. - onlineCrlResponses.AddAll(RetrieveAllCRLResponsesUsingClient(report, certificate, new CrlClientOnline()).Sorted - ((o1, o2) => o2.crl.GetThisUpdate().CompareTo(o1.crl.GetThisUpdate())).ToList()); + onlineCrlResponses.AddAll(RetrieveAllCRLResponsesUsingClient(report, certificate, builder.GetCrlClient()). + Sorted((o1, o2) => o2.crl.GetThisUpdate().CompareTo(o1.crl.GetThisUpdate())).ToList()); } SignatureValidationProperties.OnlineFetching ocspOnlineFetching = properties.GetRevocationOnlineFetching(context .SetValidatorContext(ValidatorContext.OCSP_VALIDATOR)); if (SignatureValidationProperties.OnlineFetching.FETCH_IF_NO_OTHER_DATA_AVAILABLE == ocspOnlineFetching) { foreach (IX509Certificate issuerCert in certificateRetriever.RetrieveIssuerCertificate(certificate)) { SafeCalling.OnRuntimeExceptionLog(() => { - IBasicOcspResponse basicOCSPResp = new OcspClientBouncyCastle().GetBasicOCSPResp(certificate, issuerCert, - null); + IBasicOcspResponse basicOCSPResp = builder.GetOcspClient().GetBasicOCSPResp(certificate, issuerCert, null); IList ocspResponses = new List(); FillOcspResponses(ocspResponses, basicOCSPResp, DateTimeUtil.GetCurrentUtcTime(), TimeBasedContext.PRESENT diff --git a/itext/itext.sign/itext/signatures/validation/ValidatorChainBuilder.cs b/itext/itext.sign/itext/signatures/validation/ValidatorChainBuilder.cs index c01836f193..ff8c3cbf54 100644 --- a/itext/itext.sign/itext/signatures/validation/ValidatorChainBuilder.cs +++ b/itext/itext.sign/itext/signatures/validation/ValidatorChainBuilder.cs @@ -26,6 +26,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Kernel.Pdf; using iText.Signatures; using iText.Signatures.Validation.Report.Xml; +using iText.StyledXmlParser.Resolver.Resource; namespace iText.Signatures.Validation { /// A builder class to construct all necessary parts of a validation chain. @@ -34,7 +35,7 @@ namespace iText.Signatures.Validation { /// The builder can be reused to create multiple instances of a validator. /// public class ValidatorChainBuilder { - private SignatureValidationProperties properties; + private SignatureValidationProperties properties = new SignatureValidationProperties(); private Func certificateRetrieverFactory; @@ -46,14 +47,33 @@ public class ValidatorChainBuilder { private Func crlValidatorFactory; + private Func resourceRetrieverFactory; + private Func documentRevisionsValidatorFactory; + private Func ocspClientFactory; + + private Func crlClientFactory; + private ICollection trustedCertificates; private ICollection knownCertificates; private AdESReportAggregator adESReportAggregator = new NullAdESReportAggregator(); + /// Creates a ValidatorChainBuilder using default implementations + public ValidatorChainBuilder() { + certificateRetrieverFactory = () => BuildIssuingCertificateRetriever(); + certificateChainValidatorFactory = () => BuildCertificateChainValidator(); + revocationDataValidatorFactory = () => BuildRevocationDataValidator(); + ocspValidatorFactory = () => BuildOCSPValidator(); + crlValidatorFactory = () => BuildCRLValidator(); + resourceRetrieverFactory = () => new DefaultResourceRetriever(); + documentRevisionsValidatorFactory = () => BuildDocumentRevisionsValidator(); + ocspClientFactory = () => new OcspClientBouncyCastle(); + crlClientFactory = () => new CrlClientOnline(); + } + /// /// Create a new /// @@ -157,8 +177,8 @@ public virtual CRLValidator BuildCRLValidator() { /// /// the document revisions validator factory method to use /// the current ValidatorChainBuilder. - public virtual ValidatorChainBuilder WithDocumentRevisionsValidatorFactory(Func documentRevisionsValidatorFactory) { + public virtual iText.Signatures.Validation.ValidatorChainBuilder WithDocumentRevisionsValidatorFactory(Func + documentRevisionsValidatorFactory) { this.documentRevisionsValidatorFactory = documentRevisionsValidatorFactory; return this; } @@ -170,11 +190,25 @@ public virtual ValidatorChainBuilder WithDocumentRevisionsValidatorFactory(Func< /// /// the CRLValidatorFactory method to use /// the current ValidatorChainBuilder. - public virtual ValidatorChainBuilder WithCRLValidatorFactory(Func crlValidatorFactory) { + public virtual iText.Signatures.Validation.ValidatorChainBuilder WithCRLValidatorFactory(Func crlValidatorFactory) { this.crlValidatorFactory = crlValidatorFactory; return this; } + /// + /// Use this factory method to create instances of + /// + /// for use in the validation chain. + /// + /// the ResourceRetrieverFactory method to use. + /// the current ValidatorChainBuilder. + public virtual iText.Signatures.Validation.ValidatorChainBuilder WithResourceRetriever(Func resourceRetrieverFactory) { + this.resourceRetrieverFactory = resourceRetrieverFactory; + return this; + } + /// /// Use this factory method to create instances of /// @@ -182,7 +216,8 @@ public virtual ValidatorChainBuilder WithCRLValidatorFactory(Func /// /// the OCSPValidatorFactory method to use /// the current ValidatorChainBuilder. - public virtual ValidatorChainBuilder WithOCSPValidatorFactory(Func ocspValidatorFactory) { + public virtual iText.Signatures.Validation.ValidatorChainBuilder WithOCSPValidatorFactory(Func ocspValidatorFactory) { this.ocspValidatorFactory = ocspValidatorFactory; return this; } @@ -194,8 +229,8 @@ public virtual ValidatorChainBuilder WithOCSPValidatorFactory(Func /// the RevocationDataValidator factory method to use /// the current ValidatorChainBuilder. - public virtual ValidatorChainBuilder WithRevocationDataValidatorFactory(Func revocationDataValidatorFactory - ) { + public virtual iText.Signatures.Validation.ValidatorChainBuilder WithRevocationDataValidatorFactory(Func revocationDataValidatorFactory) { this.revocationDataValidatorFactory = revocationDataValidatorFactory; return this; } @@ -207,8 +242,8 @@ public virtual ValidatorChainBuilder WithRevocationDataValidatorFactory(Func /// the CertificateChainValidator factory method to use /// the current ValidatorChainBuilder. - public virtual ValidatorChainBuilder WithCertificateChainValidatorFactory(Func - certificateChainValidatorFactory) { + public virtual iText.Signatures.Validation.ValidatorChainBuilder WithCertificateChainValidatorFactory(Func + certificateChainValidatorFactory) { this.certificateChainValidatorFactory = certificateChainValidatorFactory; return this; } @@ -220,8 +255,8 @@ public virtual ValidatorChainBuilder WithCertificateChainValidatorFactory(Func /// the SignatureValidationProperties instance to use /// the current ValidatorChainBuilder. - public virtual ValidatorChainBuilder WithSignatureValidationProperties(SignatureValidationProperties properties - ) { + public virtual iText.Signatures.Validation.ValidatorChainBuilder WithSignatureValidationProperties(SignatureValidationProperties + properties) { this.properties = properties; return this; } @@ -233,20 +268,46 @@ public virtual ValidatorChainBuilder WithSignatureValidationProperties(Signature /// /// the IssuingCertificateRetriever factory method to use /// the current ValidatorChainBuilder. - public virtual ValidatorChainBuilder WithIssuingCertificateRetrieverFactory(Func certificateRetrieverFactory) { + public virtual iText.Signatures.Validation.ValidatorChainBuilder WithIssuingCertificateRetrieverFactory(Func + certificateRetrieverFactory) { this.certificateRetrieverFactory = certificateRetrieverFactory; return this; } + /// + /// Use this factory to create instances of + /// + /// for use in the validation chain. + /// + /// the IOcspClient factory method to use + /// the current ValidatorChainBuilder. + public virtual iText.Signatures.Validation.ValidatorChainBuilder WithOcspClient(Func ocspClientFactory) { + this.ocspClientFactory = ocspClientFactory; + return this; + } + + /// + /// Use this factory to create instances of + /// + /// for use in the validation chain. + /// + /// the ICrlClient factory method to use + /// the current ValidatorChainBuilder. + public virtual iText.Signatures.Validation.ValidatorChainBuilder WithCrlClient(Func crlClientFactory + ) { + this.crlClientFactory = crlClientFactory; + return this; + } + /// /// Adds known certificates to the /// . /// /// the list of known certificates to add /// the current ValidatorChainBuilder. - public virtual ValidatorChainBuilder WithKnownCertificates(ICollection knownCertificates - ) { + public virtual iText.Signatures.Validation.ValidatorChainBuilder WithKnownCertificates(ICollection knownCertificates) { this.knownCertificates = new List(knownCertificates); return this; } @@ -257,8 +318,8 @@ public virtual ValidatorChainBuilder WithKnownCertificates(ICollection /// the list of trusted certificates to set /// the current ValidatorChainBuilder. - public virtual ValidatorChainBuilder WithTrustedCertificates(ICollection trustedCertificates - ) { + public virtual iText.Signatures.Validation.ValidatorChainBuilder WithTrustedCertificates(ICollection trustedCertificates) { this.trustedCertificates = new List(trustedCertificates); return this; } @@ -275,7 +336,8 @@ public virtual ValidatorChainBuilder WithTrustedCertificates(ICollection /// the report aggregator to use /// the current ValidatorChainBuilder - public virtual ValidatorChainBuilder WithAdESReportAggregator(AdESReportAggregator adESReportAggregator) { + public virtual iText.Signatures.Validation.ValidatorChainBuilder WithAdESReportAggregator(AdESReportAggregator + adESReportAggregator) { this.adESReportAggregator = adESReportAggregator; return this; } @@ -291,9 +353,6 @@ public virtual ValidatorChainBuilder WithAdESReportAggregator(AdESReportAggregat /// instance. /// public virtual IssuingCertificateRetriever GetCertificateRetriever() { - if (certificateRetrieverFactory == null) { - return BuildIssuingCertificateRetriever(); - } return certificateRetrieverFactory(); } @@ -308,9 +367,6 @@ public virtual IssuingCertificateRetriever GetCertificateRetriever() { /// instance. /// public virtual SignatureValidationProperties GetProperties() { - if (properties == null) { - properties = new SignatureValidationProperties(); - } return properties; } @@ -347,9 +403,6 @@ public virtual AdESReportAggregator GetAdESReportAggregator() { /// instance. /// internal virtual DocumentRevisionsValidator GetDocumentRevisionsValidator() { - if (documentRevisionsValidatorFactory == null) { - return BuildDocumentRevisionsValidator(); - } return documentRevisionsValidatorFactory(); } //\endcond @@ -366,9 +419,6 @@ internal virtual DocumentRevisionsValidator GetDocumentRevisionsValidator() { /// instance. /// internal virtual CertificateChainValidator GetCertificateChainValidator() { - if (certificateChainValidatorFactory == null) { - return BuildCertificateChainValidator(); - } return certificateChainValidatorFactory(); } //\endcond @@ -385,13 +435,56 @@ internal virtual CertificateChainValidator GetCertificateChainValidator() { /// instance. /// internal virtual RevocationDataValidator GetRevocationDataValidator() { - if (revocationDataValidatorFactory == null) { - return BuildRevocationDataValidator(); - } return revocationDataValidatorFactory(); } //\endcond +//\cond DO_NOT_DOCUMENT + /// + /// Retrieves the explicitly added or automatically created + /// + /// instance. + /// + /// + /// the explicitly added or automatically created + /// + /// instance. + /// + internal virtual ICrlClient GetCrlClient() { + return crlClientFactory(); + } +//\endcond + +//\cond DO_NOT_DOCUMENT + /// + /// Retrieves the explicitly added or automatically created + /// + /// instance. + /// + /// + /// the explicitly added or automatically created + /// + /// instance. + /// + internal virtual IOcspClientBouncyCastle GetOcspClient() { + return ocspClientFactory(); + } +//\endcond + + /// + /// Retrieves the explicitly added or automatically created + /// + /// instance. + /// + /// + /// the explicitly added or automatically created + /// + /// instance. + /// + public virtual IResourceRetriever GetResourceRetriever() { + return resourceRetrieverFactory(); + } + //\cond DO_NOT_DOCUMENT /// /// Retrieves the explicitly added or automatically created @@ -404,9 +497,6 @@ internal virtual RevocationDataValidator GetRevocationDataValidator() { /// instance. /// internal virtual CRLValidator GetCRLValidator() { - if (crlValidatorFactory == null) { - return BuildCRLValidator(); - } return crlValidatorFactory(); } //\endcond @@ -423,15 +513,12 @@ internal virtual CRLValidator GetCRLValidator() { /// instance. /// internal virtual OCSPValidator GetOCSPValidator() { - if (ocspValidatorFactory == null) { - return BuildOCSPValidator(); - } return ocspValidatorFactory(); } //\endcond private IssuingCertificateRetriever BuildIssuingCertificateRetriever() { - IssuingCertificateRetriever result = new IssuingCertificateRetriever(); + IssuingCertificateRetriever result = new IssuingCertificateRetriever(this.resourceRetrieverFactory()); if (trustedCertificates != null) { result.SetTrustedCertificates(trustedCertificates); } diff --git a/itext/itext.svg/itext/svg/SvgConstants.cs b/itext/itext.svg/itext/svg/SvgConstants.cs index b28453db21..3f4ec00eab 100644 --- a/itext/itext.svg/itext/svg/SvgConstants.cs +++ b/itext/itext.svg/itext/svg/SvgConstants.cs @@ -612,6 +612,27 @@ public sealed class Values { /// Value representing the default aspect ratio: xmidymid. public const String DEFAULT_ASPECT_RATIO = SvgConstants.Values.XMID_YMID; + /// Default svg view port width value. + /// + /// Default svg view port width value. + /// See SVG specification. + /// + public const String DEFAULT_VIEWPORT_WIDTH = "300px"; + + /// Default svg view port height value. + /// + /// Default svg view port height value. + /// See SVG specification. + /// + public const String DEFAULT_VIEWPORT_HEIGHT = "150px"; + + /// Default width and height value. + /// + /// Default width and height value. + /// See SVG specification. + /// + public const String DEFAULT_WIDTH_AND_HEIGHT_VALUE = "100%"; + /// Value representing how to preserve the aspect ratio when dealing with images. public const String DEFER = "defer"; @@ -658,6 +679,9 @@ public sealed class Values { /// Value representing the units relation "userSpaceOnUse". public const String USER_SPACE_ON_USE = "userSpaceOnUse"; + /// The number of viewBox values. + public const int VIEWBOX_VALUES_NUMBER = 4; + /// Value representing how to align when scaling. public const String XMIN_YMIN = "xminymin"; @@ -685,16 +709,8 @@ public sealed class Values { /// Value representing how to align when scaling. public const String XMAX_YMAX = "xmaxymax"; + [Obsolete] public const String VERSION1_1 = "1.1"; - - /// Default svg view box width value. - public const String DEFAULT_VIEWBOX_WIDTH = "300px"; - - /// Default svg view box height value. - public const String DEFAULT_VIEWBOX_HEIGHT = "150px"; - - /// The number of viewBox values. - public const int VIEWBOX_VALUES_NUMBER = 4; } } } diff --git a/itext/itext.svg/itext/svg/converter/SvgConverter.cs b/itext/itext.svg/itext/svg/converter/SvgConverter.cs index 1492c2d9e3..515dc1dabd 100644 --- a/itext/itext.svg/itext/svg/converter/SvgConverter.cs +++ b/itext/itext.svg/itext/svg/converter/SvgConverter.cs @@ -31,14 +31,10 @@ You should have received a copy of the GNU Affero General Public License using iText.Kernel.Pdf.Xobject; using iText.Layout.Element; using iText.StyledXmlParser; -using iText.StyledXmlParser.Css.Resolve; -using iText.StyledXmlParser.Css.Util; using iText.StyledXmlParser.Node; using iText.StyledXmlParser.Node.Impl.Jsoup; using iText.StyledXmlParser.Resolver.Resource; -using iText.Svg; using iText.Svg.Exceptions; -using iText.Svg.Logs; using iText.Svg.Processors; using iText.Svg.Processors.Impl; using iText.Svg.Renderers; @@ -340,6 +336,9 @@ public static void DrawOnPage(Stream stream, PdfPage page, ISvgConverterProperti public static void DrawOnPage(Stream stream, PdfPage page, float x, float y, ISvgConverterProperties props ) { CheckNull(page); + if (props is SvgConverterProperties && ((SvgConverterProperties)props).GetCustomViewport() == null) { + ((SvgConverterProperties)props).SetCustomViewport(page.GetMediaBox()); + } DrawOnCanvas(stream, new PdfCanvas(page), x, y, props); } @@ -693,9 +692,9 @@ public static void CreatePdf(Stream svgStream, Stream pdfDest, ISvgConverterProp // Extract topmost dimensions CheckNull(topSvgRenderer); CheckNull(pdfDocument); - //Since svg is a single object in the document, rem = em - Rectangle wh = SvgCssUtils.ExtractWidthAndHeight(topSvgRenderer, drawContext.GetCssContext().GetRootFontSize - (), drawContext.GetCssContext().GetRootFontSize()); + // Since svg is a single object in the document, em = rem + float em = drawContext.GetCssContext().GetRootFontSize(); + Rectangle wh = SvgCssUtils.ExtractWidthAndHeight(topSvgRenderer, em, drawContext); // Adjust pagesize and create new page pdfDocument.SetDefaultPageSize(new PageSize(wh.GetWidth(), wh.GetHeight())); PdfPage page = pdfDocument.AddNewPage(); @@ -878,6 +877,9 @@ private static PdfFormXObject ConvertToXObject(ISvgProcessorResult processorResu if (processorResult is SvgProcessorResult) { drawContext.SetCssContext(((SvgProcessorResult)processorResult).GetContext().GetCssContext()); } + if (props is SvgConverterProperties) { + drawContext.SetCustomViewport(((SvgConverterProperties)props).GetCustomViewport()); + } drawContext.SetTempFonts(processorResult.GetTempFonts()); drawContext.AddNamedObjects(processorResult.GetNamedObjects()); return ConvertToXObject(processorResult.GetRootRenderer(), document, drawContext); @@ -1143,11 +1145,9 @@ private static PdfFormXObject ConvertToXObject(ISvgNodeRenderer topSvgRenderer, CheckNull(topSvgRenderer); CheckNull(document); CheckNull(context); - //Can't determine em value here, so passing default value - float defaultFontSize = CssDimensionParsingUtils.ParseAbsoluteFontSize(CssDefaults.GetDefaultValue(SvgConstants.Attributes - .FONT_SIZE)); - Rectangle bbox = SvgCssUtils.ExtractWidthAndHeight(topSvgRenderer, defaultFontSize, context.GetCssContext( - ).GetRootFontSize()); + // Can't determine em value here, so em=rem + float em = context.GetCssContext().GetRootFontSize(); + Rectangle bbox = SvgCssUtils.ExtractWidthAndHeight(topSvgRenderer, em, context); PdfFormXObject pdfForm = new PdfFormXObject(bbox); PdfCanvas canvas = new PdfCanvas(pdfForm, document); context.PushCanvas(canvas); @@ -1317,7 +1317,7 @@ public static INode Parse(Stream stream, ISvgConverterProperties props) { /// to browser default if viewbox is missing as well /// /// Deprecated in favour of - /// /// /// @@ -1329,45 +1329,10 @@ public static INode Parse(Stream stream, ISvgConverterProperties props) { /// float[2], width is in position 0, height in position 1 [Obsolete] public static float[] ExtractWidthAndHeight(ISvgNodeRenderer topSvgRenderer) { - float[] res = new float[2]; - float[] values = SvgCssUtils.ParseViewBox(topSvgRenderer); - float width; - float height; - String wString; - String hString; - wString = topSvgRenderer.GetAttribute(SvgConstants.Attributes.WIDTH); - if (wString == null) { - if (values != null) { - width = values[2]; - } - else { - //Log Warning - LOGGER.LogWarning(SvgLogMessageConstant.MISSING_WIDTH); - //Set to browser default - width = CssDimensionParsingUtils.ParseAbsoluteLength(SvgConstants.Values.DEFAULT_VIEWBOX_WIDTH); - } - } - else { - width = CssDimensionParsingUtils.ParseAbsoluteLength(wString); - } - hString = topSvgRenderer.GetAttribute(SvgConstants.Attributes.HEIGHT); - if (hString == null) { - if (values != null) { - height = values[3]; - } - else { - //Log Warning - LOGGER.LogWarning(SvgLogMessageConstant.MISSING_HEIGHT); - //Set to browser default - height = CssDimensionParsingUtils.ParseAbsoluteLength(SvgConstants.Values.DEFAULT_VIEWBOX_HEIGHT); - } - } - else { - height = CssDimensionParsingUtils.ParseAbsoluteLength(hString); - } - res[0] = width; - res[1] = height; - return res; + SvgDrawContext context = new SvgDrawContext(null, null); + float em = context.GetCssContext().GetRootFontSize(); + Rectangle rectangle = SvgCssUtils.ExtractWidthAndHeight(topSvgRenderer, em, context); + return new float[] { rectangle.GetX(), rectangle.GetY(), rectangle.GetWidth(), rectangle.GetHeight() }; } //\cond DO_NOT_DOCUMENT diff --git a/itext/itext.svg/itext/svg/css/SvgCssContext.cs b/itext/itext.svg/itext/svg/css/SvgCssContext.cs index 1e4c63eb4e..30f6f0cb03 100644 --- a/itext/itext.svg/itext/svg/css/SvgCssContext.cs +++ b/itext/itext.svg/itext/svg/css/SvgCssContext.cs @@ -23,7 +23,7 @@ You should have received a copy of the GNU Affero General Public License using System; using iText.StyledXmlParser.Css.Resolve; using iText.StyledXmlParser.Css.Util; -using iText.Svg; +using iText.Svg.Css.Impl; namespace iText.Svg.Css { /// @@ -32,8 +32,7 @@ namespace iText.Svg.Css { /// public class SvgCssContext : AbstractCssContext { /// The root font size value in pt. - private float rootFontSize = CssDimensionParsingUtils.ParseAbsoluteFontSize(CssDefaults.GetDefaultValue(SvgConstants.Attributes - .FONT_SIZE)); + private float rootFontSize = SvgStyleResolver.DEFAULT_FONT_SIZE; /// Gets the root font size. /// the root font size in pt diff --git a/itext/itext.svg/itext/svg/css/impl/SvgStyleResolver.cs b/itext/itext.svg/itext/svg/css/impl/SvgStyleResolver.cs index d8e996a5af..c31499d46f 100644 --- a/itext/itext.svg/itext/svg/css/impl/SvgStyleResolver.cs +++ b/itext/itext.svg/itext/svg/css/impl/SvgStyleResolver.cs @@ -49,14 +49,14 @@ public class SvgStyleResolver : ICssResolver { (new HashSet(JavaUtil.ArraysAsList((IStyleInheritance)new CssInheritance(), (IStyleInheritance )new SvgAttributeInheritance()))); + public static readonly float DEFAULT_FONT_SIZE = CssDimensionParsingUtils.ParseAbsoluteFontSize(CssDefaults + .GetDefaultValue(SvgConstants.Attributes.FONT_SIZE)); + // TODO: DEVSIX-3923 remove normalization (.toLowerCase) private static readonly String[] ELEMENTS_INHERITING_PARENT_STYLES = new String[] { SvgConstants.Tags.MARKER , SvgConstants.Tags.LINEAR_GRADIENT, SvgConstants.Tags.LINEAR_GRADIENT.ToLowerInvariant(), SvgConstants.Tags .PATTERN }; - private static readonly float DEFAULT_FONT_SIZE = CssDimensionParsingUtils.ParseAbsoluteFontSize(CssDefaults - .GetDefaultValue(SvgConstants.Attributes.FONT_SIZE)); - private static readonly ILogger LOGGER = ITextLogManager.GetLogger(typeof(iText.Svg.Css.Impl.SvgStyleResolver )); @@ -144,8 +144,7 @@ public static void ResolveFontSizeStyle(IDictionary styles, SvgC } else { if (parentFontSizeStr == null) { - baseFontSize = CssDimensionParsingUtils.ParseAbsoluteFontSize(CssDefaults.GetDefaultValue(SvgConstants.Attributes - .FONT_SIZE)); + baseFontSize = DEFAULT_FONT_SIZE; } else { baseFontSize = CssDimensionParsingUtils.ParseAbsoluteLength(parentFontSizeStr); diff --git a/itext/itext.svg/itext/svg/logs/SvgLogMessageConstant.cs b/itext/itext.svg/itext/svg/logs/SvgLogMessageConstant.cs index 500b6ec6a0..366e1eac06 100644 --- a/itext/itext.svg/itext/svg/logs/SvgLogMessageConstant.cs +++ b/itext/itext.svg/itext/svg/logs/SvgLogMessageConstant.cs @@ -49,9 +49,13 @@ public sealed class SvgLogMessageConstant { public const String PATTERN_WIDTH_OR_HEIGHT_IS_NEGATIVE = "Pattern width or height is negative value. This pattern will not be rendered."; + /// The constant not used anymore and will be removed in the next major release. + [Obsolete] public const String MISSING_WIDTH = "Top Svg tag has no defined width attribute and viewbox width is not present, so browser default of 300px " + "is used"; + /// The constant not used anymore and will be removed in the next major release. + [Obsolete] public const String MISSING_HEIGHT = "Top Svg tag has no defined height attribute and viewbox height is not present, so browser default of " + "150px is used"; diff --git a/itext/itext.svg/itext/svg/processors/impl/SvgConverterProperties.cs b/itext/itext.svg/itext/svg/processors/impl/SvgConverterProperties.cs index cab6724e0b..fb464250c1 100644 --- a/itext/itext.svg/itext/svg/processors/impl/SvgConverterProperties.cs +++ b/itext/itext.svg/itext/svg/processors/impl/SvgConverterProperties.cs @@ -21,6 +21,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ using System; +using iText.Kernel.Geom; using iText.Layout.Font; using iText.StyledXmlParser.Css; using iText.StyledXmlParser.Css.Media; @@ -54,6 +55,8 @@ public class SvgConverterProperties : ISvgConverterProperties { private CssStyleSheet cssStyleSheet = null; + private Rectangle customViewport = null; + /// /// Creates a new /// @@ -70,6 +73,29 @@ public SvgConverterProperties() { this.rendererFactory = new DefaultSvgNodeRendererFactory(); } + /// Gets the custom viewport of SVG. + /// + /// Gets the custom viewport of SVG. + /// + /// The custom viewport is used to resolve percent values of the top level svg. + /// + /// the custom viewport + public virtual Rectangle GetCustomViewport() { + // TODO DEVSIX-8808 add this getter to the interface ISvgConverterProperties and remove class casting where getCustomViewport is called + return customViewport; + } + + /// Sets the custom viewport of SVG. + /// + /// Sets the custom viewport of SVG. + /// + /// The custom viewport is used to resolve percent values of the top level svg. + /// + /// the custom viewport + public virtual void SetCustomViewport(Rectangle customViewport) { + this.customViewport = customViewport; + } + public virtual iText.Svg.Processors.Impl.SvgConverterProperties SetRendererFactory(ISvgNodeRendererFactory rendererFactory) { this.rendererFactory = rendererFactory; diff --git a/itext/itext.svg/itext/svg/renderers/SvgDrawContext.cs b/itext/itext.svg/itext/svg/renderers/SvgDrawContext.cs index 04c2779369..6f813ed135 100644 --- a/itext/itext.svg/itext/svg/renderers/SvgDrawContext.cs +++ b/itext/itext.svg/itext/svg/renderers/SvgDrawContext.cs @@ -66,6 +66,8 @@ public class SvgDrawContext { private float[] relativePosition; + private Rectangle customViewport; + /// Create an instance of the context that is used to store information when converting SVG. /// /// instance of @@ -87,6 +89,28 @@ public SvgDrawContext(ResourceResolver resourceResolver, FontProvider fontProvid cssContext = new SvgCssContext(); } + /// Gets the custom viewport of SVG. + /// + /// Gets the custom viewport of SVG. + /// + /// The custom viewport is used to resolve percent values of the top level svg. + /// + /// the custom viewport + public virtual Rectangle GetCustomViewport() { + return customViewport; + } + + /// Sets the custom viewport of SVG. + /// + /// Sets the custom viewport of SVG. + /// + /// The custom viewport is used to resolve percent values of the top level svg. + /// + /// the custom viewport + public virtual void SetCustomViewport(Rectangle customViewport) { + this.customViewport = customViewport; + } + /// Retrieves the current top of the stack, without modifying the stack. /// the current canvas that can be used for drawing operations. public virtual PdfCanvas GetCurrentCanvas() { diff --git a/itext/itext.svg/itext/svg/renderers/SvgImageRenderer.cs b/itext/itext.svg/itext/svg/renderers/SvgImageRenderer.cs index eec8b7a16e..8e0b0c2e2b 100644 --- a/itext/itext.svg/itext/svg/renderers/SvgImageRenderer.cs +++ b/itext/itext.svg/itext/svg/renderers/SvgImageRenderer.cs @@ -45,9 +45,5 @@ public override void Draw(DrawContext drawContext) { ((SvgImage)modelElement).Generate(drawContext.GetDocument()); base.Draw(drawContext); } - //TODO: DEVSIX-8775 probably we need to override ImageRenderer#calculateImageDimensions and calcualte percent - // values of svg width and height there by altering layoutBox or affine transform, this is needed to correctly - // calculate percent values in root svg element. Though this won't help with svg's loaded as background image in - // html2pdf, so this has to be carefully investigated } } diff --git a/itext/itext.svg/itext/svg/renderers/impl/AbstractContainerSvgNodeRenderer.cs b/itext/itext.svg/itext/svg/renderers/impl/AbstractContainerSvgNodeRenderer.cs index abf35ca314..2deb87ed58 100644 --- a/itext/itext.svg/itext/svg/renderers/impl/AbstractContainerSvgNodeRenderer.cs +++ b/itext/itext.svg/itext/svg/renderers/impl/AbstractContainerSvgNodeRenderer.cs @@ -20,10 +20,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ +using System; using iText.Kernel.Geom; -using iText.StyledXmlParser.Css.Util; using iText.Svg; using iText.Svg.Renderers; +using iText.Svg.Utils; namespace iText.Svg.Renderers.Impl { public abstract class AbstractContainerSvgNodeRenderer : AbstractBranchSvgNodeRenderer { @@ -45,33 +46,34 @@ protected internal override void DoDraw(SvgDrawContext context) { /// the SVG draw context /// the viewport that applies to this renderer internal virtual Rectangle CalculateViewPort(SvgDrawContext context) { - //TODO: DEVSIX-8775 the logic below should be refactored, first of all it shouldn't be applied to root svg tag - // (though depending on implementation maybe it won't be a problem), also it need to be adjusted to support em/rem - // which seems possible for all cases, and as for percents, I'm not sure it's possible for nested svg tags, but - // it should be possible for symbols - Rectangle currentViewPort = context.GetCurrentViewPort(); - // Set default values to parent viewport in the case of a nested svg tag + Rectangle percentBaseBox; + if (GetParent() is PdfRootSvgNodeRenderer || !(GetParent() is AbstractSvgNodeRenderer)) { + // If the current container is a top level SVG, take a current view port as a percent base + percentBaseBox = context.GetCurrentViewPort(); + } + else { + // If the current container is nested container, take a view box as a percent base + percentBaseBox = ((AbstractSvgNodeRenderer)GetParent()).GetCurrentViewBox(context); + } float portX = 0; float portY = 0; - // Default should be parent portWidth if not outermost - float portWidth = currentViewPort.GetWidth(); - // Default should be parent height if not outermost - float portHeight = currentViewPort.GetHeight(); + float portWidth = percentBaseBox.GetWidth(); + float portHeight = percentBaseBox.GetHeight(); if (attributesAndStyles != null) { - if (attributesAndStyles.ContainsKey(SvgConstants.Attributes.X)) { - portX = CssDimensionParsingUtils.ParseAbsoluteLength(attributesAndStyles.Get(SvgConstants.Attributes.X)); - } - if (attributesAndStyles.ContainsKey(SvgConstants.Attributes.Y)) { - portY = CssDimensionParsingUtils.ParseAbsoluteLength(attributesAndStyles.Get(SvgConstants.Attributes.Y)); - } - if (attributesAndStyles.ContainsKey(SvgConstants.Attributes.WIDTH)) { - portWidth = CssDimensionParsingUtils.ParseAbsoluteLength(attributesAndStyles.Get(SvgConstants.Attributes.WIDTH - )); - } - if (attributesAndStyles.ContainsKey(SvgConstants.Attributes.HEIGHT)) { - portHeight = CssDimensionParsingUtils.ParseAbsoluteLength(attributesAndStyles.Get(SvgConstants.Attributes. - HEIGHT)); - } + portX = SvgCssUtils.ParseAbsoluteLength(this, attributesAndStyles.Get(SvgConstants.Attributes.X), percentBaseBox + .GetWidth(), 0, context); + portY = SvgCssUtils.ParseAbsoluteLength(this, attributesAndStyles.Get(SvgConstants.Attributes.Y), percentBaseBox + .GetHeight(), 0, context); + String widthStr = attributesAndStyles.Get(SvgConstants.Attributes.WIDTH); + // In case widthStr==null, according to SVG spec default value is 100%, it is why default + // value is percentBaseBox.getWidth(). See SvgConstants.Values.DEFAULT_WIDTH_AND_HEIGHT_VALUE + portWidth = SvgCssUtils.ParseAbsoluteLength(this, widthStr, percentBaseBox.GetWidth(), percentBaseBox.GetWidth + (), context); + String heightStr = attributesAndStyles.Get(SvgConstants.Attributes.HEIGHT); + // In case heightStr==null, according to SVG spec default value is 100%, it is why default + // value is percentBaseBox.getHeight(). See SvgConstants.Values.DEFAULT_WIDTH_AND_HEIGHT_VALUE + portHeight = SvgCssUtils.ParseAbsoluteLength(this, heightStr, percentBaseBox.GetHeight(), percentBaseBox.GetHeight + (), context); } return new Rectangle(portX, portY, portWidth, portHeight); } diff --git a/itext/itext.svg/itext/svg/renderers/impl/AbstractSvgNodeRenderer.cs b/itext/itext.svg/itext/svg/renderers/impl/AbstractSvgNodeRenderer.cs index a4902d92e0..af40379049 100644 --- a/itext/itext.svg/itext/svg/renderers/impl/AbstractSvgNodeRenderer.cs +++ b/itext/itext.svg/itext/svg/renderers/impl/AbstractSvgNodeRenderer.cs @@ -187,14 +187,50 @@ public virtual float GetCurrentFontSize(SvgDrawContext context) { return CssDimensionParsingUtils.ParseRelativeValue(fontSizeAttribute, context.GetCssContext().GetRootFontSize ()); } - if (CssTypesValidationUtils.IsEmValue(fontSizeAttribute) && GetParent() != null && parent is AbstractSvgNodeRenderer + if (CssTypesValidationUtils.IsEmValue(fontSizeAttribute) && GetParent() != null && GetParent() is AbstractSvgNodeRenderer ) { - return CssDimensionParsingUtils.ParseRelativeValue(fontSizeAttribute, ((AbstractSvgNodeRenderer)parent).GetCurrentFontSize - (context)); + return CssDimensionParsingUtils.ParseRelativeValue(fontSizeAttribute, ((AbstractSvgNodeRenderer)GetParent( + )).GetCurrentFontSize(context)); } return CssDimensionParsingUtils.ParseAbsoluteFontSize(fontSizeAttribute); } + /// Gets the viewbox from the first parent element which can define it. + /// + /// Gets the viewbox from the first parent element which can define it. + /// + /// See SVG specification + /// to find which elements can define a viewbox. + /// + /// draw context from which fallback viewbox can be extracted + /// + /// the viewbox or + /// + /// if the element doesn't have parent which can define the viewbox + /// + public virtual Rectangle GetCurrentViewBox(SvgDrawContext context) { + // According to https://svgwg.org/svg2-draft/coords.html#EstablishingANewSVGViewport: "For historical reasons, + // the ‘pattern’ and ‘marker’ elements do not create a new viewport, despite accepting a ‘viewBox’ attribute". + // So get viewbox only from symbol and svg elements + if (this is AbstractContainerSvgNodeRenderer) { + float[] viewBoxValues = SvgCssUtils.ParseViewBox(this); + if (viewBoxValues == null || viewBoxValues.Length < SvgConstants.Values.VIEWBOX_VALUES_NUMBER) { + Rectangle currentViewPort = context.GetCurrentViewPort(); + viewBoxValues = new float[] { 0, 0, currentViewPort.GetWidth(), currentViewPort.GetHeight() }; + } + return new Rectangle(viewBoxValues[0], viewBoxValues[1], viewBoxValues[2], viewBoxValues[3]); + } + else { + if (GetParent() is AbstractSvgNodeRenderer) { + return ((AbstractSvgNodeRenderer)GetParent()).GetCurrentViewBox(context); + } + else { + // From iText this line isn't reachable, in custom renderer tree fallback to context's view port + return context.GetCurrentViewPort(); + } + } + } + /// /// Make a deep copy of the styles and attributes of this renderer /// Helper method for deep copying logic @@ -377,8 +413,7 @@ internal virtual void ApplyFillAndStrokeProperties(AbstractSvgNodeRenderer.FillP /// /// absolute length in points protected internal virtual float ParseHorizontalLength(String length, SvgDrawContext context) { - return SvgCssUtils.ParseAbsoluteLength(this, length, SvgCoordinateUtils.CalculatePercentBaseValueIfNeeded( - context, length, true), 0.0F, context); + return SvgCssUtils.ParseAbsoluteHorizontalLength(this, length, 0.0F, context); } /// Parse y-axis length value. @@ -409,8 +444,7 @@ protected internal virtual float ParseHorizontalLength(String length, SvgDrawCon /// /// absolute length in points protected internal virtual float ParseVerticalLength(String length, SvgDrawContext context) { - return SvgCssUtils.ParseAbsoluteLength(this, length, SvgCoordinateUtils.CalculatePercentBaseValueIfNeeded( - context, length, false), 0.0F, context); + return SvgCssUtils.ParseAbsoluteVerticalLength(this, length, 0.0F, context); } /// Parse length attributes. @@ -458,6 +492,9 @@ private TransparentColor GetColorFromAttributeValue(SvgDrawContext context, Stri String normalizedName = tokenValue.JSubstring(5, tokenValue.Length - 1).Trim(); ISvgNodeRenderer colorRenderer = context.GetNamedObject(normalizedName); if (colorRenderer is ISvgPaintServer) { + if (colorRenderer.GetParent() == null) { + colorRenderer.SetParent(this); + } resolvedColor = ((ISvgPaintServer)colorRenderer).CreateColor(context, GetObjectBoundingBox(context), objectBoundingBoxMargin , parentOpacity); } diff --git a/itext/itext.svg/itext/svg/renderers/impl/LinearGradientSvgNodeRenderer.cs b/itext/itext.svg/itext/svg/renderers/impl/LinearGradientSvgNodeRenderer.cs index b3ed79518c..5c227c2648 100644 --- a/itext/itext.svg/itext/svg/renderers/impl/LinearGradientSvgNodeRenderer.cs +++ b/itext/itext.svg/itext/svg/renderers/impl/LinearGradientSvgNodeRenderer.cs @@ -131,7 +131,7 @@ private Point[] GetCoordinates(SvgDrawContext context, bool isObjectBoundingBox) .Y2), 0) * CONVERT_COEFF); } else { - Rectangle currentViewPort = context.GetCurrentViewPort(); + Rectangle currentViewPort = this.GetCurrentViewBox(context); double x = currentViewPort.GetX(); double y = currentViewPort.GetY(); double width = currentViewPort.GetWidth(); diff --git a/itext/itext.svg/itext/svg/renderers/impl/PatternSvgNodeRenderer.cs b/itext/itext.svg/itext/svg/renderers/impl/PatternSvgNodeRenderer.cs index ec3c7fefb6..99eb6c6f34 100644 --- a/itext/itext.svg/itext/svg/renderers/impl/PatternSvgNodeRenderer.cs +++ b/itext/itext.svg/itext/svg/renderers/impl/PatternSvgNodeRenderer.cs @@ -185,7 +185,7 @@ private Rectangle CalculateOriginalPatternRectangle(SvgDrawContext context, bool 0) * CONVERT_COEFF; } else { - Rectangle currentViewPort = context.GetCurrentViewPort(); + Rectangle currentViewPort = this.GetCurrentViewBox(context); double viewPortX = currentViewPort.GetX(); double viewPortY = currentViewPort.GetY(); double viewPortWidth = currentViewPort.GetWidth(); diff --git a/itext/itext.svg/itext/svg/renderers/impl/UseSvgNodeRenderer.cs b/itext/itext.svg/itext/svg/renderers/impl/UseSvgNodeRenderer.cs index 0f59ebbb86..458ade6753 100644 --- a/itext/itext.svg/itext/svg/renderers/impl/UseSvgNodeRenderer.cs +++ b/itext/itext.svg/itext/svg/renderers/impl/UseSvgNodeRenderer.cs @@ -57,12 +57,9 @@ protected internal override void DoDraw(SvgDrawContext context) { PdfCanvas currentCanvas = context.GetCurrentCanvas(); float x = 0f; float y = 0f; - if (this.attributesAndStyles.ContainsKey(SvgConstants.Attributes.X)) { - x = CssDimensionParsingUtils.ParseAbsoluteLength(this.attributesAndStyles.Get(SvgConstants.Attributes.X)); - } - if (this.attributesAndStyles.ContainsKey(SvgConstants.Attributes.Y)) { - y = CssDimensionParsingUtils.ParseAbsoluteLength(this.attributesAndStyles.Get(SvgConstants.Attributes.Y)); - } + // If X or Y attribute is null, then default 0 value will be returned + x = ParseHorizontalLength(this.attributesAndStyles.Get(SvgConstants.Attributes.X), context); + y = ParseVerticalLength(this.attributesAndStyles.Get(SvgConstants.Attributes.Y), context); AffineTransform inverseMatrix = null; if (!CssUtils.CompareFloats(x, 0) || !CssUtils.CompareFloats(y, 0)) { AffineTransform translation = AffineTransform.GetTranslateInstance(x, y); diff --git a/itext/itext.svg/itext/svg/renderers/path/impl/AbstractPathShape.cs b/itext/itext.svg/itext/svg/renderers/path/impl/AbstractPathShape.cs index fae70080d4..7877a8d0ea 100644 --- a/itext/itext.svg/itext/svg/renderers/path/impl/AbstractPathShape.cs +++ b/itext/itext.svg/itext/svg/renderers/path/impl/AbstractPathShape.cs @@ -117,8 +117,7 @@ public virtual void SetContext(SvgDrawContext context) { /// /// absolute length in points protected internal virtual float ParseHorizontalLength(String length) { - return SvgCssUtils.ParseAbsoluteLength(parent, length, SvgCoordinateUtils.CalculatePercentBaseValueIfNeeded - (context, length, true), 0.0F, context); + return SvgCssUtils.ParseAbsoluteHorizontalLength(parent, length, 0.0F, context); } /// Parse y axis length value. @@ -129,8 +128,7 @@ protected internal virtual float ParseHorizontalLength(String length) { /// /// absolute length in points protected internal virtual float ParseVerticalLength(String length) { - return SvgCssUtils.ParseAbsoluteLength(parent, length, SvgCoordinateUtils.CalculatePercentBaseValueIfNeeded - (context, length, false), 0.0F, context); + return SvgCssUtils.ParseAbsoluteVerticalLength(parent, length, 0.0F, context); } public abstract void SetCoordinates(String[] arg1, Point arg2); diff --git a/itext/itext.svg/itext/svg/utils/SvgCoordinateUtils.cs b/itext/itext.svg/itext/svg/utils/SvgCoordinateUtils.cs index 9c47ded7b6..6ece1ffdfb 100644 --- a/itext/itext.svg/itext/svg/utils/SvgCoordinateUtils.cs +++ b/itext/itext.svg/itext/svg/utils/SvgCoordinateUtils.cs @@ -136,28 +136,6 @@ public static float CalculateNormalizedDiagonalLength(SvgDrawContext context) { return (float)(Math.Sqrt(viewPortHeight * viewPortHeight + viewPortWidth * viewPortWidth) / Math.Sqrt(2)); } - /// Calculate percent base value if provided length is percent value. - /// svg draw context. - /// length to check - /// - /// if - /// - /// viewport's width will be used (x-axis), otherwise viewport's height will be - /// used (y-axis) - /// - /// percent base value if provided length is percent value, 0.0F otherwise - public static float CalculatePercentBaseValueIfNeeded(SvgDrawContext context, String length, bool isXAxis) { - float percentBaseValue = 0.0F; - if (CssTypesValidationUtils.IsPercentageValue(length)) { - if (context.GetCurrentViewPort() == null) { - throw new SvgProcessingException(SvgExceptionMessageConstant.ILLEGAL_RELATIVE_VALUE_NO_VIEWPORT_IS_SET); - } - percentBaseValue = isXAxis ? context.GetCurrentViewPort().GetWidth() : context.GetCurrentViewPort().GetHeight - (); - } - return percentBaseValue; - } - /// Returns the viewBox received after scaling and displacement given preserveAspectRatio. /// /// parsed viewBox rectangle. It should be a valid diff --git a/itext/itext.svg/itext/svg/utils/SvgCssUtils.cs b/itext/itext.svg/itext/svg/utils/SvgCssUtils.cs index 73d3e297a9..dcc0b62e3b 100644 --- a/itext/itext.svg/itext/svg/utils/SvgCssUtils.cs +++ b/itext/itext.svg/itext/svg/utils/SvgCssUtils.cs @@ -28,6 +28,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Kernel.Geom; using iText.StyledXmlParser.Css.Util; using iText.Svg; +using iText.Svg.Exceptions; using iText.Svg.Logs; using iText.Svg.Renderers; using iText.Svg.Renderers.Impl; @@ -97,6 +98,44 @@ public static float ParseAbsoluteLength(AbstractSvgNodeRenderer svgNodeRenderer, return CssDimensionParsingUtils.ParseLength(length, percentBaseValue, defaultValue, em, rem); } + /// Parses vertical length attribute and converts it to an absolute value. + /// renderer for which length should be parsed + /// + /// + /// + /// for parsing + /// + /// default value if length is not recognized + /// + /// current + /// + /// + /// absolute value in points + public static float ParseAbsoluteVerticalLength(AbstractSvgNodeRenderer svgNodeRenderer, String length, float + defaultValue, SvgDrawContext context) { + float percentBaseValue = CalculatePercentBaseValueIfNeeded(svgNodeRenderer, context, length, false); + return ParseAbsoluteLength(svgNodeRenderer, length, percentBaseValue, defaultValue, context); + } + + /// Parses horizontal length attribute and converts it to an absolute value. + /// renderer for which length should be parsed + /// + /// + /// + /// for parsing + /// + /// default value if length is not recognized + /// + /// current + /// + /// + /// absolute value in points + public static float ParseAbsoluteHorizontalLength(AbstractSvgNodeRenderer svgNodeRenderer, String length, + float defaultValue, SvgDrawContext context) { + float percentBaseValue = CalculatePercentBaseValueIfNeeded(svgNodeRenderer, context, length, true); + return ParseAbsoluteLength(svgNodeRenderer, length, percentBaseValue, defaultValue, context); + } + /// Extract svg viewbox values. /// /// the @@ -142,65 +181,94 @@ public static float[] ParseViewBox(ISvgNodeRenderer svgRenderer) { } /// - /// Extract width and height of the passed SVGNodeRenderer, - /// defaulting to respective viewbox values if either one is not present or - /// to browser default if viewbox is missing as well. + /// Extract width and height of the passed SVGNodeRenderer, defaulting to + /// + /// if either one is not present. /// + /// + /// Extract width and height of the passed SVGNodeRenderer, defaulting to + /// + /// if either one is not present. If + /// + /// isn't specified, than respective + /// viewbox values or browser default (if viewbox is missing) will be used. + /// /// /// the /// - /// instance that contains - /// the renderer tree + /// instance that contains the renderer tree /// /// em value in pt - /// rem value in pt - /// Rectangle, where x,y = 0 and width and height are extracted ones by this method. - public static Rectangle ExtractWidthAndHeight(ISvgNodeRenderer svgRenderer, float em, float rem) { - float[] values = iText.Svg.Utils.SvgCssUtils.ParseViewBox(svgRenderer); - float defaultWidth = values == null ? CssDimensionParsingUtils.ParseAbsoluteLength(SvgConstants.Values.DEFAULT_VIEWBOX_WIDTH - ) : values[2]; - float defaultHeight = values == null ? CssDimensionParsingUtils.ParseAbsoluteLength(SvgConstants.Values.DEFAULT_VIEWBOX_HEIGHT - ) : values[3]; - Rectangle result = new Rectangle(defaultWidth, defaultHeight); - String width = svgRenderer.GetAttribute(SvgConstants.Attributes.WIDTH); - if (CssTypesValidationUtils.IsRemValue(width)) { - result.SetWidth(CssDimensionParsingUtils.ParseRelativeValue(width, rem)); - } - else { - if (CssTypesValidationUtils.IsEmValue(width)) { - result.SetWidth(CssDimensionParsingUtils.ParseRelativeValue(width, em)); + /// the svg draw context + /// rectangle, where x,y = 0 and width and height are extracted ones by this method. + public static Rectangle ExtractWidthAndHeight(ISvgNodeRenderer svgRenderer, float em, SvgDrawContext context + ) { + float finalWidth = 0; + float finalHeight = 0; + float percentHorizontalBase; + float percentVerticalBase; + // Here we follow https://svgwg.org/specs/integration/#svg-css-sizing with one exception: + // we use author specified width and height (SvgDrawContext#customViewport) + // in any case regardless viewbox existing (it is how browsers work). + if (context.GetCustomViewport() == null) { + float[] viewBox = iText.Svg.Utils.SvgCssUtils.ParseViewBox(svgRenderer); + if (viewBox == null) { + percentHorizontalBase = CssDimensionParsingUtils.ParseAbsoluteLength(SvgConstants.Values.DEFAULT_VIEWPORT_WIDTH + ); + percentVerticalBase = CssDimensionParsingUtils.ParseAbsoluteLength(SvgConstants.Values.DEFAULT_VIEWPORT_HEIGHT + ); } else { - if (width != null) { - result.SetWidth(CssDimensionParsingUtils.ParseAbsoluteLength(width)); - } - else { - if (values == null) { - LOGGER.LogWarning(SvgLogMessageConstant.MISSING_WIDTH); - } - } + percentHorizontalBase = viewBox[2]; + percentVerticalBase = viewBox[3]; } } + else { + percentHorizontalBase = context.GetCustomViewport().GetWidth(); + percentVerticalBase = context.GetCustomViewport().GetHeight(); + } + float rem = context.GetCssContext().GetRootFontSize(); + String width = svgRenderer.GetAttribute(SvgConstants.Attributes.WIDTH); + finalWidth = CalculateFinalSvgRendererLength(width, em, rem, percentHorizontalBase); String height = svgRenderer.GetAttribute(SvgConstants.Attributes.HEIGHT); - if (CssTypesValidationUtils.IsRemValue(height)) { - result.SetHeight(CssDimensionParsingUtils.ParseRelativeValue(height, rem)); + finalHeight = CalculateFinalSvgRendererLength(height, em, rem, percentVerticalBase); + return new Rectangle(finalWidth, finalHeight); + } + + private static float CalculateFinalSvgRendererLength(String length, float em, float rem, float percentBase + ) { + if (length == null) { + length = SvgConstants.Values.DEFAULT_WIDTH_AND_HEIGHT_VALUE; + } + if (CssTypesValidationUtils.IsRemValue(length)) { + return CssDimensionParsingUtils.ParseRelativeValue(length, rem); } else { - if (CssTypesValidationUtils.IsEmValue(height)) { - result.SetHeight(CssDimensionParsingUtils.ParseRelativeValue(height, em)); + if (CssTypesValidationUtils.IsEmValue(length)) { + return CssDimensionParsingUtils.ParseRelativeValue(length, em); } else { - if (height != null) { - result.SetHeight(CssDimensionParsingUtils.ParseAbsoluteLength(height)); + if (CssTypesValidationUtils.IsPercentageValue(length)) { + return CssDimensionParsingUtils.ParseRelativeValue(length, percentBase); } else { - if (values == null) { - LOGGER.LogWarning(SvgLogMessageConstant.MISSING_HEIGHT); - } + return CssDimensionParsingUtils.ParseAbsoluteLength(length); } } } - return result; + } + + private static float CalculatePercentBaseValueIfNeeded(AbstractSvgNodeRenderer svgNodeRenderer, SvgDrawContext + context, String length, bool isXAxis) { + float percentBaseValue = 0.0F; + if (CssTypesValidationUtils.IsPercentageValue(length)) { + Rectangle viewBox = svgNodeRenderer.GetCurrentViewBox(context); + if (viewBox == null) { + throw new SvgProcessingException(SvgExceptionMessageConstant.ILLEGAL_RELATIVE_VALUE_NO_VIEWPORT_IS_SET); + } + percentBaseValue = isXAxis ? viewBox.GetWidth() : viewBox.GetHeight(); + } + return percentBaseValue; } } } diff --git a/port-hash b/port-hash index 557d64e7b2..45644bb10c 100644 --- a/port-hash +++ b/port-hash @@ -1 +1 @@ -ac38ed196978d1f68d38ccdfc1c58c4dbee26302 +81e947664c0e8cd96bb236ddbfb88205bdcc0243