Skip to content

931474: Fit To Width Sample #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions How to/FitToWidth/ConsoleApp1.sln
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions How to/FitToWidth/ConsoleApp1/ConsoleApp1.csproj
Original file line number Diff line number Diff line change
@@ -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>
Binary file added How to/FitToWidth/ConsoleApp1/Output.pdf
Binary file not shown.
28 changes: 28 additions & 0 deletions How to/FitToWidth/ConsoleApp1/Program.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}