Output File Names
Default Output File Names
When using the PdfRasterizer's Draw method to convert the PDF document to an image file, there will be one image file created for each page specified in the PDF. These output files will be based on the name specified in the first parameter of the Draw method but will have a one based digit appended to the portion of the string before the extension. The code below demonstrates a typical conversion:
PdfRasterizer rasterizer = new PdfRasterizer("C:\\DocumentA.pdf");
rasterizer.Draw("C:\\DocumentA_Page.png", ImageFormat.Png, ImageSize.Dpi72);
Dim MyRasterizer As PdfRasterizer = New PdfRasterizer("C:\DocumentA.pdf")
MyRasterizer.Draw("C:\DocumentA_Page.png", ImageFormat.Png, ImageSize.Dpi72)
So if the PDF (DocumentA.pdf) contained 3 pages then after the execution of the Draw method the newly created files would be "DocumentA_Page1.png", "DocumentA_Page2.png" and "DocumentA_Page3.png".
Manual Control of Output File Names
If you would like more control of the files names for the output images this can be achieved by looping over the collection of Pages in your PdfRasterizer object and calling the Draw method individually for each page. Since calling the Draw method on individual pages of the PDF document only outputs one image file at a time you can then name each page individually and uniquely.
PdfRasterizer rasterizer = new PdfRasterizer("C:\\DocumentA.pdf");
for(int i = 0; i < raster.Pages.Count; i++)
{
rasterizer.Pages[i].Draw("C:\\Page" + i +"_DocumentA.png", ImageFormat.Png, ImageSize.Dpi72);
}
Dim MyRasterizer As PdfRasterizer = New PdfRasterizer("C:\DocumentA.pdf")
Dim i As Integer
For i = 0 To MyRasterizer.Pages.Count - 1
MyRasterizer.Pages(i).Draw("C:\Page" & i & "_DocumentA.png", ImageFormat.Png, ImageSize.Dpi72)
Next
Note that in all cases, the file extension specified file path of the Draw method (in this case "png") must match the image format defined in the ImageFormat parameter (in this case "ImageFormat.Png").