Comments (7)
Does #4 fix this issue? I could move out the helper into its own class and make a pull request if that is the only feature outstanding?
from wkhtmltoxsharp.
Hi Haroon,
The feature you are asking for it's implemented in this pull-request
#4 which I have not been able
to merge yet due to time constraints. As I cannot apply a direct merge
using github due to some minor issues.
Pablo
On Mon, Apr 16, 2012 at 3:02 PM, Haroon <
[email protected]
wrote:
I was wondering how do I set the page width/size?
WkhtmlToPDF (according to
http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf-0.9.9-doc.html)Exposes the option –-page-width
Reply to this email directly or view it on GitHub:
#6
from wkhtmltoxsharp.
I have tested the width and height from this pull request #4, but it throws a memory is currupt exception?
from wkhtmltoxsharp.
Hi,
How are you testing your code changes? Memory corruption issues are
normally related to incorrect usage of the component by using it from
two or more consecutive app. Domains.. Which provokes a corruption of
the underlaying library memory..
Keep in mind that tlwe are using a native library under the hood
Sent from my iPhone
On 17/04/2012, at 12:11, Haroon
[email protected]
wrote:
I have tested the width and height from this pull request #4, but it throws a memory is currupt exception?
Reply to this email directly or view it on GitHub:
#6 (comment)
from wkhtmltoxsharp.
I am running my code inside an asp.net mvc controller - the code is run on the default server from visual studio... I am not running an Async controller.
This works without using the Page Width or Page Height props... As soon as I use those two properties I get the exception...
private MultiplexingConverter _GetConverter()
{
var obj = new MultiplexingConverter();
//obj.Begin += (s, e) => _Log.DebugFormat("Conversion begin, phase count: {0}", e.Value);
//obj.Error += (s, e) => _Log.Error(e.Value);
//obj.Warning += (s, e) => _Log.Warn(e.Value);
//obj.PhaseChanged += (s, e) => _Log.InfoFormat("PhaseChanged: {0} - {1}", e.Value, e.Value2);
//obj.ProgressChanged += (s, e) => _Log.InfoFormat("ProgressChanged: {0} - {1}", e.Value, e.Value2);
//obj.Finished += (s, e) => _Log.InfoFormat("Finished: {0}", e.Value ? "success" : "failed!");
return obj;
}
private byte[] GetMyPdf()
{
using (var wk = _GetConverter())
{
wk.GlobalSettings.Margin.Top = "2cm";
wk.GlobalSettings.Margin.Bottom = "2cm";
wk.GlobalSettings.Margin.Left = "2cm";
wk.GlobalSettings.Margin.Right = "2cm";
wk.GlobalSettings.Size.PageSize = PdfPageSize.A4; //works
//wk.GlobalSettings.Size.Height= 40; // does not works
// wk.GlobalSettings.Size.Width=20; //does not works
wk.ObjectSettings.Web.EnablePlugins = false;
wk.ObjectSettings.Web.EnableJavascript = false;
using (var stream = new MemoryStream(ReadHtmlFromFile(@"C:\Projects\test.xhtml")))
using (var sr = new StreamReader(stream))
{
var str = sr.ReadToEnd();
var tmp = wk.Convert(str);
return tmp;
}
}
}
private byte[] ReadHtmlFromFile(string filePath)
{
using (FileStream fileStream = System.IO.File.OpenRead(filePath))
{
MemoryStream memStream = new MemoryStream();
memStream.SetLength(fileStream.Length);
fileStream.Read(memStream.GetBuffer(), 0, (int)fileStream.Length);
return memStream.ToArray();
}
}
My Controller:
public ActionResult GetMePDF()
{
var buffer = GetMyPdf();
return File(buffer, "application/pdf");
}
from wkhtmltoxsharp.
Can you try it from a simple console app?
Sent from my iPad
On 17/04/2012, at 14:34, Haroon
[email protected]
wrote:
I am running my code inside an asp.net mvc controller - the code is run on the default server from visual studio... I am not running an Async controller.
This works without using the Page Width or Page Height props... As soon as I use those two properties I get the exception...
private MultiplexingConverter _GetConverter() { var obj = new MultiplexingConverter(); //obj.Begin += (s, e) => _Log.DebugFormat("Conversion begin, phase count: {0}", e.Value); //obj.Error += (s, e) => _Log.Error(e.Value); //obj.Warning += (s, e) => _Log.Warn(e.Value); //obj.PhaseChanged += (s, e) => _Log.InfoFormat("PhaseChanged: {0} - {1}", e.Value, e.Value2); //obj.ProgressChanged += (s, e) => _Log.InfoFormat("ProgressChanged: {0} - {1}", e.Value, e.Value2); //obj.Finished += (s, e) => _Log.InfoFormat("Finished: {0}", e.Value ? "success" : "failed!"); return obj; } private byte[] GetMyPdf() { using (var wk = _GetConverter()) { wk.GlobalSettings.Margin.Top = "2cm"; wk.GlobalSettings.Margin.Bottom = "2cm"; wk.GlobalSettings.Margin.Left = "2cm"; wk.GlobalSettings.Margin.Right = "2cm"; wk.ObjectSettings.Web.EnablePlugins = false; wk.ObjectSettings.Web.EnableJavascript = false; using (var stream = new MemoryStream(ReadHtmlFromFile(@"C:\Projects\devnet\TemplateEditor\TemplateEditor\lib\test.xhtml"))) using (var sr = new StreamReader(stream)) { var str = sr.ReadToEnd(); var tmp = wk.Convert(str); return tmp; } } } private byte[] ReadHtmlFromFile(string filePath) { using (FileStream fileStream = System.IO.File.OpenRead(filePath)) { MemoryStream memStream = new MemoryStream(); memStream.SetLength(fileStream.Length); fileStream.Read(memStream.GetBuffer(), 0, (int)fileStream.Length); return memStream.ToArray(); } }
Reply to this email directly or view it on GitHub:
#6 (comment)
from wkhtmltoxsharp.
I just published a new version (1.2.5+) supporting PageSize properties (from a pull-req from @tomdenny), so I am closing this issue too.
from wkhtmltoxsharp.
Related Issues (20)
- Unable to load DLL 'wkhtmltox0' HOT 7
- WkHtmlToXSharp 1.2.9 nuget package missing HOT 4
- CallbackOnCollectedDelegate MDA HOT 1
- Maintenance status HOT 2
- Suport Custom Font HOT 4
- Getting intermittent error that shuts down app pool HOT 1
- Asp.net/IIS Support HOT 12
- My virus scanner found a virus in project files. HOT 4
- Question regarding usage of MultiplexingConverter HOT 2
- Observed difference in output between MultiplexerConverter and WkHtmlToPdfConverter HOT 2
- x64 bit support HOT 1
- ApartmentState.STA in .net core linux HOT 4
- Provide strong name signed versions of WkHtmlToXSharp.Win32.dll / WkHtmlToXSharp.Win64.dll HOT 1
- Upgrade to 0.12.5
- Not working on linux HOT 3
- System.BadImageFormatException thrown when disposing MultiplexingConverter...
- Error install the nuget package
- Could not load file or assembly `System.Configuration.ConfigurationManager`
- Multiple URLS into Multiple PDFS
- Upgrade to 0.12.6 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wkhtmltoxsharp.