|
Rank: Newbie Groups: Member
Joined: 8/31/2011 Posts: 8
|
I am using html 2 pdf on visual studio 2010 .net framework 4.0. In test enviroment, everything works fine but when i deploy application on production server error occures. Production machine is Windows Server 2008 64 bit, IIS 7 and TEST machine is Windows 7 64 bit on ASP DEVELOPMENT SERVER. Error, that occures, says: COULD`T FIND PART OF THE FILE "C:\TEMP\DOCUMENT.PDF". And that is it. End document is not created. I put in Security tab on TEMP folder EVERYONE FULL CONTROL. What is a problem?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
That error message appears to be from your code, not from us. You may want to check your code that displays the error message and see if you can find out why. Obviously we cannot tell you exactly why when it's not from our code.
If you are writing a file, you will not want to use a fixed file name on a Web server. A Web server serves multiple users at the same time, so it's possible that while your code is writing the file for one user, another user comes to visit your website and trigger the same code. That will run into problems because the file is still locked at that moment.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 8/31/2011 Posts: 8
|
Thanx for your fast answer. Below you can see the error from custom log file that control returns. Try/Catch block that i used is like this
public static void CreatePdfFile(Url url, string pdfFileName) { try { EO.Pdf.HtmlToPdfOptions options = new EO.Pdf.HtmlToPdfOptions();
options.PageSize = EO.Pdf.PdfPageSizes.A4; options.OutputArea = new System.Drawing.RectangleF(0.5f, 0.5f, 7.26771f, 10.6929f); options.ZoomLevel = 0.7f;
EO.Pdf.HtmlToPdf.ConvertUrl(url.Value, pdfFileName, options); } catch (EO.Pdf.HtmlToPdfException ex) { Logger.Log.Error("EOHTMLToPDF.CreatePdfFile has failed", ex); } }
:
System.IO.FileNotFoundException: Could not find file 'C:\Inetpub\wwwroot\JBSObuka\Temp\StampaResenja.pdf'. File name: 'C:\Inetpub\wwwroot\JBSObuka\Temp\StampaResenja.pdf' at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at System.Web.HttpResponse.TransmitFile(String filename, Int64 offset, Int64 length) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass14.<InvokeActionResultWithFilters>b__11() at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) 2011-09-06 10:25:44,906 [6] ERROR JBS.Shared (null) [(null)] - EOHTMLToPDF.CreatePdfFile has failed EO.Pdf.HtmlToPdfException: Failed to initialize conversion. at EO.Pdf.HtmlToPdfException.b(Exception A_0) at EO.Pdf.Internal.j1.h() at EO.Pdf.HtmlToPdf.a(j1 A_0) at EO.Pdf.HtmlToPdf.ConvertHtml(String html, String pdfFileName, HtmlToPdfOptions options) at JBS.Reporting.EOHTMLToPDF.CreatePdfFile(PrintAttribute print, String html) 2011-09-06 10:25:44,906 [6] ERROR JBS.Shared (null)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, This is a permission issue. Try to create the output file into memory and then save the file yourself:
Code: C#
//Convert into PDF document
PdfDocument doc = new PdfDocument();
EO.Pdf.HtmlToPdf.ConvertUrl(url.Value, doc, options);
//Save the result into a MemoryStream object
MemoryStream ms = new MemoryStream();
doc.Save(ms);
//Now you have the PDF file contents in bytes. Save this
//into whatever file you wish to save. If you run into problem
//on this step, then it's your permission issue
byte[] pdfFileData = ms.ToArray();
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 8/31/2011 Posts: 8
|
Hi again,
i have done exactly from code from up but i am getting a following error:
EOHTMLToPDF.CreatePdfFile has failed EO.Pdf.HtmlToPdfException: Can not find file 'c:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\4c62cbca\7638a3b0\assembly\dl3\d8e4110d\9011b3d5_6e6ccc01\EO.Pdf.Html.dll', this file is needed to perform HTML to PDF conversion. Please make sure this file exists in the same directory as EO.Pdf.dll. For example, for an ASP.NET application, both EO.Pdf.dll and EO.Pdf.Html.dll should be in your application’s bin directory. at EO.Pdf.HtmlToPdfException.b(Exception A_0) at EO.Pdf.Internal.j1.h() at EO.Pdf.HtmlToPdf.a(j1 A_0) at JBS.Reporting.EOHTMLToPDF.CreatePdfFile(PrintAttribute print, String html) 2011-09-06 14:59:17,579 [8] ERROR JBS.Shared (null) [(null)] - EOHTMLToPDF.CreatePdfFile has failed EO.Pdf.HtmlToPdfException: The type initializer for 'a' threw an exception. at EO.Pdf.HtmlToPdfException.b(Exception A_0) at EO.Pdf.Internal.j1.h() at EO.Pdf.HtmlToPdf.a(j1 A_0) at JBS.Reporting.EOHTMLToPDF.CreatePdfFile(PrintAttribute print, String html) 2011-09-06 15:00:11,688 [7] ERROR JBS.Shared (null) [(null)] - EOHTMLToPDF.CreatePdfFile has failed EO.Pdf.HtmlToPdfException: The type initializer for 'a' threw an exception. at EO.Pdf.HtmlToPdfException.b(Exception A_0) at EO.Pdf.Internal.j1.h() at EO.Pdf.HtmlToPdf.a(j1 A_0) at JBS.Reporting.EOHTMLToPDF.CreatePdfFile(PrintAttribute print, String html)
To mention again: it is windows server 2003 64-bit on IIS6.
|
|
Rank: Newbie Groups: Member
Joined: 8/31/2011 Posts: 8
|
Sorry error above is fixed by putting EO.PDF.Html.dll in bin folder. Now i am getting a following error:
2011-09-06 15:00:11,688 [7] ERROR JBS.Shared (null) [(null)] - EOHTMLToPDF.CreatePdfFile has failed EO.Pdf.HtmlToPdfException: The type initializer for 'a' threw an exception. at EO.Pdf.HtmlToPdfException.b(Exception A_0) at EO.Pdf.Internal.j1.h() at EO.Pdf.HtmlToPdf.a(j1 A_0) at JBS.Reporting.EOHTMLToPDF.CreatePdfFile(PrintAttribute print, String html)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
We have posted a new build (build 3.0.66.2) for you that will help you to troubleshoot this problem (please see your private message for the download location). The new build will not fix the problem, but should give you a more specific error message. Please switch to the new build and post the new error message.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 8/31/2011 Posts: 8
|
Hi, i installed new version and now is muck clearer situation. Following erro has occured:
2011-09-07 11:47:00,824 [11] ERROR JBS.Shared (null) [(null)] - ---------------- UNHANDLED ERROR IN JBS CONTROLLER ------------------------------------ System.TypeInitializationException: The type initializer for 'a' threw an exception. ---> System.UnauthorizedAccessException: Access to the path 'C:\WINDOWS\TEMP\eods' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj) at System.IO.Directory.CreateDirectory(String path) at EO.Pdf.Internal.gs.a..ctor() at EO.Pdf.Internal.gs.a..cctor() --- End of inner exception stack trace --- at EO.Pdf.Internal.gs.a.c() at EO.Pdf.Internal.gs..ctor(Byte[] A_0) at EO.Pdf.Internal.go.b(Byte[] A_0) at EO.Pdf.Internal.go.d(Byte[] A_0) at EO.Pdf.Drawing.PdfImage.a(Int32 A_0, Int32 A_1, Boolean A_2, Boolean A_3) at EO.Pdf.Drawing.PdfImage.a(Boolean A_0) at EO.Pdf.Drawing.PdfImage..ctor(Image A_0, Byte A_1, Boolean A_2, Int32 A_3, Boolean A_4) at EO.Pdf.Internal.et.a(ft A_0) at EO.Pdf.Internal.et.b() at EO.Pdf.Internal.et..ctor(j2 A_0, Boolean A_1, Int32 A_2, i9 A_3, Int32 A_4, Single A_5, Rectangle A_6, PdfPage A_7, f4 A_8) at EO.Pdf.Internal.j2.a(PdfPage A_0, Boolean A_1, Int32 A_2, Rectangle A_3, i9 A_4, f4 A_5) at EO.Pdf.Internal.j2.a(Int32 A_0, HtmlToPdfResult A_1) at EO.Pdf.Internal.j2.h() at EO.Pdf.HtmlToPdf.a(j2 A_0) at JBS.Reporting.EOHTMLToPDF.CreatePdfFile(PrintAttribute print, String html) at JBS.Reporting.DocumentGenerator.MakePdfForHtml(PrintAttribute print, String html) at JBS.WebUI.Controllers.PdfController.Create(String realController, String realAction, Int32 id) at System.Web.Mvc.ActionMethodDispatcher.<>c__DisplayClass1.<WrapVoidAction>b__0(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
System is trying to make "C:\WINDOWS\TEMP\eods" folder. I put EVERYONE FULL CONTROL on that folder (TEMP) and the error still occures. After that i have manualy created EODS folder in TEMP and also set FULL CONTROL to EVERYONE and didnt help. What i should do?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Thank you very much for the additional information. That appears to be a combination of two problems. One of the problems appears to be a bug on our side and we should be able to fix it for you.
The first problem is a permission problem on your system. We do not know why your application does not have the permission to create a folder inside the temp folder. Obviously we have no control over Windows's permission system. So if Windows does not allow us to create that folder, then our code will fail. You can try to call Directory.CreateDirectory in your own app to create that folder and see if it works.
The second problem looks like a bug on our side. By default, the converter should NOT create temp file UNLESS you are running low on memory (for example, when you have a lot of images). So for most conversions, the converter should not even try to create that directory. That part is broken because obviously it’s creating the temp folder regardless. We will fix that and provide you an update build today.
Thank you very much for your patience and help!
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 8/31/2011 Posts: 8
|
Ok but why don`t you make one property more to explicitly specify temp folder path? And if it is NULL or EMPTY then try make it in windows/temp?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, That's a good idea. In the mean time if you wish to change the temp path, you can change the temp file path through environment variable or user profile. We call Path.GetTempPath to get the temp file path, which is controlled by environment varialbe: MS Path.GetTempPath Doc wrote:This method checks for the existence of environment variables in the following order and uses the first path found:
1. The path specified by the TMP environment variable.
2. The path specified by the TEMP environment variable.
3. The path specified by the USERPROFILE environment variable.
4. The Windows directory. Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
We have posted a new build (2011.2.67) that should fix the temp file issue. The new build will not write temp file unless you are low on memory or the file you are trying to convert has more than 30 pages. Please download the new build from our download page and let us know whether it resolves the issue for you.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 8/31/2011 Posts: 8
|
Thank you very much!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
You are welcome. Did it work for you?
|
|
Rank: Newbie Groups: Member
Joined: 8/31/2011 Posts: 8
|
Sorry, work time finished. I`ll try it tomorow. Thanx for your interest.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Ah....I see....enjoy your evening. : )
|
|