Skip to content

Commit 698683d

Browse files
committed
911741 Added RTL text to the text box field sample.
1 parent 64eca74 commit 698683d

File tree

5 files changed

+73
-0
lines changed

5 files changed

+73
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Add-RTL-text-in-a-textbox-field", "Add-RTL-text-in-a-textbox-field\Add-RTL-text-in-a-textbox-field.csproj", "{BC62D7EF-50C9-47CC-853F-4280B8F819FA}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{BC62D7EF-50C9-47CC-853F-4280B8F819FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{BC62D7EF-50C9-47CC-853F-4280B8F819FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{BC62D7EF-50C9-47CC-853F-4280B8F819FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{BC62D7EF-50C9-47CC-853F-4280B8F819FA}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Add_RTL_text_in_a_textbox_field</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>
Binary file not shown.

Forms/Add-RTL-text-in-a-textbox-field/.NET/Add-RTL-text-in-a-textbox-field/Output/gitkeep.txt

Whitespace-only changes.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Syncfusion.Pdf.Graphics;
2+
using Syncfusion.Pdf.Interactive;
3+
using Syncfusion.Pdf;
4+
using Syncfusion.Drawing;
5+
6+
// Create a new PDF document
7+
using (PdfDocument document = new PdfDocument())
8+
{
9+
// Add a page to the document
10+
PdfPage page = document.Pages.Add();
11+
// Create a font to be used for the text box.
12+
PdfTrueTypeFont font = new PdfTrueTypeFont(Path.GetFullPath(@"../../../Data/arial.ttf"), 12);
13+
// Create a text box field with RTL text
14+
PdfTextBoxField textBox = new PdfTextBoxField(page, "rtlTextBox");
15+
16+
// Set the default text (RTL text, Arabic example)
17+
textBox.Text = "مرحبا بكم في عالم البرمجة"; // "Welcome to the world of programming" in Arabic
18+
// Set the text direction to Right-to-Left
19+
textBox.TextAlignment = PdfTextAlignment.Right;
20+
21+
textBox.Bounds = new RectangleF(10, 10, 150, 50);
22+
// Set the font for the text box field
23+
textBox.Font = font;
24+
// Add the text box field to the page
25+
document.Form.Fields.Add(textBox);
26+
27+
//Set default appearance as false.
28+
document.Form.SetDefaultAppearance(false);
29+
30+
//Create file stream.
31+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
32+
{
33+
//Save the PDF document to file stream.
34+
document.Save(outputFileStream);
35+
}
36+
}

0 commit comments

Comments
 (0)