diff --git a/Examples/ApiExamples/ApiExamples/ApiExamples.csproj b/Examples/ApiExamples/ApiExamples/ApiExamples.csproj index aca254064..32f2fc4c4 100644 --- a/Examples/ApiExamples/ApiExamples/ApiExamples.csproj +++ b/Examples/ApiExamples/ApiExamples/ApiExamples.csproj @@ -128,7 +128,7 @@ - + diff --git a/Examples/ApiExamples/ApiExamples/ExCharts.cs b/Examples/ApiExamples/ApiExamples/ExCharts.cs index 3b8197f4c..42d2fceba 100644 --- a/Examples/ApiExamples/ApiExamples/ExCharts.cs +++ b/Examples/ApiExamples/ApiExamples/ExCharts.cs @@ -1712,5 +1712,60 @@ public void DataTable() doc.Save(ArtifactsDir + "Charts.DataTable.docx"); //ExEnd:DataTable } + + [Test] + public void ChartFormat() + { + //ExStart:ChartFormat + //GistId:5f20ac02cb42c6b08481aa1c5b0cd3db + //ExFor:Chart.Format + //ExFor:ChartTitle.Format + //ExFor:ChartAxisTitle.Format + //ExFor:ChartLegend.Format + //ExSummary:Shows how to use chart formating. + Document doc = new Document(); + DocumentBuilder builder = new DocumentBuilder(doc); + + Shape shape = builder.InsertChart(ChartType.Column, 432, 252); + Chart chart = shape.Chart; + + // Delete series generated by default. + ChartSeriesCollection series = chart.Series; + series.Clear(); + + string[] categories = new string[] { "Category 1", "Category 2" }; + series.Add("Series 1", categories, new double[] { 1, 2 }); + series.Add("Series 2", categories, new double[] { 3, 4 }); + + // Format chart background. + chart.Format.Fill.Solid(Color.DarkSlateGray); + + // Hide axis tick labels. + chart.AxisX.TickLabels.Position = AxisTickLabelPosition.None; + chart.AxisY.TickLabels.Position = AxisTickLabelPosition.None; + + // Format chart title. + chart.Title.Format.Fill.Solid(Color.LightGoldenrodYellow); + + // Format axis title. + chart.AxisX.Title.Show = true; + chart.AxisX.Title.Format.Fill.Solid(Color.LightGoldenrodYellow); + + // Format legend. + chart.Legend.Format.Fill.Solid(Color.LightGoldenrodYellow); + + doc.Save(ArtifactsDir + "Charts.ChartFormat.docx"); + //ExEnd:ChartFormat + + doc = new Document(ArtifactsDir + "Charts.ChartFormat.docx"); + + shape = (Shape)doc.GetChild(NodeType.Shape, 0, true); + chart = shape.Chart; + + Assert.AreEqual(Color.DarkSlateGray.ToArgb(), chart.Format.Fill.Color.ToArgb()); + Assert.AreEqual(Color.LightGoldenrodYellow.ToArgb(), chart.Title.Format.Fill.Color.ToArgb()); + Assert.AreEqual(Color.LightGoldenrodYellow.ToArgb(), chart.AxisX.Title.Format.Fill.Color.ToArgb()); + Assert.AreEqual(Color.LightGoldenrodYellow.ToArgb(), chart.Legend.Format.Fill.Color.ToArgb()); + } } } diff --git a/Examples/ApiExamples/ApiExamples/ExHtmlLoadOptions.cs b/Examples/ApiExamples/ApiExamples/ExHtmlLoadOptions.cs index d89790860..8ea74806f 100644 --- a/Examples/ApiExamples/ApiExamples/ExHtmlLoadOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExHtmlLoadOptions.cs @@ -328,5 +328,20 @@ public void BlockImport(BlockImportMode blockImportMode) doc.Save(ArtifactsDir + "HtmlLoadOptions.BlockImport.docx"); //ExEnd } + + [Test] + public void FontFaceRules() + { + //ExStart:FontFaceRules + //GistId:5f20ac02cb42c6b08481aa1c5b0cd3db + //ExFor:HtmlLoadOptions.SupportFontFaceRules + //ExSummary:Shows how to load declared "@font-face" rules. + HtmlLoadOptions loadOptions = new HtmlLoadOptions(); + loadOptions.SupportFontFaceRules = true; + Document doc = new Document(MyDir + "Html with FontFace.html", loadOptions); + + Assert.AreEqual("Bitstream Vera Serif Bold", doc.FontInfos[0].Name); + //ExEnd:FontFaceRules + } } } \ No newline at end of file diff --git a/Examples/ApiExamples/ApiExamples/ExImage.cs b/Examples/ApiExamples/ApiExamples/ExImage.cs index a66f38ff2..c0459588e 100644 --- a/Examples/ApiExamples/ApiExamples/ExImage.cs +++ b/Examples/ApiExamples/ApiExamples/ExImage.cs @@ -410,14 +410,13 @@ public void ScaleImage() Assert.AreEqual(300.0d, imageSize.HeightPoints); } -#if NET5_0_OR_GREATER [Test] public void InsertWebpImage() { //ExStart:InsertWebpImage //GistId:e386727403c2341ce4018bca370a5b41 //ExFor:DocumentBuilder.InsertImage(String) - //ExSummary:Shows how to insert WebP image (only .NetStandard) + //ExSummary:Shows how to insert WebP image. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); @@ -433,13 +432,12 @@ public void ReadWebpImage() //ExStart:ReadWebpImage //GistId:e386727403c2341ce4018bca370a5b41 //ExFor:ImageType - //ExSummary:Shows how to read WebP image (only .NetStandard) + //ExSummary:Shows how to read WebP image. Document doc = new Document(MyDir + "Document with WebP image.docx"); Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true); Assert.AreEqual(ImageType.WebP, shape.ImageData.ImageType); //ExEnd:ReadWebpImage } -#endif } } \ No newline at end of file diff --git a/Examples/ApiExamples/ApiExamples/ExOoxmlSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExOoxmlSaveOptions.cs index 1091361d4..dc2cfb14e 100644 --- a/Examples/ApiExamples/ApiExamples/ExOoxmlSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExOoxmlSaveOptions.cs @@ -10,6 +10,7 @@ using System.Drawing; using System.IO; using Aspose.Words; +using Aspose.Words.DigitalSignatures; using Aspose.Words.Drawing; using Aspose.Words.Lists; using Aspose.Words.Loading; @@ -402,5 +403,24 @@ public void Zip64ModeOption() new OoxmlSaveOptions { Zip64Mode = Zip64Mode.Always }); //ExEnd:Zip64ModeOption } + + [Test] + public void DigitalSignature() + { + //ExStart:DigitalSignature + //GistId:5f20ac02cb42c6b08481aa1c5b0cd3db + //ExFor:OoxmlSaveOptions.DigitalSignatureDetails + //ExSummary:Shows how to sign OOXML document. + Document doc = new Document(MyDir + "Document.docx"); + + CertificateHolder certificateHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw"); + OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(); + saveOptions.DigitalSignatureDetails = new DigitalSignatureDetails( + certificateHolder, + new SignOptions() { Comments = "Some comments", SignTime = DateTime.Now }); + + doc.Save(ArtifactsDir + "OoxmlSaveOptions.DigitalSignature.docx", saveOptions); + //ExEnd:DigitalSignature + } } } diff --git a/Examples/ApiExamples/ApiExamples/ExParagraphFormat.cs b/Examples/ApiExamples/ApiExamples/ExParagraphFormat.cs index 283cf16d2..a0c338376 100644 --- a/Examples/ApiExamples/ApiExamples/ExParagraphFormat.cs +++ b/Examples/ApiExamples/ApiExamples/ExParagraphFormat.cs @@ -528,5 +528,26 @@ public void ParagraphBaselineAlignment() format = doc.FirstSection.Body.Paragraphs[0].ParagraphFormat; Assert.AreEqual(BaselineAlignment.Top, format.BaselineAlignment); } + + [Test] + public void MirrorIndents() + { + //ExStart:MirrorIndents + //GistId:5f20ac02cb42c6b08481aa1c5b0cd3db + //ExFor:ParagraphFormat.MirrorIndents + //ExSummary:Show how to make left and right indents the same. + Document doc = new Document(MyDir + "Document.docx"); + ParagraphFormat format = doc.FirstSection.Body.Paragraphs[0].ParagraphFormat; + + format.MirrorIndents = true; + + doc.Save(ArtifactsDir + "ParagraphFormat.MirrorIndents.docx"); + //ExEnd:MirrorIndents + + doc = new Document(ArtifactsDir + "ParagraphFormat.MirrorIndents.docx"); + format = doc.FirstSection.Body.Paragraphs[0].ParagraphFormat; + + Assert.AreEqual(true, format.MirrorIndents); + } } } diff --git a/Examples/ApiExamples/ApiExamples/ExShape.cs b/Examples/ApiExamples/ApiExamples/ExShape.cs index b7f413c8d..68e8867f4 100644 --- a/Examples/ApiExamples/ApiExamples/ExShape.cs +++ b/Examples/ApiExamples/ApiExamples/ExShape.cs @@ -3106,5 +3106,79 @@ public void TextBoxOleControl() Assert.AreEqual("Updated text", textBoxControl.Text); //ExEnd:TextBoxOleControl } + + [Test] + public void Glow() + { + //ExStart:Glow + //GistId:5f20ac02cb42c6b08481aa1c5b0cd3db + //ExFor:ShapeBase.Glow + //ExFor:GlowFormat.Color + //ExFor:GlowFormat.Radius + //ExFor:GlowFormat.Transparency + //ExFor:GlowFormat.Remove() + //ExSummary:Shows how to interact with glow shape effect. + Document doc = new Document(MyDir + "Various shapes.docx"); + Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true); + + shape.Glow.Color = Color.Salmon; + shape.Glow.Radius = 30; + shape.Glow.Transparency = 0.15; + + doc.Save(ArtifactsDir + "Shape.Glow.docx"); + + doc = new Document(ArtifactsDir + "Shape.Glow.docx"); + shape = (Shape)doc.GetChild(NodeType.Shape, 0, true); + + Assert.AreEqual(Color.FromArgb(217, 250, 128, 114).ToArgb(), shape.Glow.Color.ToArgb()); + Assert.AreEqual(30, shape.Glow.Radius); + Assert.AreEqual(0.15d, shape.Glow.Transparency, 0.01d); + + shape.Glow.Remove(); + + Assert.AreEqual(Color.Black.ToArgb(), shape.Glow.Color.ToArgb()); + Assert.AreEqual(0, shape.Glow.Radius); + Assert.AreEqual(0, shape.Glow.Transparency); + //ExEnd:Glow + } + + [Test] + public void Reflection() + { + //ExStart:Reflection + //GistId:5f20ac02cb42c6b08481aa1c5b0cd3db + //ExFor:ShapeBase.Reflection + //ExFor:ReflectionFormat.Size + //ExFor:ReflectionFormat.Blur + //ExFor:ReflectionFormat.Transparency + //ExFor:ReflectionFormat.Distance + //ExFor:ReflectionFormat.Remove() + //ExSummary:Shows how to interact with reflection shape effect. + Document doc = new Document(MyDir + "Various shapes.docx"); + Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true); + + shape.Reflection.Transparency = 0.37; + shape.Reflection.Size = 0.48; + shape.Reflection.Blur = 17.5; + shape.Reflection.Distance = 9.2; + + doc.Save(ArtifactsDir + "Shape.Reflection.docx"); + + doc = new Document(ArtifactsDir + "Shape.Reflection.docx"); + shape = (Shape)doc.GetChild(NodeType.Shape, 0, true); + + Assert.AreEqual(0.37d, shape.Reflection.Transparency, 0.01d); + Assert.AreEqual(0.48d, shape.Reflection.Size, 0.01d); + Assert.AreEqual(17.5d, shape.Reflection.Blur, 0.01d); + Assert.AreEqual(9.2d, shape.Reflection.Distance, 0.01d); + + shape.Reflection.Remove(); + + Assert.AreEqual(0, shape.Reflection.Transparency); + Assert.AreEqual(0, shape.Reflection.Size); + Assert.AreEqual(0, shape.Reflection.Blur); + Assert.AreEqual(0, shape.Reflection.Distance); + //ExEnd:Reflection + } } } diff --git a/Examples/ApiExamples/ApiExamples/ExStyles.cs b/Examples/ApiExamples/ApiExamples/ExStyles.cs index 0f1381a37..3cd961af2 100644 --- a/Examples/ApiExamples/ApiExamples/ExStyles.cs +++ b/Examples/ApiExamples/ApiExamples/ExStyles.cs @@ -397,5 +397,29 @@ public void StylePriority() doc.Save(ArtifactsDir + "Styles.StylePriority.docx"); //ExEnd:StylePriority } + + [Test] + public void LinkedStyleName() + { + //ExStart:LinkedStyleName + //GistId:5f20ac02cb42c6b08481aa1c5b0cd3db + //ExFor:Style.LinkedStyleName + //ExSummary:Shows how to link styles among themselves. + Document doc = new Document(); + + Style styleHeading1 = doc.Styles[StyleIdentifier.Heading1]; + + Style styleHeading1Char = doc.Styles.Add(StyleType.Character, "Heading 1 Char"); + styleHeading1Char.Font.Name = "Verdana"; + styleHeading1Char.Font.Bold = true; + styleHeading1Char.Font.Border.LineStyle = LineStyle.Dot; + styleHeading1Char.Font.Border.LineWidth = 15; + + styleHeading1.LinkedStyleName = "Heading 1 Char"; + + Assert.AreEqual("Heading 1 Char", styleHeading1.LinkedStyleName); + Assert.AreEqual("Heading 1", styleHeading1Char.LinkedStyleName); + //ExEnd:LinkedStyleName + } } } diff --git a/Examples/Data/Html with FontFace.html b/Examples/Data/Html with FontFace.html new file mode 100644 index 000000000..1fc787ae4 --- /dev/null +++ b/Examples/Data/Html with FontFace.html @@ -0,0 +1,16 @@ + + + Web Font Sample + + + + This is Bitstream Vera Serif Bold. + + \ No newline at end of file diff --git a/Examples/Data/MyFonts/VeraSeBd.ttf b/Examples/Data/MyFonts/VeraSeBd.ttf new file mode 100644 index 000000000..672bf761f Binary files /dev/null and b/Examples/Data/MyFonts/VeraSeBd.ttf differ