Skip to content
Open
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.9.34622.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "ConsoleApp\ConsoleApp.csproj", "{4343B126-0BE7-4A4C-BD14-CEFB86AA8DF2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4343B126-0BE7-4A4C-BD14-CEFB86AA8DF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4343B126-0BE7-4A4C-BD14-CEFB86AA8DF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4343B126-0BE7-4A4C-BD14-CEFB86AA8DF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4343B126-0BE7-4A4C-BD14-CEFB86AA8DF2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {420AD2DD-DF09-4048-9EDC-E17668C6235F}
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>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.PdfToImageConverter.Net.Core" Version="*" />
<PackageReference Include="System.Drawing.Common" Version="8.0.6" />
</ItemGroup>

</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using SkiaSharp;
using Syncfusion.PdfToImageConverter;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;

namespace ConsoleApp
{
internal class Program
{
static int itr = 0;
static Bitmap[] bitmaps;
static void Main(string[] args)
{
//Initialize PDF to Image converter.
PdfToImageConverter imageConverter = new PdfToImageConverter();
//Load the PDF document as a stream
FileStream inputStream = new FileStream("../../../Input.pdf", FileMode.Open, FileAccess.ReadWrite);
imageConverter.Load(inputStream);
bitmaps = new Bitmap[imageConverter.PageCount - 1];
//Convert PDF to Image.
Stream[] outputStream = imageConverter.Convert(0, imageConverter.PageCount - 1, false, false);
bitmaps = BitmapConverter.ConvertStreamsToBitmaps(outputStream);
PrintDocument printDocument = new PrintDocument();
printDocument.PrintPage += PrintDocument_PrintPage;
printDocument.Print();
}

private static void PrintDocument_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(bitmaps[itr], 0, 0, e.PageBounds.Width, e.PageBounds.Height);
e.HasMorePages = itr < bitmaps.Length - 1;
itr = itr + 1;
}
}

public class BitmapConverter
{
public static Bitmap[] ConvertStreamsToBitmaps(Stream[] streams)
{
Bitmap[] bitmaps = new Bitmap[streams.Length];

for (int i = 0; i < streams.Length; i++)
{
bitmaps[i] = new Bitmap(streams[i]);
}

return bitmaps;
}
}

}