Memory limit for running external executables within Asp.net
Posted
by
itsbalur
on Stack Overflow
See other posts from Stack Overflow
or by itsbalur
Published on 2012-09-02T09:37:08Z
Indexed on
2012/09/02
9:37 UTC
Read the original article
Hit count: 289
I am using WkhtmltoPdf in my C# web application running in .NET 4.0 to generate PDFs from HTML files. In general everything works fine except when the size of the HTML file is below 250KB. Once the HTML file size increases beyond that, the process which runs the wkhtmltopdf.exe gives an exception as below. On the Task Manager, I have seen that the Memory value for the wkhtmltopdf.exe process does not increase beyond a value of 40,096 K, which I believe is the reason why the process is abandoned in between.
How can we configure such that the memory limit for external exes can be increased? Is there any other way of solving this issue?
More info:
When I run the conversion from the command line directly, the PDF is generated fine. So, its unlikely to be a problem with WkhtmlToPdf.
The error is from localhost. I have tried the same on the DEV server, with the same result.
Exception:
> [Exception: Loading pages (1/6) [>
> ] 0% [======> ]
> 10% [======> ] 11%
> [=======> ] 13%
> [=========> ] 15%
> [==========> ] 18%
> [============> ] 20%
> [=============> ] 22%
> [==============> ] 24%
> [===============> ] 26%
> [=================> ] 29%
> [==================> ] 31%
> [===================> ] 33%
> [=====================> ] 35%
> [======================> ] 37%
> [========================> ] 40%
> [=========================> ] 42%
> [==========================> ] 44%
> [============================> ] 47%
> [=============================> ] 49%
> [==============================> ] 51%
> [============================================================] 100%
> Counting pages (2/6)
> [============================================================] Object
> 1 of 1 Resolving links (4/6)
> [============================================================] Object
> 1 of 1 Loading headers and footers (5/6)
> Printing pages (6/6) [>
> ] Preparing [=>
> ] Page 1 of 49 [==>
> ] Page 2 of 49 [===>
> ] Page 3 of 49 [====>
> ] Page 4 of 49 [======>
> ] Page 5 of 49 [=======>
> ] Page 6 of 49 [========>
> ] Page 7 of 49 [=========>
> ] Page 8 of 49 [==========>
> ] Page 9 of 49 [============>
> ] Page 10 of 49 [=============>
> ] Page 11 of 49 [==============>
> ] Page 12 of 49 [===============>
> ] Page 13 of 49 [================>
> ] Page 14 of 49 [==================>
> ] Page 15 of 49 [===================>
> ] Page 16 of 49 [====================>
> ] Page 17 of 49 [=====================>
> ] Page 18 of 49 [======================>
> ] Page 19 of 49 [========================>
> ] Page 20 of 49 [=========================>
> ] Page 21 of 49 [==========================>
> ] Page 22 of 49 [===========================>
> ] Page 23 of 49 [============================>
> ] Page 24 of 49 [==============================>
> ] Page 25 of 49 [===============================>
> ] Page 26 of 49 [=================================>
> ] Page 27 of 49 [==================================>
> ]
Code that I use:
var fileName = " - ";
var wkhtmlDir = ConfigurationManager.AppSettings[Constants.AppSettings.ExportToPdfExecutablePath];
var wkhtml = ConfigurationManager.AppSettings[Constants.AppSettings.ExportToPdfExecutablePath] + "\\wkhtmltopdf.exe";
var p = new Process();
string switches = "";
switches += "--print-media-type ";
switches += "--margin-top 10mm --margin-bottom 10mm --margin-right 5mm --margin-left 5mm ";
switches += "--page-size A4 ";
switches += "--disable-smart-shrinking ";
var startInfo = new ProcessStartInfo
{
CreateNoWindow = true,
FileName = wkhtml,
Arguments = switches + " " + url + " " + fileName,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput=true,
WorkingDirectory=wkhtmlDir
};
p.StartInfo = startInfo;
p.Start();
© Stack Overflow or respective owner