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 Original file line number Diff line number Diff line change @@ -12,18 +12,24 @@ public static void Main(string[] args)
12
12
PdfToImageConverter imageConverter = new PdfToImageConverter ( ) ;
13
13
14
14
//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
+
16
17
imageConverter . Load ( inputStream ) ;
17
18
18
19
//Convert PDF to Image.
19
20
Stream outputStream = imageConverter . Convert ( 0 , false , false ) ;
20
21
22
+ //Rewind the stream position to the beginning before copying.
23
+ outputStream . Position = 0 ;
24
+
21
25
//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 ) )
23
27
{
24
28
//Save the image to file stream.
25
- inputStream . CopyTo ( outputFileStream ) ;
29
+ outputStream . CopyTo ( outputFileStream ) ;
26
30
}
31
+ //Dispose the imageConverter
32
+ imageConverter . Dispose ( ) ;
27
33
}
28
34
}
29
35
}
You can’t perform that action at this time.
0 commit comments