-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from SyncfusionExamples/Task-935618-SaveRestore
Task-935618- Save and restore the PdfGraphics sample
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...aphics/.NET/Saving-and-Restoring-the-PdfGraphics/Saving-and-Restoring-the-PdfGraphics.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.13.35617.110 d17.13 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Saving-and-Restoring-the-PdfGraphics", "Saving-and-Restoring-the-PdfGraphics\Saving-and-Restoring-the-PdfGraphics.csproj", "{A81CE32D-AAEE-45DB-B18A-224639CAE5E1}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A81CE32D-AAEE-45DB-B18A-224639CAE5E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A81CE32D-AAEE-45DB-B18A-224639CAE5E1}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A81CE32D-AAEE-45DB-B18A-224639CAE5E1}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A81CE32D-AAEE-45DB-B18A-224639CAE5E1}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {DEC52A59-B6AE-4347-84D1-1DCD62427AE9} | ||
EndGlobalSection | ||
EndGlobal |
Empty file.
29 changes: 29 additions & 0 deletions
29
....NET/Saving-and-Restoring-the-PdfGraphics/Saving-and-Restoring-the-PdfGraphics/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Create a new PDF document | ||
using Syncfusion.Pdf; | ||
using Syncfusion.Pdf.Graphics; | ||
using Syncfusion.Drawing; | ||
|
||
using (PdfDocument pdfDocument = new PdfDocument()) | ||
{ | ||
PdfPage page = pdfDocument.Pages.Add(); | ||
// Create PDF graphics | ||
PdfGraphics graphics = page.Graphics; | ||
// Save the current graphics state and apply transformations | ||
graphics.Save(); | ||
graphics.TranslateTransform(100, 50); | ||
graphics.RotateTransform(45); | ||
// Define the font for drawing text | ||
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 16); | ||
// Draw transformed text | ||
graphics.DrawString("Hello, World!", font, PdfBrushes.Black, new PointF(0, 0)); | ||
// Restore the previous graphics state to ensure subsequent text is unaffected | ||
graphics.Restore(); | ||
// Draw text that is not influenced by transformations | ||
graphics.DrawString("This text is not rotated.", font, PdfBrushes.Black, new PointF(0, 100)); | ||
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) | ||
{ | ||
//Save the PDF document to file stream. | ||
pdfDocument.Save(outputFileStream); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...Graphics/Saving-and-Restoring-the-PdfGraphics/Saving-and-Restoring-the-PdfGraphics.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>Saving_and_Restoring_the_PdfGraphics</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" /> | ||
</ItemGroup> | ||
|
||
</Project> |