function RenderPDFPageAX(const fnm: String; const img: TImage; const pg: Integer; var pc: Integer; const zm: Integer; var err_msg: String): Boolean;
var
  vch: Variant;  // Variant containing the Canvas Handle
  bmp: TBitmap;
  dpi, pg_rt, zdvi: Integer;   zdvd: Double;
  wdtd, hgtd, wdtn, hgtn, wdts, hgts: Double;
  wdti, hgti: Integer;
  rnd_md: TFPURoundingMode;
  sbx: TScrollBox;
  obj: TObject;
  tmp_fnm: String;
begin
  Result := True;
  err_msg := '';
  sbx := nil;
  ReleasePdfImg(img);
  obj := img.Parent;
  if not Assigned(obj) then
    Exit;
  if (obj is TScrollBox) then
    sbx := (obj as TScrollBox);
  if not Assigned(sbx) then
    Exit;
  sbx.HorzScrollBar.Position := 0;
  sbx.VertScrollBar.Position := 0;
  img.AutoSize := True;
  img.Left := 0;
  img.Top := 0;
  img.Visible := True;
  bmp := nil;
  try
    if Assigned(GlobalVars.QwkPdf.axl) then
      begin
        inc(GlobalVars.RenderID);
        tmp_fnm := GlobalVars.AppProps.pdf_tmp_fdr + IntToStr(GlobalVars.RenderID) + '.dat';
        GlobalVars.QwkPdf.axl.OleServer.SetTempFile(tmp_fnm);
        Result := (GlobalVars.QwkPdf.axl.OleServer.LoadFromFile(fnm, '') = 1);
        if Result then
          begin
            with GlobalVars.QwkPdf.axl.OleServer do
              begin
                SetMeasurementUnits(2);   //  2 = Inches.
                SetGDIPlusOptions(0, 1);
                SetGDIPlusOptions(1, 1);
                SetGDIPlusOptions(2, 1);
                SetGDIPlusOptions(3, 1);
                SetGDIPlusOptions(10, 2);
                SetGDIPlusOptions(11, 2);
              end;
            pc := GlobalVars.QwkPdf.axl.OleServer.PageCount;
            GlobalVars.QwkPdf.axl.OleServer.SelectPage(pg);
            pg_rt := GlobalVars.QwkPdf.axl.OleServer.PageRotation;
            // Page Size in inches
            wdtd := GlobalVars.QwkPdf.axl.OleServer.PageWidth;
            hgtd := GlobalVars.QwkPdf.axl.OleServer.PageHeight;
            bmp := TBitmap.Create;
            bmp.Canvas.Brush.Color := clBlue; //clWhite;
            // Inches to Screen pixels
            wdti := Trunc(wdtd * GlobalVars.QwkPdf.sppi);
            hgti := Trunc(hgtd * GlobalVars.QwkPdf.sppi);
            if (pg_rt = 0) or (pg_rt = 180) then
              begin
                bmp.Width := wdti;
                bmp.Height := hgti;
              end
            else
              begin
                bmp.Width := hgti;
                bmp.Height := wdti;
              end;
            // Adjust for Zoom
            zdvd := 1;
            if not (zm = 100) then
              begin
                if (zm > 100) then
                  begin
                    zdvd := (zm div 100);
                  end;
                if (zm < 100) then
                  begin
                    zdvd := (zm / 100);
                  end;
              end;
            wdti := Trunc(bmp.Width * zdvd);
            hgti := Trunc(bmp.Height * zdvd);
            bmp.Width := wdti;
            bmp.Height := hgti;
            bmp.Canvas.FillRect(Rect(0, 0, bmp.Width, bmp.Height));
            img.Picture.Assign(bmp);
            vch := bmp.Canvas.Handle;
          end
        else
          begin
            err_msg := 'Unable to load PDF Viewer from file: ' + fnm + #13 + 'ErrorCode: ' + IntToStr(GlobalVars.QwkPdf.axl.OleServer.LastErrorCode);
            Exit;
          end;
        Result := (GlobalVars.QwkPdf.axl.OleServer.RenderPageToDC(Trunc(GlobalVars.QwkPdf.sppi * zdvd), pg, vch) = 1);
        if not Result then
          begin
            err_msg := 'Unable to render image from QuickPDF ActiveX' + #13 + GlobalVars.QwkPdf.axl.OleServer.LastRenderError;
            Exit;
          end;
      end;
  finally
    bmp.Free;
  end;
end;