Output File Names

DynamicPDF Rasterizer allows outputting image files using either a default naming strategy or using user-defined names. The default naming strategy makes generating a file easier while manually controlling an output file name provides developers greater flexibility.

Default Output File Names

When using the PdfRasterizer's Draw method to convert the PDF document to an image file, one image file is created for each PDF page specified. These output files are named using the value specified in the Draw method's first parameter. The naming strategy is as follows.

<name-from-Draw-method> + "Page" + <page-number>.<file-type-extension>

The name from the file appends the word "Page_" and then the page number followed by the file extension. The following code illustrates default output file naming.

PdfRasterizer rasterizer = new PdfRasterizer(pdfFilePath);
rasterizer.Draw(pngFilePath, ImageFormat.Png, ImageSize.Dpi72);        
Dim MyRasterizer As PdfRasterizer = New PdfRasterizer(pdfFilePath)
MyRasterizer.Draw(pngFilePath, ImageFormat.Png, ImageSize.Dpi72)    

For example, if the PDF (DocumentA.pdf) contained 3 pages, then after executing the Draw method, the newly created files would be named "DocumentA_Page1.png", "DocumentA_Page2.png" and "DocumentA_Page3.png".

Manual Control of Output File Names

Developers also have control of file names by iterating over a collection of Pages in a PdfRasterizer object and then calling the Draw method individually for each page. Each page within the loop outputs the current image from the PDF document and allows naming each page uniquely. 

PdfRasterizer rasterizer = new PdfRasterizer(pdfFilePath);
for(int i = 0; i < rasterizer.Pages.Count; i++)
{
   rasterizer.Pages[i].Draw("Page" + i +"_DocumentA.png", ImageFormat.Png, ImageSize.Dpi72);
}        
Dim MyRasterizer As PdfRasterizer = New PdfRasterizer(pdfFilePath)
Dim i As Integer
For i = 0 To MyRasterizer.Pages.Count - 1
   MyRasterizer.Pages(i).Draw("Page" & i & "_DocumentA.png", ImageFormat.Png,   ImageSize.Dpi72)
Next

In this topic