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
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Syncfusion.PdfToImageConverter.Net" Version="*" />
<PackageReference Include="System.Drawing.Common" Version="*" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Syncfusion.PdfToImageConverter;
using System.Drawing;
using System.Drawing.Printing;

// Initialize the PdfToImageConverter with the path to the PDF file
using (PdfToImageConverter imageConverter = new PdfToImageConverter())
{
// Load the PDF document
imageConverter.Load(new FileStream("Data/Input.pdf", FileMode.Open, FileAccess.Read));

//Convert all the PDF pages to images
Stream[] images = imageConverter.Convert(0, imageConverter.PageCount - 1, false, false);

//Create a print document object to print the images
using (PrintDocument printDocument = new PrintDocument())
{
int currentPageIndex = 0;
//Handle the PrintPage event to print each image
printDocument.PrintPage += (sender, e) =>
{
Stream imageStream = images[currentPageIndex];
imageStream.Position = 0; // Reset stream position
Image currentImage = Image.FromStream(imageStream);
//Draw the current image on the print page
e.Graphics.DrawImage(currentImage, e.PageBounds);
//Move to the next page
currentPageIndex++;
//Check if there are more pages to print
e.HasMorePages = currentPageIndex < images.Length;
};
//Print the document
printDocument.Print();
}
}
Loading