EMF problems

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan

Post Reply
Yury
User
Posts: 70
Joined: Fri Oct 14, 2011 9:32 am

EMF problems

Post by Yury » Fri Oct 14, 2011 10:22 am

Hi, I'm trying to use PDF Tools 4 SDK to generate PDF files programmatically.

I use PXC_AddEnhMetafile to add EMF image on to the page. ( C++ unmanaged , MS Visual C++ 2010).
EMF (HENHMETAFILE) is generated with GDI+.

Picture was added successfully, however it's displayed wrong. I noticed that colors with transparency are displayed as garbage.
See attached resulted pdf and original image.

Am I doing something wrong, or this is bug in your library. Any fix soon?

Best regards,
Yury
Attachments
Original Image.pdf
(51.26 KiB) Downloaded 156 times
result.pdf
(87.01 KiB) Downloaded 164 times

Ivan - Tracker Software
Site Admin
Posts: 3607
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: EMF problems

Post by Ivan - Tracker Software » Fri Oct 14, 2011 10:39 am

Can you provide your .emf file?

PDF-XChange doesn't use GDI+ for handling EMF files, and most GDI+ generated files contain their data in private structures inside an EMF_GDIComment record in the EMF file, which is undocumented.
So, I'm not sure we will be able to reproduce the file correctly - depends what information is available outside of private structures.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.

Yury
User
Posts: 70
Joined: Fri Oct 14, 2011 9:32 am

Re: EMF problems

Post by Yury » Fri Oct 14, 2011 2:05 pm

I don't know how to save this emf.... ( GDI+ does not support saving to EMF. ) MAy be I'll just post you the MS Word file with the embedded picture?

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13428
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: EMF problems

Post by Tracker Supp-Stefan » Fri Oct 14, 2011 2:38 pm

Hello Yuri,

Yes a sample word document will definitely be better than no sample :D
Please do archive it before attaching to this topic, as the forum only allows archive formats (.zip/.rar/.7z) and pdf as kinds of attachments.

Best,
Stefan

Yury
User
Posts: 70
Joined: Fri Oct 14, 2011 9:32 am

Re: EMF problems

Post by Yury » Fri Oct 14, 2011 3:04 pm

Here you are.
Attachments
Doc1.zip
(206.1 KiB) Downloaded 143 times

Yury
User
Posts: 70
Joined: Fri Oct 14, 2011 9:32 am

Re: EMF problems

Post by Yury » Fri Oct 14, 2011 3:14 pm

More simple way to reproduce....

Use code below:

using namespace Gdiplus;
using namespace Streams;
HDC hdc( ::GetDC( 0 ) );

IMemoryStreamPtr _pImageStream( new CMemoryStream(), false );
Image* _pImage( new Metafile( _pImageStream, hdc ) );
Graphics* gr =new Graphics( _pImage );

gr->SetPageUnit( UnitPixel );
gr->SetTextRenderingHint( TextRenderingHintAntiAliasGridFit );
Color color( 0xAAFF0000 );
SolidBrush brush( color );
Rect rcBound(0,0,100,100);
Region rgnClip( rcBound );
gr->SetClip( &rgnClip );
Pen pen( &brush, 1);
gr->DrawRectangle( &pen,rcBound);
gr->FillRectangle( &brush,rcBound);

delete gr;

HENHMETAFILE hEnhMetaFile( ((Metafile*)_pImage)->GetHENHMETAFILE() );
_pImage->GetBounds( &rcFullBound, &unit );

m_hLastError = PXC_AddEnhMetafile(m_pDoc, hEnhMetaFile, &image);


Then, use PXC_PlaceImage somehow.

This will produce PDF like attached
Attachments
result.pdf
(9.22 KiB) Downloaded 162 times

Ivan - Tracker Software
Site Admin
Posts: 3607
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: EMF problems

Post by Ivan - Tracker Software » Fri Oct 14, 2011 4:40 pm

I can try to fix some issues (with transparency and with size of patterns (but please note, patterns in PDFs depend on the zoom level, while not in an EMF file)).
I can do nothing with gradients, shadows, real transparency - in GDI mode this .emf is rendered without real gradients/transparency, shadows:

Image
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.

Yury
User
Posts: 70
Joined: Fri Oct 14, 2011 9:32 am

Re: EMF problems

Post by Yury » Mon Oct 17, 2011 8:34 am

Is it possible to have options on how to render transparent color?

1. Alpha blended ( preffered ). ( This would be a color, which is combination of the given color and background color )
2. No transparency. ( just omit alpha chanel byte)
3. default - this is what I see on your screen shot.

Ivan - Tracker Software
Site Admin
Posts: 3607
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: EMF problems

Post by Ivan - Tracker Software » Mon Oct 17, 2011 1:51 pm

I'm afraid not - into this EMF there are no information that transparency is used - instead of that, the rectangle is filled with pattern brush, or image is rendered.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.

Yury
User
Posts: 70
Joined: Fri Oct 14, 2011 9:32 am

Re: EMF problems

Post by Yury » Mon Oct 17, 2011 2:32 pm

Hi Ivan, not sure I understand what is possible to fix then....

At the moment I'm interested in displaying transparency as close to the original as possible. ( let's put patterns of for a while ).

The code which produces HENHMETAFILE is

Color color( 0xAAFF0000 );
SolidBrush brush( color );
Rect rcBound(0,0,100,100);
gr->FillRectangle( &brush,rcBound);
delete gr;
HENHMETAFILE hEnhMetaFile( ((Metafile*)_pImage)->GetHENHMETAFILE() );

As far as I understand, this HENHMETAFILE contains the correct colors. ( with transparency )
When you converting this HENHMETAFILE into the metafile, which is supported by PDF, is it possible to use colors without the transparency byte, or blened?

Yury
User
Posts: 70
Joined: Fri Oct 14, 2011 9:32 am

Re: EMF problems

Post by Yury » Tue Oct 18, 2011 1:55 pm

I guess I understand now why it is not possible to fix as I asked....

I enumerated EMF records in the sample above ( just simple red rectangle in hMetafile ) .
The first test is with transparent color, the second one is without one.

I got absolutely different set of EMF records. In case of transparency I could see records like EMR_BITBLT, EMR_CREATEDIBPATTERNBRUSHPT, etc.

So... sorry, and please fix as you mentioned early.

Also one question about licensing...
does my license for one user entitle me to include library in our commercial application for all of our customers? are there any restrictions?

User avatar
Paul - Tracker Supp
Site Admin
Posts: 4935
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada
Contact:

Re: EMF problems

Post by Paul - Tracker Supp » Tue Oct 18, 2011 4:45 pm

Hi Yury,

regards your licensing question. Your PDF-Tools SDK entitles you to install the SDK on a single machine and distribute your application to 100,000 desktop installs.

hth
_________________
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com

Yury
User
Posts: 70
Joined: Fri Oct 14, 2011 9:32 am

Re: EMF problems

Post by Yury » Wed Oct 19, 2011 12:28 pm

Great, waiting for the technical issue unswer then. Please let me know about the fixing status.

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13428
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: EMF problems

Post by Tracker Supp-Stefan » Wed Oct 19, 2011 1:26 pm

Hello Yury,

Ivan is working on this case, and we will certainly let you know when to expect the fix.

Best,
Stefan

Yury
User
Posts: 70
Joined: Fri Oct 14, 2011 9:32 am

Re: EMF problems

Post by Yury » Wed Oct 19, 2011 1:31 pm

Excellent! Thank you.

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13428
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: EMF problems

Post by Tracker Supp-Stefan » Thu Oct 20, 2011 2:26 pm

Hello Yury

After checking this with the devs, we have created a ticket in our internal system:
#1304: Tools SDK: Increase pattern step size for EMF files
So that we can track and fix this case as discussed.

We will update you both via e-mail and here in this topic when there are any news on the subject.

Best,
Stefan

Yury
User
Posts: 70
Joined: Fri Oct 14, 2011 9:32 am

Re: EMF problems

Post by Yury » Mon Nov 21, 2011 9:19 am

Hello, any news?

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13428
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: EMF problems

Post by Tracker Supp-Stefan » Mon Nov 21, 2011 11:46 am

Hello Yury,

A work item was created for this case, but I am afraid that there hasn't been any other news in the ticket.
I will now ask for a status update.

Best,
Stefan

Post Reply