Skip to content

Commit

Permalink
fixed some issues in APIExamples for simplifing ability of porting them
Browse files Browse the repository at this point in the history
  • Loading branch information
stdstring committed Mar 6, 2024
1 parent a1527c4 commit db8b016
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Examples/ApiExamples/ApiExamples/ExDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public void PdfRenderer(string docName, string format)

break;

case "XPS":
case "XPS":
SaveTo(pdfRenderer, docName, options, "xps");
AssertResult("xps");

Expand Down
8 changes: 4 additions & 4 deletions Examples/ApiExamples/ApiExamples/ExDrawing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -461,17 +461,17 @@ public void TextBox()

Shape textbox = new Shape(doc, ShapeType.TextBox)
{
Width = 100,
Width = 100,
Height = 100,
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

Expand Down
12 changes: 6 additions & 6 deletions Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ public void SvgMetafileFormat()
style='fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;' />
</svg> ");

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]
Expand All @@ -394,8 +394,8 @@ public void PngMetafileFormat()
style='fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;' />
</svg> ");

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]
Expand All @@ -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]
Expand Down
6 changes: 6 additions & 0 deletions Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
5 changes: 3 additions & 2 deletions Examples/ApiExamples/ApiExamples/ExRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit db8b016

Please sign in to comment.