|
Rank: Member Groups: Member
Joined: 11/8/2021 Posts: 21
|
Hi all, is it possible to save a pdf page to a png or better emf? There are various external tools that do this but I would like a single solution.
Thanks Kind regards
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,206
|
Hi, You do not need external tools for this. The key is this is a two steps process: Step 1. Use our library to render a PDF page to a System.Drawing.Image object; Step 2. Use built-in .NET function to save the System.Drawing.Image object to the format you wanted; For example, if you search "C# save Image to EMF" you may come up this which contains code on how to do step 2. https://stackoverflow.com/questions/152729/gdi-c-how-to-save-an-image-as-emfYou can do the search for png file. Thanks!
|
|
Rank: Member Groups: Member
Joined: 11/8/2021 Posts: 21
|
Thanks for the reply. I'm just starting to try out the PDF component and I didn't know the render object. For PNG, JPG, etc. it works but unfortunately in EMF I don't get an acceptable result (Huge files and not vector). Have you tried this solution? Can you include a native function for exporting pages to EMF? Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,206
|
Hi,
Unfortunately we do not have native support for EMF yet. It is technically possible because internally the rendering engine in fact does render to EMF format first, and then "flatten" it to bitmap format. However exposing this internal data structure would require signficant work. We will look into it to see if it is possible for us to add that feature.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 11/8/2021 Posts: 21
|
Thank you! For me it would be very important.
I hope it can be done Thanks again
|
|
Rank: Member Groups: Member
Joined: 11/8/2021 Posts: 21
|
I would add that I do not require the internal structure to be exposed. A function that allows a page to be saved directly to an eml file might also suffice.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,206
|
Yes. That's the goal.
|
|
Rank: Member Groups: Member
Joined: 11/8/2021 Posts: 21
|
Do you have any news? I would like to find out if it is possible to do this and in what timeframe so that I can give answers to my customers. Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,206
|
Hi,
We still have not full evaluated the scope of code changes needed yet. We should be able to give you a better picture on whether indeed it is possible and give you a more accurate time frame if we do proceed to implement in about two weeks.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 11/8/2021 Posts: 21
|
Ok Thanks
|
|
Rank: Member Groups: Member
Joined: 11/8/2021 Posts: 21
|
Sorry to ask again but, is there any news? Thanks! Kind regards
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,206
|
Hi,
Sorry about the delay. We are still working on this. We have implemented a PdfRender.RenderToEMF method internally but our internal test indicates some problems. It can not be released until we resolve those issues.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,206
|
Hi, We have posted the new build. Please download it from our download page and take a look. This build added this method: https://www.essentialobjects.com/doc/eo.pdf.pdfrender.renderasemf.htmlIt returns a byte array which you can save directly into a file with ".emf" extension and it will be a valid emf file. Thanks!
|
|
Rank: Member Groups: Member
Joined: 11/8/2021 Posts: 21
|
Great!!! I'll try as soon as possible.
Thank you very much
|
|
Rank: Member Groups: Member
Joined: 11/8/2021 Posts: 21
|
I have just done a test but it does not seem to work well because the result I think is not actually a vector. The size of a page rendered on file, without images, is also several MB and this is very strange. Vector files should be much smaller in size. If I open the file by zooming in, the text is grainy.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,206
|
Hi, The result is vector. You can verify that by using a third party EMF file viewer, or you can examine the record in the file with this method with code: https://learn.microsoft.com/en-us/dotnet/api/system.drawing.graphics.enumeratemetafileThe reason that the file is large has to do with how text is rendered. EMF file was initially designed for printer that only understand simple drawing commands (such as moveTo, lineTo, drawArc, etc). As a result, even for simple text output like "abc", it will result in the EMF file containing every drawing commands that any printer can use to reproduce these three letters without using any font data. Thanks
|
|
Rank: Member Groups: Member
Joined: 11/8/2021 Posts: 21
|
The file is probably in EMFPlus format and my application, with its own print preview, does not support it correctly. The images are grainy. Apologies :-), would it also be possible to save in WMF format and/or in EMF (Non PLUS)?
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,206
|
Hi,
Unfortunately no. It is not possible to create WMF format because WMF was designed for 16 bit application and it does not record many newer advanced drawing instructions. So the output would not be complete and the result in WMF format would cause missing parts in the output.
We will look into the grainy issue and see if we can find any additional information about it.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 11/8/2021 Posts: 21
|
Thanks!
|
|