Skip to content

Commit f6337a8

Browse files
2 parents 526d53a + 5671983 commit f6337a8

File tree

1 file changed

+9
-3
lines changed
  • PDF-to-image/.NET/PDFPage-to-Image/PDFPage-to-Image

1 file changed

+9
-3
lines changed

PDF-to-image/.NET/PDFPage-to-Image/PDFPage-to-Image/Program.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,24 @@ public static void Main(string[] args)
1212
PdfToImageConverter imageConverter = new PdfToImageConverter();
1313

1414
//Load the PDF document as a stream
15-
FileStream inputStream = new FileStream("../../../Data/Input.pdf", FileMode.Open, FileAccess.ReadWrite);
15+
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.ReadWrite);
16+
1617
imageConverter.Load(inputStream);
1718

1819
//Convert PDF to Image.
1920
Stream outputStream = imageConverter.Convert(0, false, false);
2021

22+
//Rewind the stream position to the beginning before copying.
23+
outputStream.Position = 0;
24+
2125
//Create file stream.
22-
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Output/Output.jpeg"), FileMode.Create, FileAccess.ReadWrite))
26+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.jpeg"), FileMode.Create, FileAccess.ReadWrite))
2327
{
2428
//Save the image to file stream.
25-
inputStream.CopyTo(outputFileStream);
29+
outputStream.CopyTo(outputFileStream);
2630
}
31+
//Dispose the imageConverter
32+
imageConverter.Dispose();
2733
}
2834
}
2935
}

0 commit comments

Comments
 (0)