Skip to content
Merged
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
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 17
VisualStudioVersion = 17.14.36616.10 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unit-conversion-in-text-layout", "Unit-conversion-in-text-layout\Unit-conversion-in-text-layout.csproj", "{B3390CE2-AAF4-48F8-B9B2-A3A6FD97CF66}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B3390CE2-AAF4-48F8-B9B2-A3A6FD97CF66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3390CE2-AAF4-48F8-B9B2-A3A6FD97CF66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3390CE2-AAF4-48F8-B9B2-A3A6FD97CF66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3390CE2-AAF4-48F8-B9B2-A3A6FD97CF66}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {44C257F7-3356-4AC0-93B6-5FE4C0803FD0}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Drawing;

// Create a new PDF document
using (PdfDocument document = new PdfDocument())
{
// Add a page
PdfPage page = document.Pages.Add();

// Initialize unit converter
PdfUnitConverter converter = new PdfUnitConverter();

// Convert margins from inches to points
float margin = converter.ConvertUnits(1f, PdfGraphicsUnit.Inch, PdfGraphicsUnit.Point);

// Define text bounds to fill the page with margins
RectangleF textBounds = new RectangleF(
margin,
margin,
page.Graphics.ClientSize.Width - 2 * margin,
page.Graphics.ClientSize.Height - 2 * margin
);

// Define font and paragraph text
PdfFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 14);

string paragraphText = "Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.";

// Create text element and layout format
PdfTextElement textElement = new PdfTextElement(paragraphText, font, PdfBrushes.Black);

PdfLayoutFormat layoutFormat = new PdfLayoutFormat
{
Break = PdfLayoutBreakType.FitPage,
Layout = PdfLayoutType.Paginate
};

// Draw the paragraph text within the bounds
textElement.Draw(page, textBounds, layoutFormat);

//Save the document
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Unit_conversion_in_text_layout</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
Loading