From 453041295c070d5ca6baa4ad61633e4e383d9c9d Mon Sep 17 00:00:00 2001 From: stdstring Date: Wed, 6 Mar 2024 23:51:05 +0500 Subject: [PATCH] fixed some issues in APIExamples for simplifing ability of porting them --- Examples/ApiExamples/ApiExamples/ExDocument.cs | 2 +- Examples/ApiExamples/ApiExamples/ExDrawing.cs | 12 ++++++------ .../ApiExamples/ApiExamples/ExHtmlSaveOptions.cs | 12 ++++++------ Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs | 6 ++++++ Examples/ApiExamples/ApiExamples/ExRange.cs | 5 +++-- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Examples/ApiExamples/ApiExamples/ExDocument.cs b/Examples/ApiExamples/ApiExamples/ExDocument.cs index a497fedc..7cf1d221 100644 --- a/Examples/ApiExamples/ApiExamples/ExDocument.cs +++ b/Examples/ApiExamples/ApiExamples/ExDocument.cs @@ -330,7 +330,7 @@ public void PdfRenderer(string docName, string format) break; - case "XPS": + case "XPS": SaveTo(pdfRenderer, docName, options, "xps"); AssertResult("xps"); diff --git a/Examples/ApiExamples/ApiExamples/ExDrawing.cs b/Examples/ApiExamples/ApiExamples/ExDrawing.cs index b520458f..e20e8bc7 100644 --- a/Examples/ApiExamples/ApiExamples/ExDrawing.cs +++ b/Examples/ApiExamples/ApiExamples/ExDrawing.cs @@ -307,7 +307,7 @@ public void SaveAllImages() Assert.AreEqual(".Jpeg", fileInfos[7].Extension); TestUtil.VerifyImage(1200, 1500, fileInfos[8].FullName); Assert.AreEqual(".Jpeg", fileInfos[8].Extension); - } + } [Test] public void StrokePattern() @@ -461,17 +461,17 @@ public void TextBox() Shape textbox = new Shape(doc, ShapeType.TextBox) { - Width = 100, - Height = 100, - TextBox = { LayoutFlow = LayoutFlow.BottomToTop } + Width = 100, + Height = 100 }; - + textbox.TextBox.LayoutFlow = LayoutFlow.BottomToTop; + textbox.AppendChild(new Paragraph(doc)); builder.InsertNode(textbox); builder.MoveTo(textbox.FirstParagraph); builder.Write("This text is flipped 90 degrees to the left."); - + doc.Save(ArtifactsDir + "Drawing.TextBox.docx"); //ExEnd diff --git a/Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs index 39571742..6d713d8c 100644 --- a/Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs @@ -378,8 +378,8 @@ public void SvgMetafileFormat() style='fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;' /> "); - builder.Document.Save(ArtifactsDir + "HtmlSaveOptions.SvgMetafileFormat.html", - new HtmlSaveOptions { MetafileFormat = HtmlMetafileFormat.Png }); + HtmlSaveOptions saveOptions = new HtmlSaveOptions { MetafileFormat = HtmlMetafileFormat.Png }; + builder.Document.Save(ArtifactsDir + "HtmlSaveOptions.SvgMetafileFormat.html", saveOptions); } [Test] @@ -394,8 +394,8 @@ public void PngMetafileFormat() style='fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;' /> "); - builder.Document.Save(ArtifactsDir + "HtmlSaveOptions.PngMetafileFormat.html", - new HtmlSaveOptions { MetafileFormat = HtmlMetafileFormat.Png }); + HtmlSaveOptions saveOptions = new HtmlSaveOptions { MetafileFormat = HtmlMetafileFormat.Png }; + builder.Document.Save(ArtifactsDir + "HtmlSaveOptions.PngMetafileFormat.html", saveOptions); } [Test] @@ -413,8 +413,8 @@ public void EmfOrWmfMetafileFormat() ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0 vr4MkhoXe0rZigAAAABJRU5ErkJggg=="" alt=""Red dot"" />"); - builder.Document.Save(ArtifactsDir + "HtmlSaveOptions.EmfOrWmfMetafileFormat.html", - new HtmlSaveOptions { MetafileFormat = HtmlMetafileFormat.EmfOrWmf }); + HtmlSaveOptions saveOptions = new HtmlSaveOptions { MetafileFormat = HtmlMetafileFormat.EmfOrWmf }; + builder.Document.Save(ArtifactsDir + "HtmlSaveOptions.EmfOrWmfMetafileFormat.html", saveOptions); } [Test] diff --git a/Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs index 03a2682f..f4525edc 100644 --- a/Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs @@ -2576,6 +2576,12 @@ public void ExportParagraphGraphicsToArtifact() doc.Save(ArtifactsDir + "PdfSaveOptions.ExportParagraphGraphicsToArtifact.pdf", saveOptions); //ExEnd + } + + [Test] + public void UsePdfDocumentForExportParagraphGraphicsToArtifact() + { + ExportParagraphGraphicsToArtifact(); Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(ArtifactsDir + "PdfSaveOptions.ExportParagraphGraphicsToArtifact.pdf"); Assert.AreEqual(3, pdfDocument.Pages[1].Artifacts.Count()); diff --git a/Examples/ApiExamples/ApiExamples/ExRange.cs b/Examples/ApiExamples/ApiExamples/ExRange.cs index d4b57044..3b2f3422 100644 --- a/Examples/ApiExamples/ApiExamples/ExRange.cs +++ b/Examples/ApiExamples/ApiExamples/ExRange.cs @@ -286,11 +286,12 @@ public void IgnoreShapes() DocumentBuilder builder = new DocumentBuilder(doc); builder.Write("Lorem ipsum dolor sit amet, consectetur adipiscing elit."); - builder.InsertShape(ShapeType.Balloon, 200, 200); + builder.InsertShape(ShapeType.Balloon, 200, 200); builder.Write("Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + FindReplaceOptions findReplaceOptions = new FindReplaceOptions() { IgnoreShapes = true }; builder.Document.Range.Replace("Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", new FindReplaceOptions() { IgnoreShapes = true }); + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", findReplaceOptions); Assert.AreEqual("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", builder.Document.GetText().Trim()); //ExEnd }