diff --git a/How to/FitToWidth/ConsoleApp1.sln b/How to/FitToWidth/ConsoleApp1.sln new file mode 100644 index 0000000..4e442b6 --- /dev/null +++ b/How to/FitToWidth/ConsoleApp1.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35527.113 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{974A1524-7916-4A6D-A66D-C71F56A751F8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {974A1524-7916-4A6D-A66D-C71F56A751F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {974A1524-7916-4A6D-A66D-C71F56A751F8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {974A1524-7916-4A6D-A66D-C71F56A751F8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {974A1524-7916-4A6D-A66D-C71F56A751F8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/How to/FitToWidth/ConsoleApp1/ConsoleApp1.csproj b/How to/FitToWidth/ConsoleApp1/ConsoleApp1.csproj new file mode 100644 index 0000000..c9b500b --- /dev/null +++ b/How to/FitToWidth/ConsoleApp1/ConsoleApp1.csproj @@ -0,0 +1,14 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net8.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + + <ItemGroup> + <PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" /> + </ItemGroup> + +</Project> diff --git a/How to/FitToWidth/ConsoleApp1/Output.pdf b/How to/FitToWidth/ConsoleApp1/Output.pdf new file mode 100644 index 0000000..621a85d Binary files /dev/null and b/How to/FitToWidth/ConsoleApp1/Output.pdf differ diff --git a/How to/FitToWidth/ConsoleApp1/Program.cs b/How to/FitToWidth/ConsoleApp1/Program.cs new file mode 100644 index 0000000..b18bff6 --- /dev/null +++ b/How to/FitToWidth/ConsoleApp1/Program.cs @@ -0,0 +1,28 @@ +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using System.IO; + +class Program +{ + static void Main() + { + // Create a new PDF document + PdfDocument doc = new PdfDocument(); + + // Add a new page to the document + PdfPage page = doc.Pages.Add(); + + // Set the document’s viewer preferences + doc.ViewerPreferences.FitWindow = true; // Fit the document to the window + doc.ViewerPreferences.PageLayout = PdfPageLayout.SinglePage; // Display one page at a time + + // Save and close the document + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) + { + doc.Save(outputFileStream); // Save the document to a file + } + + // Close the document after saving + doc.Close(true); + } +}