Line style in EMF

A forum for questions or concerns related to the PDF-XChange Core API SDK

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

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
Yury
User
Posts: 70
Joined: Fri Oct 14, 2011 9:32 am

Line style in EMF

Post by Yury » Tue Jul 18, 2017 11:04 am

Hello, we are using Core API SDK to generate the PDF with the embedded EMF file.
This way EMF is placed to PDF output using the code like this:

Code: Select all

HRESULT PDFXBuilder::PlaceMetafile(PageItem* pageItem,  HENHMETAFILE hMeta, const PXC::PXC_Rect& rc)
{
   HRESULT hr = S_OK;
  try
  {
   CComPtr<PXC::IPXC_XForm> pXForm;
   hr = m_pCoreDoc->ConvertMetafile((PXC::HANDLE_T)hMeta, 0, nullptr, &pXForm);
   if (FAILED(hr))
      return hr;
   return PlaceXForm(pageItem, pXForm, rc);
  }
  catch( ... )
  {
	  return -1;
  }   
}
This works. And I already contacted you about this. However this works only for 90%.
We have issue, which we really need to get rid of.
DASH and DOT styled lines are not displayed ( parsed ) properly.
I remember we discussed that GDI+ EMF format is hard to support. However, we switched to plain GDI to draw lines properly, but still have bad results.
I'm attaching the resulted PDF & EMF. Code, which draws the dash line looks as this:

Code: Select all

CPen pen;
		HPEN hPen = ::ExtCreatePen(PS_GEOMETRIC | m_pPen->GetDashStyle(), iLineWidth ,&lb, 0, NULL);
		BOOL bAttached = pen.Attach(hPen );
		//////////////////////////////////////////////////////////////

		CPen* pOldPen = pDC->SelectObject( &pen );

		for( UINT i = 0; i < m_vPoints.size(); i++ )
		{
			PointF pt = m_vPoints[i];
			_parent->ToStage( pt );
			GetLayer()->FromStage( pt );
			if(i == 0 )
				pDC->MoveTo( (int)(pt.X * fScale + 0.5), (int)(pt.Y * fScale + 0.5) );
				// pDC->MoveTo( std::ceil(  pt.X*fScale ), std::ceil( pt.Y*fScale ) );
			else
				pDC->LineTo( (int)(pt.X * fScale + 0.5), (int)(pt.Y * fScale + 0.5) );
				// pDC->LineTo(  std::ceil( pt.X*fScale ),std::ceil( pt.Y*fScale ) );
		}
		pDC->SelectObject(pOldPen);
		pGr->ReleaseHDC( hdc );
Any help?, update? workaround?
Regards,
Yury
Attachments
emf_output.jpg
342696.pdf
(78.15 KiB) Downloaded 66 times

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Line style in EMF

Post by Sasha - Tracker Dev Team » Tue Jul 18, 2017 11:22 am

Hello Yury,

Could you please provide the emf file that you were using for us to test?

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

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

Re: Line style in EMF

Post by Yury » Tue Jul 18, 2017 12:40 pm

Here you are
Attachments
img-2500.zip
(13.46 KiB) Downloaded 69 times

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

Re: Line style in EMF

Post by Ivan - Tracker Software » Tue Jul 18, 2017 5:58 pm

I have modified a bit coefficients to use in dash-dot patterns. Now your converted EMF will looks like in attached file.
img-2500.pdf
(80.38 KiB) Downloaded 75 times
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: Line style in EMF

Post by Yury » Wed Jul 19, 2017 9:44 am

Looks excellent. Can I get the new build?

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Line style in EMF

Post by Sasha - Tracker Dev Team » Wed Jul 19, 2017 9:57 am

Hello Yury,

Of course, you can download it when it officially will be out ;)

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

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

Re: Line style in EMF

Post by Yury » Wed Jul 19, 2017 11:58 am

Alex, any time forecasts? The matter is that this bug is show stopper for our product. x64 edition.

Regards,

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

Re: Line style in EMF

Post by Tracker Supp-Stefan » Wed Jul 19, 2017 3:24 pm

Hello Yury,

There is still no official release date for build 323, but I've asked Alex if we can prepare e.g. a "nightly" build with the fix included.
He has finished for the day - so the reply will be available tomorrow - but we will see what we can arrange for you!

Cheers,
Stefan

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

Re: Line style in EMF

Post by Tracker Supp-Stefan » Thu Jul 20, 2017 8:32 am

Hello Yury,

I've just spoken with Alex - and unfortunately we can't provide a 'nightly' build at this time - as the development version is not stable enough at the moment for such a release.
Also - given that you need to put this in your live product - we do not believe a nightly (and not properly tested) build will be good to include there.
So unfortunately - you will have to wait till the official release of build 323 to implement the fix at your end.

Regards,
Stefan

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

Re: Line style in EMF

Post by Yury » Thu Jul 20, 2017 10:04 am

Hi Stefan, thank you for the care about this.

I understand that not only this fix is included into the 323, and that's why you can't release or even share it prior proper testing. That's Ok.
However, isn't it possible to take the last stable release, include this patch, rebuild and give it us. As far as I understand, fix didn't influence on over parts of code.

Also, when is the 323 is expected ?

Regards,

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

Re: Line style in EMF

Post by Tracker Supp-Stefan » Thu Jul 20, 2017 11:20 am

Hi Yury,

I will need to check with Ivan who implemented the fix - but he is in our Canadian office.
So I will only be able to confirm whether or not we will be able to do this later in the European afternoon.

Regards,
Stefan

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

Re: Line style in EMF

Post by Yury » Mon Jul 24, 2017 11:15 am

Stefan, any update on this?

Regards,

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

Re: Line style in EMF

Post by Tracker Supp-Stefan » Mon Jul 24, 2017 11:24 am

Hi Yuri,

I did contact Ivan - but have not received a reply from him on this one yet - so going to speak with some of the other colleagues in the European office to see what we can do!

Regards,
Stefan

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

Re: Line style in EMF

Post by Tracker Supp-Stefan » Mon Jul 24, 2017 4:45 pm

Hi Yury,

I've been told that we will prepare the needed file for you. A colleague from the European office has been tasked with this - so we will share it with you as soon as it's possible.

Regards,
Stefan

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

Re: Line style in EMF

Post by Yury » Tue Jul 25, 2017 7:44 am

Thanks, Stefan!

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Line style in EMF

Post by Sasha - Tracker Dev Team » Tue Jul 25, 2017 8:12 am

Hello Yury,

Here's the build:
http://docu-track.co.uk/devbuilds/19304/PDFXCoreAPI.zip

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

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

Re: Line style in EMF

Post by Yury » Tue Jul 25, 2017 4:35 pm

Thank you very much!

I've inserted this into the code. Looks working!!! We continue testing and let you know if something.
The one found issue is:
If I create pen with this options:

Code: Select all

HPEN hPen = ::ExtCreatePen(PS_JOIN_ROUND | PS_ENDCAP_FLAT |  PS_GEOMETRIC | gdiPlusPen->GetDashStyle(), iLineWidth ,&lb, 0, NULL);
It works perfect. But if I use this

Code: Select all

HPEN hPen = ::ExtCreatePen( PS_GEOMETRIC | gdiPlusPen->GetDashStyle(), iLineWidth ,&lb, 0, NULL);
It produces strange long dashes....

However, this is not critical for us at the moment.


Best regards!

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Line style in EMF

Post by Sasha - Tracker Dev Team » Tue Jul 25, 2017 6:24 pm

:)
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

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

Re: Line style in EMF

Post by Ivan - Tracker Software » Tue Jul 25, 2017 6:30 pm

Can you provide us EMFs with both of these pens ?
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: Line style in EMF

Post by Yury » Thu Jul 27, 2017 11:13 am

Hello, here is initial test result:
Archive contains 2 files: PDF & PowerPoint with the EMF, inserted.

Note, that as soon as the line thickness grows up, PDF output become different.
Lengths of the line elements ( dot, dash, space ) do not correspond to the line thickness. Could this be fixed?
The matter is that actual lengths of elements should be multiplied on line width (logical sizes). Your implementation seems use hardcoded lengths of elements.
Example:
you using array of elements like this:

Code: Select all

const DWORD dwDashSize	= 3;
const DWORD dwSpaceSize	= 2;
const DWORD dwDotSize	= 1;
DWORD dwDashDotStyle[5]		= {dwDashSize, dwSpaceSize, dwDotSize, dwSpaceSize};
But instead, it'd be as this:

Code: Select all

DWORD dwDashDotStyle[5]		= {dwDashSize * lineWidth, dwSpaceSize* lineWidth, dwDotSize* lineWidth, dwSpaceSize* lineWidth};
Any considerations?

Best regards,
Attachments
Standard-Styles.zip
(29.19 KiB) Downloaded 59 times

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

Re: Line style in EMF

Post by Yury » Thu Jul 27, 2017 12:38 pm

Another case... If the we use custom line style ( PS_USERSTYLE ),
x64 & Win32 CoreAPI behaves differently. x64 version produces incorrect result. Win32 version works as expected.
Here is the code, used to output line:

Code: Select all

//#define PS_DASH             1       /* -------  */
//#define PS_DOT              2       /* .......  */
//#define PS_DASHDOT          3       /* _._._._  */
//#define PS_DASHDOTDOT       4       /* _.._.._  */

const DWORD dwDashSize	= 3;
const DWORD dwSpaceSize	= 1;
const DWORD dwDotSize	= 1;

DWORD dwDashStyle[5]		= {dwDashSize, dwSpaceSize, dwDashSize, dwSpaceSize, 0};
DWORD dwDotStyle[3]			= {dwDotSize, dwSpaceSize, 0};
DWORD dwDashDotStyle[5]		= {dwDashSize, dwSpaceSize, dwDotSize, dwSpaceSize, 0};
DWORD dwDashDotDotStyle[7]	= {dwDashSize, dwSpaceSize, dwDotSize, dwSpaceSize, dwDotSize, dwSpaceSize, 0};
DWORD* dwStyles[5] = {NULL, dwDashStyle, dwDotStyle, dwDashDotStyle, dwDashDotDotStyle};
DWORD getDwStyleCount( DWORD* pStyle )
{
	DWORD dwCount(0);
	if( pStyle == NULL )
		return dwCount;
	while( pStyle[dwCount] != 0)
		dwCount++;
	return dwCount;
}
DWORD* getLpStyle( DWORD style, DWORD dwLineWidth )
{
	DWORD* dwStyleIndex = dwStyles[style];
	DWORD count = getDwStyleCount( dwStyleIndex );
	DWORD* pdwStyle = new DWORD[ count ];
	for( int i = 0; i < count; i++ )
		pdwStyle[i] = dwStyleIndex[i] * dwLineWidth;
	return pdwStyle;
} 
//////////////////////////////////////////
//#define _TRACKER_FIX_TEST
/////////////////////////////////////////////////
void DrawHDCDottedLine(Graphics* pGr, Pen* gdiPlusPen, vector<PointF> vPointsTranslated )
{

    LOGBRUSH lb;
	Color penColor;
	gdiPlusPen->GetColor( &penColor );
	lb.lbStyle = BS_SOLID;	
	lb.lbColor = penColor.ToCOLORREF();
	lb.lbHatch = 0;
	
	Matrix m;
	pGr->GetTransform(&m);
	REAL Elements[ 6 ];
	m.GetElements( Elements );
	REAL fScale = Elements[0];

	HDC hdc( pGr->GetHDC() );
	CDC* pDC = CDC::FromHandle( hdc );

	int iLineWidth =  ( gdiPlusPen->GetWidth()* fScale ) <= 1 ?  1 : gdiPlusPen->GetWidth() * fScale;

	CPen pen;
	DWORD dwStyleCount = getDwStyleCount( dwStyles[gdiPlusPen->GetDashStyle()] );
	DWORD* lpStyle = getLpStyle( gdiPlusPen->GetDashStyle(),  iLineWidth );
#ifdef _TRACKER_FIX_TEST
	HPEN hPen = ::ExtCreatePen(PS_JOIN_ROUND | PS_ENDCAP_FLAT |  PS_GEOMETRIC | gdiPlusPen->GetDashStyle(), iLineWidth ,&lb, 0, NULL);
	pen.Attach(hPen );
#else
	HPEN hPen = ::ExtCreatePen(PS_JOIN_ROUND | PS_ENDCAP_FLAT | PS_USERSTYLE |  PS_GEOMETRIC | gdiPlusPen->GetDashStyle(), iLineWidth ,&lb, dwStyleCount, lpStyle);
	pen.Attach(hPen );
	delete lpStyle;
#endif
    CPen* pOldPen = pDC->SelectObject( &pen );
    for( UINT i = 0; i < vPointsTranslated.size(); i++ )
    {
        PointF pt = vPointsTranslated[i];
        if(i == 0 )
			pDC->MoveTo( (int)(pt.X * fScale + 0.5), (int)(pt.Y * fScale + 0.5) );
        else
			pDC->LineTo( (int)(pt.X * fScale + 0.5), (int)(pt.Y * fScale + 0.5) );
    }
    pDC->SelectObject(pOldPen);
    pGr->ReleaseHDC( hdc );
}
Attachments
user-style.zip
(58.35 KiB) Downloaded 54 times

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

Re: Line style in EMF

Post by Yury » Tue Aug 01, 2017 9:31 am

Hi, any updates on this?

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

Re: Line style in EMF

Post by Tracker Supp-Stefan » Wed Aug 02, 2017 2:38 pm

Hello Yury,

Ivan is currently working on a high priority task, and once he is done with it - he will look at your issue again.
So apologies for the delay and lack of updates - but we will have more for you shortly.

Regards,
Stefan

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

Re: Line style in EMF

Post by Ivan - Tracker Software » Wed Aug 02, 2017 7:40 pm

I made some changes in handling dash patterns.
Please download updated DLL (64-bit only for now): http://www.docu-track.co.uk/nightbuild/ ... 2_6_rc.zip

If you have any comments, please let me know.

We are going to release build 322.6 next week, and these changes will be included in this build.
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: Line style in EMF

Post by Yury » Thu Aug 03, 2017 11:02 am

Hello, this is PDFXEdit, but we need PDFXCoreAPI.x64. Can I get it?

Regards

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

Re: Line style in EMF

Post by Ivan - Tracker Software » Thu Aug 03, 2017 5:07 pm

Sorry, my fault.
proper DLL can be found here: http://www.docu-track.co.uk/nightbuild/ ... 2_6_rc.zip
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.

Post Reply