EMF problems
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
-
- User
- Posts: 70
- Joined: Fri Oct 14, 2011 9:32 am
EMF problems
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
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
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 3550
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
Re: EMF problems
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.
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.
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.
-
- User
- Posts: 70
- Joined: Fri Oct 14, 2011 9:32 am
Re: EMF problems
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?
-
- Site Admin
- Posts: 17949
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
Re: EMF problems
Hello Yuri,
Yes a sample word document will definitely be better than no sample
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
Yes a sample word document will definitely be better than no sample
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
-
- User
- Posts: 70
- Joined: Fri Oct 14, 2011 9:32 am
Re: EMF problems
Here you are.
You do not have the required permissions to view the files attached to this post.
-
- User
- Posts: 70
- Joined: Fri Oct 14, 2011 9:32 am
Re: EMF problems
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
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
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 3550
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
Re: EMF problems
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:
I can do nothing with gradients, shadows, real transparency - in GDI mode this .emf is rendered without real gradients/transparency, shadows:
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.
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.
-
- User
- Posts: 70
- Joined: Fri Oct 14, 2011 9:32 am
Re: EMF problems
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.
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.
-
- Site Admin
- Posts: 3550
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
Re: EMF problems
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.
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.
-
- User
- Posts: 70
- Joined: Fri Oct 14, 2011 9:32 am
Re: EMF problems
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?
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?
-
- User
- Posts: 70
- Joined: Fri Oct 14, 2011 9:32 am
Re: EMF problems
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?
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?
-
- Site Admin
- Posts: 6902
- Joined: Wed Mar 25, 2009 10:37 pm
- Location: Chemainus, Canada
Re: EMF problems
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
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
Best regards
Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
-
- User
- Posts: 70
- Joined: Fri Oct 14, 2011 9:32 am
Re: EMF problems
Great, waiting for the technical issue unswer then. Please let me know about the fixing status.
-
- Site Admin
- Posts: 17949
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
Re: EMF problems
Hello Yury,
Ivan is working on this case, and we will certainly let you know when to expect the fix.
Best,
Stefan
Ivan is working on this case, and we will certainly let you know when to expect the fix.
Best,
Stefan
-
- Site Admin
- Posts: 17949
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
Re: EMF problems
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
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
-
- Site Admin
- Posts: 17949
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
Re: EMF problems
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
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