html文字列を入力してwkhtmltopdf.exeでpdfを作ろうとしましたが、正しく動作しています。wkhtmltopdf.exeを使ってdivの高さと幅に関してpdfファイルサイズを作る方法
例: - 高さ30と幅50のdivがあるとします。生成されるpdfのサイズは同じでなければなりません。以下は
あなたは--page-size引数を使用して、ページサイズ名を指定することができ、標準の用紙サイズ(A4を、使用したい場合、私はこのウェブサイトのフォーラム
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 - " & tempPath & 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 & outFileName))
End If
Finally
p.Close()
p.Dispose()
End Try
' delete the pdf
System.IO.File.Delete(tempPath & outFileName)
End Sub
jqueryからデータを送信しているためです。だから私はjqueryにタグを付けるべきだと思った。上記の言語はvb.netです –