Skip to content

ES-935070- Add the sample Apply-image-border #375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Paragraphs/Apply-image-border/.NET/Apply-image-border.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31911.196
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apply-image-border", "Apply-image-border\Apply-image-border.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Apply_image_border</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\Picture.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

53 changes: 53 additions & 0 deletions Paragraphs/Apply-image-border/.NET/Apply-image-border/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using Syncfusion.Drawing;
using System.IO;

namespace Apply_image_border
{
class Program
{
static void Main(string[] args)
{
//Create an word document.
using (WordDocument document = new WordDocument())
{
document.EnsureMinimal();
//Appends new textbox to the paragraph
IWTextBox textbox = document.LastParagraph.AppendTextBox(150, 75);
//Set color to the text box's line.
textbox.TextBoxFormat.LineColor = Color.Purple;
//Set size of the text box's border.
textbox.TextBoxFormat.LineWidth = 2;
//Sets text box's margin values as Zero.
textbox.TextBoxFormat.InternalMargin.Top = 0f;
textbox.TextBoxFormat.InternalMargin.Bottom = 0f;
textbox.TextBoxFormat.InternalMargin.Left = 0f;
textbox.TextBoxFormat.InternalMargin.Right = 0f;
//Set text trapping style to the text box.
textbox.TextBoxFormat.TextWrappingStyle = TextWrappingStyle.Inline;

//Adds new text to the textbox body
IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/Picture.png"), FileMode.Open, FileAccess.ReadWrite);
WPicture picture = textboxParagraph.AppendPicture(imageStream) as WPicture;
//sets the picture width scale factor in percent.
picture.WidthScale = 80;
//sets the picture height scale factor in percent.
picture.HeightScale = 80;

//Set picture size as text box size.
textbox.TextBoxFormat.Width = picture.Width;
textbox.TextBoxFormat.Height = picture.Height;

//Creates file stream.
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
{
//Saves the Word document to file stream.
document.Save(outputFileStream, FormatType.Docx);
}
}
}
}
}

Loading