title: How to make pdf file size with respect to div height and width using wkhtmltopdf.exe
body: <p>I tried to make pdf with wkhtmltopdf.exe by supplying html string and is working properly.But i want to provide pdf custom size to exe.</p>
  
  <p>eg:- 
     Suppose i have a div of height 30 and width 50. then the generated pdf should be of same size.</p>
  
  <p>Below is the code which i found from this website forum</p>
  
  <pre><code>     Private Sub WritePDF(ByVal HTML As String)
      Dim inFileName As String, outFileName As String, tempPath As String
      Dim p As Process
      Dim stdin As System.IO.StreamWriter
      Dim psi As New ProcessStartInfo()
  
      tempPath = Server.MapPath("~") + "\Uploads\"
      inFileName = Session.SessionID + ".htm"
      outFileName = Session.SessionID + ".pdf"
  
      ' run the conversion utility 
      psi.UseShellExecute = False
      'psi.FileName = "c:\Program Files (x86)\wkhtmltopdf\wkhtmltopdf.exe"
      psi.FileName = Server.MapPath("~") + "\App_Data\wkhtmltopdf.exe"
      psi.CreateNoWindow = True
      psi.RedirectStandardInput = True
      psi.RedirectStandardOutput = True
      psi.RedirectStandardError = True
  
  
      ' note that we tell wkhtmltopdf to be quiet and not run scripts 
      ' NOTE: I couldn't figure out a way to get both stdin and stdout redirected so we have to write to a file and then clean up afterwards 
      psi.Arguments = "-q -n - " &amp; tempPath &amp; outFileName
  
      p = Process.Start(psi)
  
      Try
          stdin = p.StandardInput
          stdin.AutoFlush = True
  
          stdin.Write(HTML)
          stdin.Close()
  
          If p.WaitForExit(15000) Then
              ' NOTE: the application hangs when we use WriteFile (due to the Delete below?); this works 
              'Response.WriteFile(tempPath + outFileName); 
              Response.BinaryWrite(System.IO.File.ReadAllBytes(tempPath &amp; outFileName))
          End If
      Finally
          p.Close()
          p.Dispose()
      End Try
  
      ' delete the pdf 
      System.IO.File.Delete(tempPath &amp; outFileName)
  End Sub
  </code></pre>