diff --git a/.cr/personal/FavoritesList/List.xml b/.cr/personal/FavoritesList/List.xml new file mode 100644 index 0000000000..a60e5ed6c7 --- /dev/null +++ b/.cr/personal/FavoritesList/List.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/iTextCore.sln b/iTextCore.sln index 8620462e10..840b724c82 100644 --- a/iTextCore.sln +++ b/iTextCore.sln @@ -1,61 +1,60 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26430.15 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33815.320 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.io.netstandard", "itext\itext.io\itext.io.csproj", "{4C4C74D4-00E2-43A4-9D7A-54352096DE32}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.io", "itext\itext.io\itext.io.csproj", "{4C4C74D4-00E2-43A4-9D7A-54352096DE32}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.pdftest.netstandard", "itext\itext.pdftest\itext.pdftest.csproj", "{9BE8BB63-8A73-4348-9387-F47377B9F1BF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.pdftest", "itext\itext.pdftest\itext.pdftest.csproj", "{9BE8BB63-8A73-4348-9387-F47377B9F1BF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.io.tests.netstandard", "itext.tests\itext.io.tests\itext.io.tests.csproj", "{DC025E65-67E8-47BD-B135-1B71C05EE35E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.io.tests", "itext.tests\itext.io.tests\itext.io.tests.csproj", "{DC025E65-67E8-47BD-B135-1B71C05EE35E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.kernel.netstandard", "itext\itext.kernel\itext.kernel.csproj", "{76166842-A194-43B3-B5C0-4C78B845DABA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.kernel", "itext\itext.kernel\itext.kernel.csproj", "{76166842-A194-43B3-B5C0-4C78B845DABA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.kernel.tests.netstandard", "itext.tests\itext.kernel.tests\itext.kernel.tests.csproj", "{9EB233B4-5821-49DC-959E-F7BBA3D6DEB0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.kernel.tests", "itext.tests\itext.kernel.tests\itext.kernel.tests.csproj", "{9EB233B4-5821-49DC-959E-F7BBA3D6DEB0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.layout.netstandard", "itext\itext.layout\itext.layout.csproj", "{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.layout", "itext\itext.layout\itext.layout.csproj", "{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.pdfa.netstandard", "itext\itext.pdfa\itext.pdfa.csproj", "{6BF0A6C3-8982-4507-B704-C0878243B322}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.pdfa", "itext\itext.pdfa\itext.pdfa.csproj", "{6BF0A6C3-8982-4507-B704-C0878243B322}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.forms.netstandard", "itext\itext.forms\itext.forms.csproj", "{22FE2361-9580-43BC-98A7-608CFCAE4E8F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.forms", "itext\itext.forms\itext.forms.csproj", "{22FE2361-9580-43BC-98A7-608CFCAE4E8F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.barcodes.netstandard", "itext\itext.barcodes\itext.barcodes.csproj", "{ED4A03D3-DFC7-4760-9066-D01D4134627D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.barcodes", "itext\itext.barcodes\itext.barcodes.csproj", "{ED4A03D3-DFC7-4760-9066-D01D4134627D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.font-asian.netstandard", "itext\itext.font-asian\itext.font-asian.csproj", "{C3D759CE-C105-4566-A125-FBD77CFC7A82}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.font-asian", "itext\itext.font-asian\itext.font-asian.csproj", "{C3D759CE-C105-4566-A125-FBD77CFC7A82}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.hyph.netstandard", "itext\itext.hyph\itext.hyph.csproj", "{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.hyph", "itext\itext.hyph\itext.hyph.csproj", "{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.sign.netstandard", "itext\itext.sign\itext.sign.csproj", "{F284CE2A-821F-4B04-8CE3-558DAC5F8674}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.sign", "itext\itext.sign\itext.sign.csproj", "{F284CE2A-821F-4B04-8CE3-558DAC5F8674}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.barcodes.tests.netstandard", "itext.tests\itext.barcodes.tests\itext.barcodes.tests.csproj", "{4BB4B5FD-1EE1-4558-B126-E9E18BC45876}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.barcodes.tests", "itext.tests\itext.barcodes.tests\itext.barcodes.tests.csproj", "{4BB4B5FD-1EE1-4558-B126-E9E18BC45876}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.forms.tests.netstandard", "itext.tests\itext.forms.tests\itext.forms.tests.csproj", "{732D6882-40DF-41CB-8A18-ED43D4757177}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.forms.tests", "itext.tests\itext.forms.tests\itext.forms.tests.csproj", "{732D6882-40DF-41CB-8A18-ED43D4757177}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.layout.tests.netstandard", "itext.tests\itext.layout.tests\itext.layout.tests.csproj", "{620C13EC-D9B8-4F49-B536-5DD7E08B3984}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.layout.tests", "itext.tests\itext.layout.tests\itext.layout.tests.csproj", "{620C13EC-D9B8-4F49-B536-5DD7E08B3984}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.pdfa.tests.netstandard", "itext.tests\itext.pdfa.tests\itext.pdfa.tests.csproj", "{BA6474C1-E64B-4522-8D8B-A7AE10D2ED86}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.pdfa.tests", "itext.tests\itext.pdfa.tests\itext.pdfa.tests.csproj", "{BA6474C1-E64B-4522-8D8B-A7AE10D2ED86}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.sign.tests.netstandard", "itext.tests\itext.sign.tests\itext.sign.tests.csproj", "{22C91DB4-51CD-4339-B904-E5FE38B271CD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.sign.tests", "itext.tests\itext.sign.tests\itext.sign.tests.csproj", "{22C91DB4-51CD-4339-B904-E5FE38B271CD}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.styledxmlparser.netstandard", "itext\itext.styledxmlparser\itext.styledxmlparser.csproj", "{6894C148-5379-4D63-AC21-D67BD04AA064}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.styledxmlparser", "itext\itext.styledxmlparser\itext.styledxmlparser.csproj", "{6894C148-5379-4D63-AC21-D67BD04AA064}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.styledxmlparser.tests.netstandard", "itext.tests\itext.styledxmlparser.tests\itext.styledxmlparser.tests.csproj", "{2785E385-0940-4023-9868-8CDD25998176}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.styledxmlparser.tests", "itext.tests\itext.styledxmlparser.tests\itext.styledxmlparser.tests.csproj", "{2785E385-0940-4023-9868-8CDD25998176}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.svg.netstandard", "itext\itext.svg\itext.svg.csproj", "{8D69BA6B-D165-45C1-B144-F187B72850B9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.svg", "itext\itext.svg\itext.svg.csproj", "{8D69BA6B-D165-45C1-B144-F187B72850B9}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.svg.tests.netstandard", "itext.tests\itext.svg.tests\itext.svg.tests.csproj", "{9F61F451-EC4F-4D1A-B339-CEDD5FA4257C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.svg.tests", "itext.tests\itext.svg.tests\itext.svg.tests.csproj", "{9F61F451-EC4F-4D1A-B339-CEDD5FA4257C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "itext.pdftest.tests.netstandard", "itext.tests\itext.pdftest.tests\itext.pdftest.tests.csproj", "{46C393D2-BFAB-473A-AF06-E5FB586493FD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.pdftest.tests", "itext.tests\itext.pdftest.tests\itext.pdftest.tests.csproj", "{46C393D2-BFAB-473A-AF06-E5FB586493FD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "itext.commons.netstandard", "itext\itext.commons\itext.commons.csproj", "{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.commons", "itext\itext.commons\itext.commons.csproj", "{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "itext.commons.tests.netstandard", "itext.tests\itext.commons.tests\itext.commons.tests.csproj", "{726AEDB2-0B0D-45B8-A744-BFFEE36A187E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.commons.tests", "itext.tests\itext.commons.tests\itext.commons.tests.csproj", "{726AEDB2-0B0D-45B8-A744-BFFEE36A187E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "itext.bouncy-castle-adapter.netstandard", "itext\itext.bouncy-castle-adapter\itext.bouncy-castle-adapter.csproj", "{3A5D9DAC-A654-4542-8114-1D5B2F153D69}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.bouncy-castle-adapter", "itext\itext.bouncy-castle-adapter\itext.bouncy-castle-adapter.csproj", "{3A5D9DAC-A654-4542-8114-1D5B2F153D69}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "itext.bouncy-castle-fips-adapter.netstandard", "itext\itext.bouncy-castle-fips-adapter\itext.bouncy-castle-fips-adapter.csproj", "{3B634E19-5522-4907-8EE4-3FB017A4FC86}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.bouncy-castle-fips-adapter", "itext\itext.bouncy-castle-fips-adapter\itext.bouncy-castle-fips-adapter.csproj", "{3B634E19-5522-4907-8EE4-3FB017A4FC86}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "itext.bouncy-castle-connector.netstandard", "itext\itext.bouncy-castle-connector\itext.bouncy-castle-connector.csproj", "{C68E3329-A2E4-4B33-BADE-0521B8E832AD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.bouncy-castle-connector", "itext\itext.bouncy-castle-connector\itext.bouncy-castle-connector.csproj", "{C68E3329-A2E4-4B33-BADE-0521B8E832AD}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "itext.pdfua", "itext\itext.pdfua\itext.pdfua.csproj", "{9E785EC2-E32B-4C02-AFB4-84F99C587DEF}" EndProject @@ -359,18 +358,6 @@ Global {726AEDB2-0B0D-45B8-A744-BFFEE36A187E}.Release|x64.Build.0 = Release|Any CPU {726AEDB2-0B0D-45B8-A744-BFFEE36A187E}.Release|x86.ActiveCfg = Release|Any CPU {726AEDB2-0B0D-45B8-A744-BFFEE36A187E}.Release|x86.Build.0 = Release|Any CPU - {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|x64.ActiveCfg = Debug|Any CPU - {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|x64.Build.0 = Debug|Any CPU - {3B634E19-5522-4907-8EE4-3FB017A4FC86E}.Debug|x86.ActiveCfg = Debug|Any CPU - {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|x86.Build.0 = Debug|Any CPU - {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|Any CPU.Build.0 = Release|Any CPU - {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|x64.ActiveCfg = Release|Any CPU - {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|x64.Build.0 = Release|Any CPU - {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|x86.ActiveCfg = Release|Any CPU - {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|x86.Build.0 = Release|Any CPU {3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Debug|Any CPU.Build.0 = Debug|Any CPU {3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -383,6 +370,18 @@ Global {3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Release|x64.Build.0 = Release|Any CPU {3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Release|x86.ActiveCfg = Release|Any CPU {3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Release|x86.Build.0 = Release|Any CPU + {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|x64.ActiveCfg = Debug|Any CPU + {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|x64.Build.0 = Debug|Any CPU + {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|x86.ActiveCfg = Debug|Any CPU + {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|x86.Build.0 = Debug|Any CPU + {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|Any CPU.Build.0 = Release|Any CPU + {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|x64.ActiveCfg = Release|Any CPU + {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|x64.Build.0 = Release|Any CPU + {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|x86.ActiveCfg = Release|Any CPU + {3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|x86.Build.0 = Release|Any CPU {C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Debug|Any CPU.Build.0 = Debug|Any CPU {C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Debug|x64.ActiveCfg = Debug|Any CPU diff --git a/itext.tests/itext.forms.tests/itext/forms/form/element/RadioTest.cs b/itext.tests/itext.forms.tests/itext/forms/form/element/RadioTest.cs index ba696bca4e..15242c61e2 100644 --- a/itext.tests/itext.forms.tests/itext/forms/form/element/RadioTest.cs +++ b/itext.tests/itext.forms.tests/itext/forms/form/element/RadioTest.cs @@ -25,7 +25,9 @@ You should have received a copy of the GNU Affero General Public License using iText.Forms; using iText.Forms.Exceptions; using iText.Forms.Fields; +using iText.Forms.Fields.Properties; using iText.Forms.Form; +using iText.Forms.Form.Renderer.Checkboximpl; using iText.Forms.Logs; using iText.Kernel.Colors; using iText.Kernel.Exceptions; @@ -285,6 +287,135 @@ public virtual void RadioWithPaddingsTest() { } NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } + [NUnit.Framework.Test] + public virtual void RadioButtonCheckTypeCheckTest() + { + String outPdf = DESTINATION_FOLDER + "radioButtonCheckTypeCheck.pdf"; + String cmpPdf = SOURCE_FOLDER + "cmp_radioButtonCheckTypeCheck.pdf"; + SolidBorder border = new SolidBorder(ColorConstants.BLUE, 3); + Color checkColor = ColorConstants.BLUE; + Color backColor = ColorConstants.GREEN; + CheckBoxType checkType = Fields.Properties.CheckBoxType.CHECK; + PdfString caValue = new PdfString(PdfCheckBoxRenderingStrategy.ZAPFDINGBATS_CHECKBOX_MAPPING.GetByKey(checkType)); + using(PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outPdf))) + { + PdfButtonFormField btnGroup = CreateRadioButtonGroup(border, checkColor, backColor, checkType, caValue, pdfDocument); + // set selected radio button + btnGroup.SetValue("formRadio1"); + pdfDocument.Close(); + } + + NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + } + [NUnit.Framework.Test] + public virtual void RadioButtonCheckTypSquare() + { + String outPdf = DESTINATION_FOLDER + "radioButtonCheckTypeSquare.pdf"; + String cmpPdf = SOURCE_FOLDER + "cmp_radioButtonCheckTypeSquare.pdf"; + SolidBorder border = new SolidBorder(ColorConstants.ORANGE, 3); + Color checkColor = ColorConstants.ORANGE; + Color backColor = ColorConstants.GRAY; + CheckBoxType checkType = Fields.Properties.CheckBoxType.SQUARE; + PdfString caValue = new PdfString(PdfCheckBoxRenderingStrategy.ZAPFDINGBATS_CHECKBOX_MAPPING.GetByKey(checkType)); + using(PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outPdf))) + { + PdfButtonFormField btnGroup = CreateRadioButtonGroup(border, checkColor, backColor, checkType, caValue, pdfDocument); + // change btnGroup to allow unselect + btnGroup.SetRadio(false); + btnGroup.SetValue("formRadio2", false); + pdfDocument.Close(); + } + + NUnit.Framework.Assert.IsTrue(File.Exists(outPdf));//.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + } + [NUnit.Framework.Test] + public virtual void RadioButtonCheckTypSquare_NoSelection() + { + String outPdf = DESTINATION_FOLDER + "radioButtonCheckTypeSquare_NoSelection.pdf"; + String cmpPdf = SOURCE_FOLDER + "cmp_radioButtonCheckTypeSquare_NoSelection.pdf"; + SolidBorder border = new SolidBorder(ColorConstants.ORANGE, 3); + Color checkColor = ColorConstants.ORANGE; + Color backColor = ColorConstants.GRAY; + CheckBoxType checkType = Fields.Properties.CheckBoxType.SQUARE; + PdfString caValue = new PdfString(PdfCheckBoxRenderingStrategy.ZAPFDINGBATS_CHECKBOX_MAPPING.GetByKey(checkType)); + using(PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outPdf))) + { + PdfButtonFormField btnGroup = CreateRadioButtonGroup(border, checkColor, backColor, checkType, caValue, pdfDocument); + // change btnGroup to allow unselect + btnGroup.SetRadio(false); + btnGroup.SetValue("formRadio2", false); + pdfDocument.Close(); + } + + NUnit.Framework.Assert.IsTrue(File.Exists(outPdf));//.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + } + + [NUnit.Framework.Test] + public virtual void RadioButtonCheckTypeStar_NoSelectionTest() + { + String outPdf = DESTINATION_FOLDER + "radioButtonCheckTypeStar_NoSelection.pdf"; + String cmpPdf = SOURCE_FOLDER + "cmp_radioButtonCheckTypeStar_NoSelection.pdf"; + SolidBorder border = new SolidBorder(ColorConstants.ORANGE, 3); + Color checkColor = ColorConstants.ORANGE; + Color backColor = ColorConstants.GRAY; + CheckBoxType checkType = Fields.Properties.CheckBoxType.STAR; + PdfString caValue = new PdfString(PdfCheckBoxRenderingStrategy.ZAPFDINGBATS_CHECKBOX_MAPPING.GetByKey(checkType)); + using(PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outPdf))) + { + PdfButtonFormField btnGroup = CreateRadioButtonGroup(border, checkColor, backColor, checkType, caValue, pdfDocument); + // change btnGroup to allow unselect + btnGroup.SetRadio(false); + btnGroup.SetValue("", false); + pdfDocument.Close(); + } + + NUnit.Framework.Assert.IsTrue(File.Exists(outPdf));//.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); //.IsTrue(File.Exists(outPdf));// + } + private static PdfButtonFormField CreateRadioButtonGroup(SolidBorder border, Color checkColor, Color backColor, CheckBoxType checkType, PdfString caValue, PdfDocument pdfDocument) + { + pdfDocument.AddNewPage(PageSize.A4); + var form = PdfAcroForm.GetAcroForm(pdfDocument, true); + // create group + var radioBuilder1 = new RadioFormFieldBuilder(pdfDocument, "form radio group"); + radioBuilder1.SetCheckType(checkType); + var btnGroup = radioBuilder1.CreateRadioGroup(); + btnGroup.SetColor(ColorConstants.BLUE); + var formField = btnGroup; + formField.SetCheckType(checkType); + // create button1 + var btn1 = radioBuilder1.CreateRadioButton("formRadio1", new Rectangle(0, 800, 20, 20)); + btn1.SetPage(1); + btn1.SetBorderColor(border.GetColor()); + btn1.SetBorderWidth(border.GetWidth()); + btn1.SetBackgroundColor(backColor); + btn1.SetColor(checkColor); + btn1.SetParent(formField); + btnGroup.AddKid(btn1); + // set visible check type (highlight appearance in Acrobat) + var mk1 = btn1.GetWidget().GetAppearanceCharacteristics(); + if(mk1 == null) + mk1 = new PdfDictionary(); + mk1.Put(PdfName.CA, caValue); + btn1.Put(PdfName.MK, mk1); + // create button2 + var btn2 = radioBuilder1.CreateRadioButton("formRadio2", new Rectangle(22, 800, 20, 20)); + btn2.SetPage(1); + btn2.SetBorderColor(border.GetColor()); + btn2.SetBorderWidth(border.GetWidth()); + btn2.SetBackgroundColor(backColor); + btn2.SetColor(checkColor); + btn2.SetParent(formField); + // set visible check type (highlight appearance in Acrobat) + var mk2 = btn2.GetWidget().GetAppearanceCharacteristics(); + if(mk2 == null) + mk2 = new PdfDictionary(); + mk2.Put(PdfName.CA, caValue); + btn2.Put(PdfName.MK, mk2); + btnGroup.AddKid(btn2); + form.AddField(btnGroup); + return btnGroup; + } + [NUnit.Framework.Test] public virtual void MultiPageRadioFieldTest() { diff --git a/itext.tests/itext.forms.tests/resources/itext/forms/form/element/RadioTest/cmp_radioButtonCheckTypeCheck.pdf b/itext.tests/itext.forms.tests/resources/itext/forms/form/element/RadioTest/cmp_radioButtonCheckTypeCheck.pdf new file mode 100644 index 0000000000..f6c7cf39fa Binary files /dev/null and b/itext.tests/itext.forms.tests/resources/itext/forms/form/element/RadioTest/cmp_radioButtonCheckTypeCheck.pdf differ diff --git a/itext.tests/itext.forms.tests/resources/itext/forms/form/element/RadioTest/cmp_radioButtonCheckTypeSquare.pdf b/itext.tests/itext.forms.tests/resources/itext/forms/form/element/RadioTest/cmp_radioButtonCheckTypeSquare.pdf new file mode 100644 index 0000000000..6cfb967deb Binary files /dev/null and b/itext.tests/itext.forms.tests/resources/itext/forms/form/element/RadioTest/cmp_radioButtonCheckTypeSquare.pdf differ diff --git a/itext.tests/itext.forms.tests/resources/itext/forms/form/element/RadioTest/cmp_radioButtonCheckTypeSquare_NoSelection.pdf b/itext.tests/itext.forms.tests/resources/itext/forms/form/element/RadioTest/cmp_radioButtonCheckTypeSquare_NoSelection.pdf new file mode 100644 index 0000000000..fc98a55063 Binary files /dev/null and b/itext.tests/itext.forms.tests/resources/itext/forms/form/element/RadioTest/cmp_radioButtonCheckTypeSquare_NoSelection.pdf differ diff --git a/itext.tests/itext.forms.tests/resources/itext/forms/form/element/RadioTest/cmp_radioButtonCheckTypeStar_NoSelection.pdf b/itext.tests/itext.forms.tests/resources/itext/forms/form/element/RadioTest/cmp_radioButtonCheckTypeStar_NoSelection.pdf new file mode 100644 index 0000000000..bdf675fab1 Binary files /dev/null and b/itext.tests/itext.forms.tests/resources/itext/forms/form/element/RadioTest/cmp_radioButtonCheckTypeStar_NoSelection.pdf differ diff --git a/itext/itext.forms/itext/forms/fields/PdfFormAnnotation.cs b/itext/itext.forms/itext/forms/fields/PdfFormAnnotation.cs index deb6430537..d4079c0d05 100644 --- a/itext/itext.forms/itext/forms/fields/PdfFormAnnotation.cs +++ b/itext/itext.forms/itext/forms/fields/PdfFormAnnotation.cs @@ -766,17 +766,46 @@ protected internal virtual void DrawSignatureFormFieldAndSaveAppearance() { /// the value of the radio button. protected internal virtual void DrawRadioButtonAndSaveAppearance(String value) { Rectangle rectangle = GetRect(this.GetPdfObject()); - if (rectangle == null) { + if(rectangle == null) { return; } - if (!(formFieldElement is Radio)) { + + // Custom >>>>>>>>>>>>>> + var fontColor = ColorConstants.BLACK; + CheckBoxType? checkType = null; + if(parent != null && parent.checkType != null) + { + fontColor = GetParentField().GetColor(); + checkType = parent.checkType.GetValue(); + } + if(this.GetColor() != null) + fontColor = this.GetColor(); + // Custom<<<<<<<<<<<<<<<<<<<<< + + + if(!(formFieldElement is Radio)) { // Create it one time and re-set properties during each widget regeneration. - formFieldElement = new Radio(""); + if(checkType != null) + formFieldElement = new Radio("", checkType.Value); + else + formFieldElement = new Radio(""); } bool wasChecked = true.Equals(formFieldElement.GetProperty(FormProperty.FORM_FIELD_CHECKED)); SetModelElementProperties(GetRect(GetPdfObject())); // First draw off appearance ((Radio)formFieldElement).SetChecked(false); + + // Custom >>>>>>>>>>>>>> + if(checkType != null) + { + if(((Radio)formFieldElement).HasProperty(FormProperty.FORM_CHECKBOX_TYPE)) + ((Radio)formFieldElement).SetCheckBoxType(checkType.Value); + + ((Radio)formFieldElement).SetFontColor(fontColor); + } + // Custom<<<<<<<<<<<<<<<<<<<<< + + PdfFormXObject xObjectOff = new PdfFormXObject(new Rectangle(0, 0, rectangle.GetWidth(), rectangle.GetHeight ())); iText.Layout.Canvas canvasOff = new iText.Layout.Canvas(xObjectOff, this.GetDocument()); @@ -788,6 +817,15 @@ protected internal virtual void DrawRadioButtonAndSaveAppearance(String value) { if (value != null && !String.IsNullOrEmpty(value) && !iText.Forms.Fields.PdfFormAnnotation.OFF_STATE_VALUE .Equals(value)) { ((Radio)formFieldElement).SetChecked(true); + if(checkType != null) + { + if(((Radio)formFieldElement).HasProperty(FormProperty.FORM_CHECKBOX_TYPE)) + ((Radio)formFieldElement).SetCheckBoxType(checkType.Value); + + ((Radio)formFieldElement).SetFontColor(fontColor); + } + // Custom<<<<<<<<<<<<<<<<<<<<< + PdfFormXObject xObject = new PdfFormXObject(new Rectangle(0, 0, rectangle.GetWidth(), rectangle.GetHeight( ))); iText.Layout.Canvas canvas = new iText.Layout.Canvas(xObject, this.GetDocument()); diff --git a/itext/itext.forms/itext/forms/fields/RadioFormFieldBuilder.cs b/itext/itext.forms/itext/forms/fields/RadioFormFieldBuilder.cs index 8acdba389a..d36da8bad3 100644 --- a/itext/itext.forms/itext/forms/fields/RadioFormFieldBuilder.cs +++ b/itext/itext.forms/itext/forms/fields/RadioFormFieldBuilder.cs @@ -22,6 +22,7 @@ You should have received a copy of the GNU Affero General Public License */ using System; using iText.Forms.Exceptions; +using iText.Forms.Fields.Properties; using iText.Kernel.Exceptions; using iText.Kernel.Geom; using iText.Kernel.Pdf; @@ -37,6 +38,8 @@ public RadioFormFieldBuilder(PdfDocument document, String radioGroupFormFieldNam : base(document, radioGroupFormFieldName) { } + private CheckBoxType checkType = CheckBoxType.CIRCLE; + /// Creates radio group form field instance based on provided parameters. /// /// new @@ -84,5 +87,21 @@ public virtual PdfFormAnnotation CreateRadioButton(String appearanceName, Rectan protected internal override iText.Forms.Fields.RadioFormFieldBuilder GetThis() { return this; } + + /// Gets check type for checkbox form field. + /// check type to be set for checkbox form field + public virtual CheckBoxType GetCheckType() + { + return checkType; + } + public virtual RadioFormFieldBuilder SetCheckType(CheckBoxType checkType) + { + if(GetConformanceLevel() != null) + this.checkType = CheckBoxType.CIRCLE; + else + this.checkType = checkType; + + return this; + } } } diff --git a/itext/itext.forms/itext/forms/form/element/Radio.cs b/itext/itext.forms/itext/forms/form/element/Radio.cs index a467684c10..f60a47c8e4 100644 --- a/itext/itext.forms/itext/forms/form/element/Radio.cs +++ b/itext/itext.forms/itext/forms/form/element/Radio.cs @@ -21,8 +21,10 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ using System; +using iText.Forms.Fields.Properties; using iText.Forms.Form; using iText.Forms.Form.Renderer; +using iText.Kernel.Colors; using iText.Layout.Properties; using iText.Layout.Renderer; @@ -44,14 +46,26 @@ public class Radio : FormField { /// the id. public Radio(String id) : base(id) { + // Draw the borders inside the element by default SetProperty(Property.BOX_SIZING, BoxSizingPropertyValue.BORDER_BOX); - // Rounded border - SetBorderRadius(new BorderRadius(UnitValue.CreatePercentValue(50))); + //// Rounded border + //SetBorderRadius(new BorderRadius(UnitValue.CreatePercentValue(50))); // Draw border as a circle by default SetProperty(FormProperty.FORM_FIELD_RADIO_BORDER_CIRCLE, true); } - + /// + /// Creates a new + /// + /// instance. + /// + /// the id + /// CheckBoxType + public Radio(String id, CheckBoxType checkBoxType) + : base(id) + { + SetCheckBoxType(checkBoxType); + } /// /// Creates a new /// @@ -102,5 +116,38 @@ public override T1 GetProperty(int property) { protected override IRenderer MakeNewRenderer() { return new RadioRenderer(this); } + /// Sets the icon of the radio. + /// the type of the radio to set + /// this Radio instance + public Radio SetCheckBoxType(CheckBoxType checkBoxType) + { + SetProperty(FormProperty.FORM_CHECKBOX_TYPE, checkBoxType); + if(checkBoxType != CheckBoxType.CIRCLE) + { + // Rounded border + //SetBorderRadius(null); + DeleteOwnProperty(Property.BORDER_RADIUS); + DeleteOwnProperty(Property.BOX_SIZING); + DeleteOwnProperty(FormProperty.FORM_FIELD_RADIO_BORDER_CIRCLE); + SetProperty(Property.BOX_SIZING, BoxSizingPropertyValue.CONTENT_BOX); + SetProperty(FormProperty.FORM_FIELD_RADIO_BORDER_CIRCLE, false); + } + + return this; + } + /// + /// Sets the chech mark color + /// + /// The selected iText color + /// + public override Radio SetFontColor(Color color) + { + if(color == null) + color = ColorConstants.BLACK; + + DeleteOwnProperty(Property.FONT_COLOR); + SetProperty(Property.FONT_COLOR, color); + return this; + } } } diff --git a/itext/itext.forms/itext/forms/form/renderer/RadioRenderer.cs b/itext/itext.forms/itext/forms/form/renderer/RadioRenderer.cs index 3e0f636bd5..60e575f38c 100644 --- a/itext/itext.forms/itext/forms/form/renderer/RadioRenderer.cs +++ b/itext/itext.forms/itext/forms/form/renderer/RadioRenderer.cs @@ -25,6 +25,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Forms; using iText.Forms.Exceptions; using iText.Forms.Fields; +using iText.Forms.Fields.Properties; using iText.Forms.Form; using iText.Forms.Form.Element; using iText.Forms.Util; @@ -114,10 +115,17 @@ protected override Rectangle ApplyBorderBox(Rectangle rect, Border[] borders, bo /// protected internal override IRenderer CreateFlatRenderer() { UnitValue heightUV = GetPropertyAsUnitValue(Property.HEIGHT); - UnitValue widthUV = GetPropertyAsUnitValue(Property.WIDTH); - float height = null == heightUV ? DEFAULT_SIZE : heightUV.GetValue(); - float width = null == widthUV ? DEFAULT_SIZE : widthUV.GetValue(); - float size = Math.Min(height, width); + UnitValue widthUV = GetPropertyAsUnitValue(Property.WIDTH); + float height = null == heightUV ? DEFAULT_SIZE : heightUV.GetValue(); + float width = null == widthUV ? DEFAULT_SIZE : widthUV.GetValue(); + float size = Math.Min(height, width); + var border = this.GetProperty(Property.BORDER); + var checkType = (int)CheckBoxType.CIRCLE; + if(this.HasProperty(FormProperty.FORM_CHECKBOX_TYPE)) + checkType = ((IFormField)this.modelElement).GetProperty(FormProperty.FORM_CHECKBOX_TYPE); + var backGround = this.GetProperty(Property.BACKGROUND); + + // Set size to current renderer SetProperty(Property.HEIGHT, UnitValue.CreatePointValue(height)); SetProperty(Property.WIDTH, UnitValue.CreatePointValue(width)); @@ -125,8 +133,13 @@ protected internal override IRenderer CreateFlatRenderer() { ).SetVerticalAlignment(DEFAULT_VERTICAL_ALIGNMENT).SetMargin(0); paragraph.SetProperty(Property.BOX_SIZING, this.GetProperty(Property.BOX_SIZING)); paragraph.SetBorder(this.GetProperty(Property.BORDER)); - paragraph.SetProperty(Property.BACKGROUND, this.GetProperty(Property.BACKGROUND)); - paragraph.SetBorderRadius(new BorderRadius(UnitValue.CreatePercentValue(50))); + + if(backGround != null) + { + paragraph.SetProperty(Property.BACKGROUND, backGround); + } + if(checkType == (int)CheckBoxType.CIRCLE) + paragraph.SetBorderRadius(new BorderRadius(UnitValue.CreatePercentValue(50))); return new RadioRenderer.FlatParagraphRenderer(this, paragraph); } @@ -201,10 +214,95 @@ public override void DrawChildren(DrawContext drawContext) { // Nothing to draw return; } + var checkType = (int)CheckBoxType.CIRCLE; + if(this._enclosing.HasProperty(FormProperty.FORM_CHECKBOX_TYPE)) + { + checkType = ((IFormField)this._enclosing.modelElement).GetProperty(FormProperty.FORM_CHECKBOX_TYPE); + var fontColor = this.GetProperty(Property.FONT_COLOR); + if(checkType == (int)CheckBoxType.CIRCLE && (fontColor == null || fontColor == DEFAULT_CHECKED_COLOR)) + { + // classic circle + DrawChildren_Classic(drawContext); + } + else + DrawChildren_Custom(drawContext); + } + else + DrawChildren_Classic(drawContext); + } + + private void DrawChildren_Custom(DrawContext drawContext) + { + ((IFormField)this._enclosing.modelElement).SetProperty(Property.BOX_SIZING, BoxSizingPropertyValue.CONTENT_BOX); + var checkType = ((IFormField)this._enclosing.modelElement).GetProperty(FormProperty.FORM_CHECKBOX_TYPE); + PdfCanvas pdfCanvas = drawContext.GetCanvas(); + Rectangle rectangle = this.GetOccupiedArea().GetBBox().Clone(); + Border border = this.GetProperty(Property.BORDER); + var fontColor = this.GetProperty(Property.FONT_COLOR); + var annotationFontColor = this._enclosing.GetProperty(Property.FONT_COLOR); + var borderWith = 0f; + if(border != null) + { + borderWith = border.GetWidth(); + var db = border.GetWidth() * 2; + if(checkType == (int)CheckBoxType.CIRCLE) + rectangle.ApplyMargins(borderWith, borderWith, borderWith, borderWith, false); + else + rectangle = new Rectangle(rectangle.GetWidth() - db, rectangle.GetHeight() - db); + } + else + { + borderWith = 1f; + } + + if(annotationFontColor != null) + fontColor = annotationFontColor; + if(fontColor == null && annotationFontColor == null) + fontColor = DEFAULT_CHECKED_COLOR; + + pdfCanvas.SetFillColor(fontColor); + pdfCanvas.SaveState(); + + DrawCheckType(checkType, pdfCanvas, rectangle, borderWith); + pdfCanvas.RestoreState(); + } + private static void DrawCheckType(int checkType, PdfCanvas pdfCanvas, Rectangle rectangle, float borderWith) + { + switch(checkType) + { + case (int)CheckBoxType.CHECK: + DrawingUtil.DrawPdfCheck(pdfCanvas, rectangle.GetWidth(), rectangle.GetHeight(), borderWith, borderWith); + break; + case (int)CheckBoxType.CIRCLE: + DrawingUtil.DrawPdfCircle(pdfCanvas, rectangle.GetWidth(), rectangle.GetHeight(), borderWith, borderWith); + break; + case (int)CheckBoxType.CROSS: + DrawingUtil.DrawPdfCross(pdfCanvas, rectangle.GetWidth(), rectangle.GetHeight(), borderWith, borderWith); + break; + case (int)CheckBoxType.DIAMOND: + DrawingUtil.DrawPdfDiamond(pdfCanvas, rectangle.GetWidth(), rectangle.GetHeight(), borderWith, borderWith); + break; + case (int)CheckBoxType.SQUARE: + DrawingUtil.DrawPdfSquare(pdfCanvas, rectangle.GetWidth(), rectangle.GetHeight(), borderWith, borderWith); + break; + case (int)CheckBoxType.STAR: + DrawingUtil.DrawPdfStar(pdfCanvas, rectangle.GetWidth(), rectangle.GetHeight(), borderWith, borderWith); + break; + } + } + + public void DrawChildren_Classic(DrawContext drawContext) + { + if(!this._enclosing.IsBoxChecked()) + { + // Nothing to draw + return; + } PdfCanvas canvas = drawContext.GetCanvas(); Rectangle rectangle = this.GetOccupiedArea().GetBBox().Clone(); Border border = this.GetProperty(Property.BORDER); - if (border != null) { + if(border != null) + { rectangle.ApplyMargins(border.GetWidth(), border.GetWidth(), border.GetWidth(), border.GetWidth(), false); } float radius = Math.Min(rectangle.GetWidth(), rectangle.GetHeight()) / 2; @@ -214,6 +312,7 @@ public override void DrawChildren(DrawContext drawContext) { canvas.RestoreState(); } + /// /// /// diff --git a/itext/itext.forms/itext/forms/util/DrawingUtil.cs b/itext/itext.forms/itext/forms/util/DrawingUtil.cs index ac208f2f27..d643fb623d 100644 --- a/itext/itext.forms/itext/forms/util/DrawingUtil.cs +++ b/itext/itext.forms/itext/forms/util/DrawingUtil.cs @@ -52,6 +52,129 @@ public class DrawingUtil { + "-0.47 0 l\n" + "-0.761 0 l\n" + "-0.526 -0.171 l\n" + "-0.616 -0.448 l\n" + "-0.381 -0.277 l\n" + "-0.145 -0.448 l\n" + "-0.236 -0.171 l\n" + "h\n" + "f\n"; + #region PDF Custom Appearance + private static void DrawPdfAppearanceString(PdfCanvas canvas, float width, float height, float moveX, float moveY, String appearanceString) + { + canvas.SaveState(); + canvas.ConcatMatrix(width, 0, 0, height, moveX, moveY); + canvas.GetContentStream().GetOutputStream().WriteBytes(appearanceString.GetBytes(iText.Commons.Utils.EncodingUtil.ISO_8859_1)); + canvas.RestoreState(); + } + /// Draws a PDF check mark in the specified rectangle. + /// the canvas to draw on + /// the width of the rectangle + /// the height of the rectangle + /// the x coordinate of the bottom left corner of the rectangle + /// the y coordinate of the bottom left corner of the rectangle + public static void DrawPdfCheck(PdfCanvas canvas, float width, float height, float moveX, float moveY) + { + DrawPdfAppearanceString(canvas, width, height, moveX, moveY, check); + } + + /// Draws a PDF check mark in the specified rectangle. + /// the canvas to draw on + /// the width of the rectangle + /// the height of the rectangle + public static void DrawPdfCheck(PdfCanvas canvas, float width, float height) + { + DrawPdfAppearanceString(canvas, width, height, 0, 0, check); + } + + /// Draws a PDF circle in the specified rectangle. + /// the canvas to draw on + /// the width of the rectangle + /// the height of the rectangle + /// the x coordinate of the bottom left corner of the rectangle + /// the y coordinate of the bottom left corner of the rectangle + public static void DrawPdfCircle(PdfCanvas canvas, float width, float height, float moveX, float moveY) + { + DrawPdfAppearanceString(canvas, width, height, moveX, moveY, circle); + } + + /// Draws a PDFcircle in the specified rectangle. + /// the canvas to draw on + /// the width of the rectangle + /// the height of the rectangle + public static void DrawPdfCircle(PdfCanvas canvas, float width, float height) + { + DrawPdfAppearanceString(canvas, width, height, 0, 0, circle); + } + + /// Draws a PDF cross in the specified rectangle. + /// the canvas to draw on + /// the width of the rectangle + /// the height of the rectangle + /// the x coordinate of the bottom left corner of the rectangle + /// the y coordinate of the bottom left corner of the rectangle + public static void DrawPdfCross(PdfCanvas canvas, float width, float height, float moveX, float moveY) + { + DrawPdfAppearanceString(canvas, width, height, moveX, moveY, cross); + } + + /// Draws a PDF cross in the specified rectangle. + /// the canvas to draw on + /// the width of the rectangle + /// the height of the rectangle + public static void DrawPdfCross(PdfCanvas canvas, float width, float height) + { + DrawPdfAppearanceString(canvas, width, height, 0, 0, cross); + } + + /// Draws a PDF diamond in the specified rectangle. + /// the canvas to draw on + /// the width of the rectangle + /// the height of the rectangle + /// the x coordinate of the bottom left corner of the rectangle + /// the y coordinate of the bottom left corner of the rectangle + public static void DrawPdfDiamond(PdfCanvas canvas, float width, float height, float moveX, float moveY) + { + DrawPdfAppearanceString(canvas, width, height, moveX, moveY, diamond); + } + + /// Draws a PDF diamond in the specified rectangle. + /// the canvas to draw on + /// the width of the rectangle + /// the height of the rectangle + public static void DrawPdfDiamond(PdfCanvas canvas, float width, float height) + { + DrawPdfAppearanceString(canvas, width, height, 0, 0, diamond); + } + + /// Draws a PDF square in the specified rectangle. + /// the canvas to draw on + /// the width of the rectangle + /// the height of the rectangle + /// the x coordinate of the bottom left corner of the rectangle + /// the y coordinate of the bottom left corner of the rectangle + public static void DrawPdfSquare(PdfCanvas canvas, float width, float height, float moveX, float moveY) + { + DrawPdfAppearanceString(canvas, width, height, moveX, moveY, square); + } + + + + /// Draws a PDF star in the specified rectangle. + /// the canvas to draw on + /// the width of the rectangle + /// the height of the rectangle + /// the x coordinate of the bottom left corner of the rectangle + /// the y coordinate of the bottom left corner of the rectangle + public static void DrawPdfStar(PdfCanvas canvas, float width, float height, float moveX, float moveY) + { + DrawPdfAppearanceString(canvas, width, height, moveX, moveY, star); + } + + /// Draws a PDF star in the specified rectangle. + /// the canvas to draw on + /// the width of the rectangle + /// the height of the rectangle + public static void DrawPdfStar(PdfCanvas canvas, float width, float height) + { + DrawPdfAppearanceString(canvas, width, height, 0, 0, star); + } + #endregion + + #region PDF A Appearance private static void DrawPdfAAppearanceString(PdfCanvas canvas, float width, float height, float moveX, float moveY, String appearanceString) { canvas.SaveState(); @@ -190,5 +313,7 @@ public static void DrawCross(PdfCanvas canvas, float width, float height, float public static void DrawCircle(PdfCanvas canvas, float centerX, float centerY, float radius) { canvas.Circle(centerX, centerY, radius).Fill(); } + + #endregion } }