How to set the output resolution on a rasterized Bitmap?

Q:

I am trying to convert a PDF to JPG with a high DPI, however I need to
maintain the exact dimensions of the PDF.

Using the below code, I am able to convert the PDF to a JPG however the
dimension are considerably enhanced, if I reduce the DPI the quality is
not good enough for our use, and if I try scaling the image back down
to the original size after the conversion of the document to JPG the
quality is lost?

How do I convert the pdf maintaining the same dimensions but having a
high DPI?

Public Function ConvertPDfToJpg(ByVal strPDFPath As String, ByVal
strJPGPath As String, ByVal intDPI As Integer)
  PDFNet.Initialize()
  PDFNet.SetResourcesPath("c:\Visual Studio Projects\dsrDam")
  Dim tiger_doc As PDFDoc = New PDFDoc(strPDFPath)
  ' Initialize the security handler, in case the PDF is encrypted.
  tiger_doc.InitSecurityHandler()
  Dim page As Page = tiger_doc.PageBegin().Current()
  Dim draw As PDFDraw = New PDFDraw
  draw.SetDPI(500) ' Set the output resolution is to 500 DPI.
  draw.SetImageSize(218, 266)
  Dim bmp As System.Drawing.Bitmap = draw.GetBitmap(page)
  Dim strTif As String = strJPGPath.ToUpper.Replace("JPG", "TIF")
  bmp.Save(strTif, System.Drawing.Imaging.ImageFormat.Tiff)
  return strTif
End Function
----
A:

If you render the image at 500DPI, you will probably want to set the
same resolution on the generated bitmap. For example,

new_res = 500
draw.SetDPI(new_res)
....
bmp.SetResolution(new_res, new_res)
...
bmp.Save(...)

SetResolution is a method in GDI+ (Bitmap class in .NET Framework).