|
Rank: Member Groups: Member
Joined: 8/17/2012 Posts: 22
|
Hi I have been upgrading to the new 2016 version of EO.Pdf. Initially, there were a lot of runtime exceptions when running code that worked perfectly under 2015. However, the latest version (2016.0.17.0) seems to have overcome these runtime exceptions, but inline images are no longer embedded (just a missing-image icon), and paragraphs are being split mid-line vertically (ie through the characters) across page breaks (even though they were perfectly split between lines in 2015). If I link the images via internet addresses rather than local-file addresses, the images will be properly embedded. If I prime the process with HtmlToPdf.UseClassicEngine(), then the whole problem goes away ... but that means that I am using the old engine and potentially missing out on improvements. Is there some new setting that I am missing? It works fine in 2015. Thanks Todd broken: broken lineunbroken: unbroken lineQuote:// ... Preliminary code ...: HtmlToPdf.UseClassicEngine();
// Create the PDF document: pdfDocument = new PdfDocument();
// Create the options: htmlToPdfOptions = new HtmlToPdfOptions(); // Set the base URL: htmlToPdfOptions.BaseUrl = baseFolderAddress;
// Prevent the document from being edited: pdfDocument.Security.Disallow(PdfDocumentPermissions.ModifyingContents); pdfDocument.Security.Disallow(PdfDocumentPermissions.AssembingDocument); pdfDocument.Security.OwnerPassword = "...";
// Set the page header: htmlToPdfOptions.HeaderHtmlFormat = "";
// Set the page footer: htmlToPdfOptions.FooterHtmlFormat = "<div style='font-family:Arial; font-size:10px; text-align:center;'>Page {page_number} of {total_pages}</div>";
// Prevent the conversion of images to JPEG: htmlToPdfOptions.SaveImageAsJpeg = false;
// Prevent the unnecessary generation of page images: htmlToPdfOptions.GeneratePageImages = false;
// Set the section options: htmlToPdfOptions.PageSize = PdfPageSizes.A4; marginLeft = 2.0F / 2.54F; marginTop = 1.5F / 2.54F; marginRight = 2.0F / 2.54F; marginBottom = 1.5F / 2.54F; htmlToPdfOptions.OutputArea = new RectangleF( marginLeft, marginTop, htmlToPdfOptions.PageSize.Width - marginLeft - marginRight, htmlToPdfOptions.PageSize.Height - marginTop - marginBottom );
// Generate the PDF document: HtmlToPdf.ConvertHtml(htmlStringRaw, pdfDocument, htmlToPdfOptions);
// Save the PDF document: pdfDocument.Save(targetFileAddress);
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Thanks for the information. We are looking into this and will get back to you as soon as possible.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Please download build 2016.0.21.0 from our download page. This build fixed this issue.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 8/17/2012 Posts: 22
|
Hi I have just downloaded and rebuilt my application twice: once using HtmlToPdf.UseClassicEngine() and once without. I can confirm that the page is no longer breaking through a line at page break, but both engines now have issues. This is all with no change in the code that I have already quoted. 1. The page size is now broken for the new engine. The page size should be A4, but now it is something odd: 34.991 x 49.489 cm. link2. The right margin is now broken for both engines. This may be related the the issue above. The right margin is almost half the page. new engine screenshotold engine screenshot3. The new engine is still not embedding locally-sourced images. I can email you some test PDFs if you need them, but I can't link them here because they contain sensitive details. I can't give you a link to a live project either because of security issues I can't get around right now. When I try to generate generic documents from the EO.Total desktop installation (EOPdfDemo), I get errors like this: Quote:Page Layout
Access to the path 'C:\Program Files (x86)\Essential Objects\EO.Total 2016\Output\Html to PDF.Basic.PageLayout.pdf' is denied. Exception:
System.UnauthorizedAccessException: Access to the path 'C:\Program Files (x86)\Essential Objects\EO.Total 2016\Output\Html to PDF.Basic.PageLayout.pdf' is denied. at EOPDFDemo.Program.OnException(Object sender, ThreadExceptionEventArgs e) at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t) at System.Windows.Forms.Timer.TimerNativeWindow.OnThreadException(Exception e) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Form.ShowDialog(IWin32Window owner) at EOPDFDemo.MainForm.RunDemo I'm not having a great day with this :-(
|
|
Rank: Member Groups: Member
Joined: 8/17/2012 Posts: 22
|
I have just checked the change log for EO.Total 2016.0.21 and this seems to resolve the margin issue and the page-size issue for both engines. Quote:Changed the default zoom level for the HTML to PDF converter from 1 to 0.6 However, this is still an odd inconsistency between the two engines when the new default zoom of 60% is used: with Classic the page remains A4 and with the new engine the page size blows out. Setting the zoom level back to 100% does not resolve the issue of local files not embedding.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
I apologize for the problems. Please download build 16.0.24.0 from our download page. This build fixed the page size issue. We have also verified that the margin works fine in both the old and new engine. As to other issues:
1. The exception issue when you run demo application. This is due to the fact that the demo application tries to write the result PDF file but it does not have sufficient permission to do so. The PDF conversion has completed correctly in this case, but it is unable to write the result as a file to disk. To resolve this issue, you can simply try to run the demo application as Administrator, or to assign write permission to the Output folder in your installation folder;
2. Embed local resource. This is a known security restriction when you use ConvertHtml. The Chromium browser treats an HTML as from the Internet zone thus forbids it from accessing files from your local computer. We can turn this off but we are still trying to evaluate the security implication of this. If our evaluation does not reveal any problems, then this will be turned off in our next build.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 8/17/2012 Posts: 22
|
Hi
I confirm that the page-size issue has gone away.
I'll continue to use the classic engine until the local resource issue has been resolved.
Many thanks
|
|
Rank: Newbie Groups: Member
Joined: 3/17/2016 Posts: 6
|
Hi,
I ran into some issues as well with the latest EO.PDF (16.0.24.0):
- it won't load html files anymore when using HtmlToPdf.ConvertUrl. The example from the documentation EO.Pdf.HtmlToPdf.ConvertUrl("c:\\test.html", "c:\\result.pdf"); did not work in version 16.0.21.0, but that could be fixed by using "file:///c:/test.html". In the latest version, that does also not work anymore, so you can't load anything from the file system apparently, including graphics.
- box shadow doesn't work. Instead of a soft drop shadow it generates a hard, square shadow.
On the other hand, 2016 does render some of my svg graphics that 2015 refused to render, so hopefully the issues mentioned above can be fixed quickly!
|
|
Rank: Member Groups: Member
Joined: 8/17/2012 Posts: 22
|
Hi
I can confirm that EO.Total 2016.0.28 has resolved all of the issues that I have posted here.
Thanks for your help.
Todd
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
poseidonCore wrote:Hi
I can confirm that EO.Total 2016.0.28 has resolved all of the issues that I have posted here.
Thanks for your help.
Todd Thank you very much for confirming the fix!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Herbert L. wrote:Hi,
I ran into some issues as well with the latest EO.PDF (16.0.24.0):
- it won't load html files anymore when using HtmlToPdf.ConvertUrl. The example from the documentation EO.Pdf.HtmlToPdf.ConvertUrl("c:\\test.html", "c:\\result.pdf"); did not work in version 16.0.21.0, but that could be fixed by using "file:///c:/test.html". In the latest version, that does also not work anymore, so you can't load anything from the file system apparently, including graphics.
- box shadow doesn't work. Instead of a soft drop shadow it generates a hard, square shadow.
On the other hand, 2016 does render some of my svg graphics that 2015 refused to render, so hopefully the issues mentioned above can be fixed quickly!
Hi, Please download 2016.0.28.0 from our download page. This build fixed ConvertUrl with file name issue. Box shadow is a known limitation of the new engine. The root of the problem is PDF does not have native support for such effects. As such the old engine actually rasterized the whole region in order to produce the box shadow effects. This causes serious quality issues when the page is being zoomed or printed. The new engine does not do this any more --- instead it just hand it over to the GPU when rendering on the screen. Since GPU is not involved when rendering to PDF, it is unable render such effects in PDF. As a compromise it replaces it with sold color shadow. Another known limitation falls into this category is text shadow, which doesn't work either. On the other hand, the new engine can render a lot of other things better, this includes many CSS 3 attributes and particular SVG. So if you use SVG graphics a lot, it would definitely benefit from the new engine. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/17/2016 Posts: 6
|
Hi, Thanks for resolving the ConvertUrl() issue this quickly! About the box shadow: yes, using the 2015 EO.PDF version I noticed that a shadow generated on top of another image caused the underlying image to be a bit blurry in the area where shadow and image mix. Thanks for explaining why it doesn't work anymore. And from your answer, ít is clear to me that this will not be fixed, unless it's fixed in the underlying engine. However I have found a workaround. The engine does support svg and the filters that come with it. In my case, I need a shadow under a div, so I generate an svg filter on the fly that will generate the shadow, using the following javascript function:
Code:
function AddShadow(elmId) { var elm = document.getElementById(elmId); if (elm == null) return;
//get the location and dimensions of the element and build the svg shadow var dim = elm.getBoundingClientRect(); var svg = '<svg width="' + (dim.width + 20) + 'px" height="' + (dim.height + 20) + 'px"> '; svg += ' <filter id="dropShadow" x="-50%" y="-50%" width="200%" height="200%">
'; svg += ' <feGaussianBlur in="SourceGraphic" stdDeviation="5"/> '; svg += ' </filter> '; svg += ' <rect x="10px" y="10px" width="' + dim.width + 'px" height="' + dim.height + 'px" fill="rgba(1,1,1,0.4)" filter="url(#dropShadow)"/> '; var shadow = document.createElement('div'); shadow.style.position = 'absolute'; shadow.style.top = (dim.top - 10) + 'px'; shadow.style.left = (dim.left - 10) + 'px'; shadow.style.zIndex = -1; shadow.innerHTML = svg; elm.parentElement.insertBefore(shadow, elm); }
This may not be a generic solution (the position trait of the element must be 'relative' or 'absolute') and no doubt it can be improved, but it does what I need it to do and the results are really very good, in fact better than the results with the old engine. Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Excellent. Thank you very much for sharing!
|
|
Rank: Newbie Groups: Member
Joined: 3/17/2016 Posts: 6
|
Hi,
Since the last update (2016.0.78.0), the shadows generated using the SVG code I shared earlier, do not work anymore. When a shadow is on top of an image, it used to blend in nicely. That does not work anymore. Instead, the shadow is generated on a white background, giving a wide white border around the object with the shadow. Looks like transparency is lost here.
Can you have a look at this please?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Please try to set HtmlToPdf.Options.SaveImageAsJpeg to false and see if that works.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/17/2016 Posts: 6
|
That works! Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Please download build .84 from our download page and see if it works with SaveImageAsJpeg as true (the default value). We fixed an alpha channel issue in this build.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/17/2016 Posts: 6
|
Installed build .84 and tested it -- It works!
Behavior is now the same as again as before build .80, so not setting property SaveImageAsJPeg or setting it to true yields the same (correct) result.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Great. Thanks for confirming the fix!
|
|