Closed raydk closed 12 years ago
Oops I didn't realise that the comment box supported HTML tags :D
I forgot to mention that the application hangs on this line on the second run.
byte[] pdfBuf = new SimplePechkin(new GlobalConfig()).Convert("Hello world!");
Hello, thank you!
It's strange, because I designed, coded and tested Pechkin to be able to run multiple times. Could you please provide details about OS on which you're running the test?
And also, in this repo there's project PechkinTestApp, could you please check, if it works for you? (You'll need to check out all the code and open the solution, for the project to be compiled correctly.)
Thanks for your fast reply.
I'm running Windows 7 Pro using Visual Web Developer 2010.
I also think it's strange that it just hangs without any error. At first I thought it was because the FileStream wasn't disposed or something like that,but later on I realised that it didn't reach to the writing part before it started to hang.
I will try to download the PechkinTestApp project and see if it causes same issues.
This test app really does just what you do, and it runs fine for me on Windows 7 Pro x64. Even with modification to use SimplePechkin.
So I need more details to reproduce the bug.
Also, you could try SynchronizedPechkin insted of Simple one, but within your one UI thread SimplePechkin is supposed to be fine.
In fact, if it's web app (and not WinForms, as I thought before), you should use SynchronizedPechkin, since for every request there's new thread in web apps.
Well the test app runs fine, also multiple times. Perhaps there are some difference because my application is a webapp.
Yeah, see comment above :)
Allright, I will try to use the SynchronizedPechkin, So what difference does it make if there's a new thread for every request? :)
The undelying library (WkHtmlToPDF) isn't thread friendly, everything inside it gets messed up, when you work with it from multiple threads.
It really happens to all the code written without threading in mind :)
So SynchronizedPechkin creates one thread to work with the library and tunnels all the calls to this thread. This way it keeps the lib safe.
I see, I didn't give that any thought before I jumped into the simple app. But you have saved me from a big headache because my application works now with the SynchronizedPechkin library! :D
Thank you very much for your help and keep up the good work! This library have saved me from a lot of trouble if I had to use iTextSharp or something similar.
Hi,
First of all, I would like to say that it's a very nice library you have created. Everything works fine, except for one thing. I have created a simple application where I try to write a PDF upon a button click. The first time the PDF is created fast and with no problem, but the application just hangs forever without any errors after postback when i try to click the button again. Do you have any idea what the problem could be?
This is my sample code:
protected void Button1Click(object sender, EventArgs e) { string targetFolderPath = String.Format("~/Resources/ProjectFiles/Project{0}/Letters/{1}/", SessionWrapper.Current.currentProjectID, LetterType); Response.Clear(); string pdfPath = String.Format(targetFolderPath + "/{0:yyyy-MM-dd_hh-mm-ss}helloworld.pdf",DateTime.Now); byte[] pdfBuf = new SimplePechkin(new GlobalConfig()).Convert("
Hello world!
"); ByteArrayToFile(@Server.MapPath(pdfPath), pdfBuf); }