Welcome Guest Search | Active Topics | Sign In | Register

PDF Page To Png or EMF Options
Lionello Giampaolo PROMETEO SRL
Posted: Tuesday, March 7, 2023 5:41:41 AM
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
eo_support
Posted: Tuesday, March 7, 2023 12:47:17 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
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-emf

You can do the search for png file.

Thanks!
Lionello Giampaolo PROMETEO SRL
Posted: Friday, March 10, 2023 10:03:23 AM
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
eo_support
Posted: Friday, March 10, 2023 11:17:33 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
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!
Lionello Giampaolo PROMETEO SRL
Posted: Friday, March 10, 2023 11:24:41 AM
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
Lionello Giampaolo PROMETEO SRL
Posted: Tuesday, March 14, 2023 11:36:14 AM
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.
eo_support
Posted: Tuesday, March 14, 2023 11:39:48 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Yes. That's the goal.
Lionello Giampaolo PROMETEO SRL
Posted: Wednesday, March 22, 2023 6:40:30 AM
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
eo_support
Posted: Thursday, March 23, 2023 10:16:10 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
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!
Lionello Giampaolo PROMETEO SRL
Posted: Thursday, March 23, 2023 10:17:34 AM
Rank: Member
Groups: Member

Joined: 11/8/2021
Posts: 21
Ok
Thanks
Lionello Giampaolo PROMETEO SRL
Posted: Thursday, April 13, 2023 8:40:17 AM
Rank: Member
Groups: Member

Joined: 11/8/2021
Posts: 21
Sorry to ask again but, is there any news?
Thanks!
Kind regards
eo_support
Posted: Friday, April 14, 2023 2:21:57 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
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!
eo_support
Posted: Tuesday, April 18, 2023 10:36:10 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
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.html

It returns a byte array which you can save directly into a file with ".emf" extension and it will be a valid emf file.

Thanks!
Lionello Giampaolo PROMETEO SRL
Posted: Tuesday, April 18, 2023 11:07:28 AM
Rank: Member
Groups: Member

Joined: 11/8/2021
Posts: 21
Great!!!
I'll try as soon as possible.

Thank you very much
Lionello Giampaolo PROMETEO SRL
Posted: Tuesday, April 18, 2023 1:21:35 PM
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!
eo_support
Posted: Tuesday, April 18, 2023 1:35:53 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
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.enumeratemetafile

The 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
Lionello Giampaolo PROMETEO SRL
Posted: Wednesday, April 19, 2023 3:41:13 AM
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!
eo_support
Posted: Wednesday, April 19, 2023 10:45:47 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
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!
Lionello Giampaolo PROMETEO SRL
Posted: Wednesday, April 19, 2023 11:29:42 AM
Rank: Member
Groups: Member

Joined: 11/8/2021
Posts: 21
Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.