EMF GDI hDC to vector PDF

247 views
Skip to first unread message

Mike Pisano

unread,
Sep 7, 2014, 11:10:28 AM9/7/14
to lib...@googlegroups.com
I have a bunch of base emf files that i play on a graphics surface then use gdi to merge text on the surface with drawstring to create a single page report forms. 
The graphics object is then or sent to the printer, or save as a png and then wrapped in a pdf. (iTextSharp)

I'm looking for a way to keep the pdf  vector based but cant find any open source ways of getting direct access to the dc to be able to draw a metafile image.

My current pdf's are around 800k per page, where if I print the same image to a pdf printer (amyuni) its 23k. The only product that i've found is PdfTron which creates a 200k vector based file, but is way too expensive and has way too many features.

Will the lib help, or does any of you graphics experts have any suggestions.

Thanks
Mike

Bill Horger

unread,
Sep 8, 2014, 10:40:25 AM9/8/14
to lib...@googlegroups.com
Mike,

Your message is no clear on what content the base emf files actually have, so it is difficult to recommend a solution. If I understand you correctly, you have an image that is based on vector drawing (in the base emf file) that you'd like to duplicate as vectors directly in a PDF and then place other objects on top of it (the report content?).

Using libharu to draw the underlying image is not difficult, and if you go back in the message board, you'll see a few examples (in "C"/"C++"). Depending on the complexity of your background, using libharu drawing commands will substantially reduce the size of the file.

Does this help? If not, perhaps you can post again, and give more details about what the content and process is that you are currently using.

Bill




--
--
---
libHaru.org development mailing list
To unsubscribe, send email to libharu-u...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "libHaru" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libharu+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Pisano

unread,
Sep 8, 2014, 9:46:35 PM9/8/14
to lib...@googlegroups.com
Bill,
The EMF are printer output from a forms design package. It makes it really easy to maintain complex forms and then merge text -  
Graphic.DrawImage(Image.FromFile("mawb.emf"));
Graphic.DrawText("bla bla bla");

I will take a look at the lib.

Thanks,
Mike

Mike Pisano

unread,
Sep 9, 2014, 10:13:06 AM9/9/14
to lib...@googlegroups.com
Bill, 
Ive played a little bit with the DLL and C#

1) seemsto be an internal issue with GetVerion() , because it crashes - commented it out

2) see no way to load Metadata? (ie)

            HPdfImage image = pdf.Load???ImageFromFile("mawb.emf");
            page.DrawImage(image, 0,0, 800,1100);


does this lib support playback of EMF?

Thanks Again,
Mike

Bill Horger

unread,
Sep 9, 2014, 10:42:06 AM9/9/14
to lib...@googlegroups.com

I don't know of any way to load  an EMF file.

--

Paul Gruzdev

unread,
Sep 11, 2014, 3:43:15 AM9/11/14
to lib...@googlegroups.com
Hi Mike,

What you actually need is a library (or Win32 EnumEnhMetaFile function) to enumerate the EMF and pass each vector drawing primitive (GDI call) as a PDF command to libharu to form the result PDF, setting up the page sizes and coordinates transform first. This is quite a substantial work from my standpoint, but I can't think of an easier solution, though some open source EMF->PDF converters may exist already.

Paul
Senior Software Developer
Xara Group Ltd
Reply all
Reply to author
Forward
0 new messages