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.36408.4 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Detecting-text-clipping-in-PDF-layouts", "Detecting-text-clipping-in-PDF-layouts\Detecting-text-clipping-in-PDF-layouts.csproj", "{8CD58A5D-765C-40AC-BE7A-A1CD873F7173}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8CD58A5D-765C-40AC-BE7A-A1CD873F7173}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8CD58A5D-765C-40AC-BE7A-A1CD873F7173}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CD58A5D-765C-40AC-BE7A-A1CD873F7173}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CD58A5D-765C-40AC-BE7A-A1CD873F7173}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D8632971-EA4E-4115-A622-71FA04D6ED24}
EndGlobalSection
EndGlobal
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>Detecting_text_clipping_in_PDF_layouts</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Syncfusion.Drawing;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;

// Create a new PDF document
PdfDocument document = new PdfDocument();

// Add a page to the document
PdfPage page = document.Pages.Add();

// Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;

// Set the standard font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 30);

// Declare the text to be drawn
string text = "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.";

// Define the bounds within which the text should be drawn
RectangleF border = new RectangleF(0, 0, page.GetClientSize().Width, 150);

// Draw a rectangle to visualize the layout bounds
graphics.DrawRectangle(PdfPens.Black, border);

// Initialize the PdfStringLayouter to layout the text
PdfStringLayouter layouter = new PdfStringLayouter();

// Layout the text and get the result to check if it fits within the bounds
PdfStringLayoutResult result = layouter.Layout(text, font, new PdfStringFormat(PdfTextAlignment.Center), new SizeF(border.Width, border.Height));

// Check if any part of the text was clipped (did not fit within the specified bounds)
if (result.Remainder != null)
{
// Store the clipped portion of the text for further processing or logging
string remainderText = result.Remainder;
// Output the clipped text to the console for debugging or review
Console.WriteLine("Remainder Text: " + remainderText);
}
// Close the document and release resources
document.Close(true);

Loading