Page 1 of 1

Line style in EMF

Posted: Tue Jul 18, 2017 11:04 am
by Yury
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

Re: Line style in EMF

Posted: Tue Jul 18, 2017 11:22 am
by Sasha - Tracker Dev Team
Hello Yury,

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

Cheers,
Alex

Re: Line style in EMF

Posted: Tue Jul 18, 2017 12:40 pm
by Yury
Here you are

Re: Line style in EMF

Posted: Tue Jul 18, 2017 5:58 pm
by Ivan - Tracker Software
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

Re: Line style in EMF

Posted: Wed Jul 19, 2017 9:44 am
by Yury
Looks excellent. Can I get the new build?

Re: Line style in EMF

Posted: Wed Jul 19, 2017 9:57 am
by Sasha - Tracker Dev Team
Hello Yury,

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

Cheers,
Alex

Re: Line style in EMF

Posted: Wed Jul 19, 2017 11:58 am
by Yury
Alex, any time forecasts? The matter is that this bug is show stopper for our product. x64 edition.

Regards,

Re: Line style in EMF

Posted: Wed Jul 19, 2017 3:24 pm
by Tracker Supp-Stefan
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

Re: Line style in EMF

Posted: Thu Jul 20, 2017 8:32 am
by Tracker Supp-Stefan
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

Re: Line style in EMF

Posted: Thu Jul 20, 2017 10:04 am
by Yury
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,

Re: Line style in EMF

Posted: Thu Jul 20, 2017 11:20 am
by Tracker Supp-Stefan
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

Re: Line style in EMF

Posted: Mon Jul 24, 2017 11:15 am
by Yury
Stefan, any update on this?

Regards,

Re: Line style in EMF

Posted: Mon Jul 24, 2017 11:24 am
by Tracker Supp-Stefan
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

Re: Line style in EMF

Posted: Mon Jul 24, 2017 4:45 pm
by Tracker Supp-Stefan
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

Re: Line style in EMF

Posted: Tue Jul 25, 2017 7:44 am
by Yury
Thanks, Stefan!

Re: Line style in EMF

Posted: Tue Jul 25, 2017 8:12 am
by Sasha - Tracker Dev Team
Hello Yury,

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

Cheers,
Alex

Re: Line style in EMF

Posted: Tue Jul 25, 2017 4:35 pm
by Yury
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!

Re: Line style in EMF

Posted: Tue Jul 25, 2017 6:24 pm
by Sasha - Tracker Dev Team
:)

Re: Line style in EMF

Posted: Tue Jul 25, 2017 6:30 pm
by Ivan - Tracker Software
Can you provide us EMFs with both of these pens ?

Re: Line style in EMF

Posted: Thu Jul 27, 2017 11:13 am
by Yury
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,

Re: Line style in EMF

Posted: Thu Jul 27, 2017 12:38 pm
by Yury
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 );
}

Re: Line style in EMF

Posted: Tue Aug 01, 2017 9:31 am
by Yury
Hi, any updates on this?

Re: Line style in EMF

Posted: Wed Aug 02, 2017 2:38 pm
by Tracker Supp-Stefan
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

Re: Line style in EMF

Posted: Wed Aug 02, 2017 7:40 pm
by Ivan - Tracker Software
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.

Re: Line style in EMF

Posted: Thu Aug 03, 2017 11:02 am
by Yury
Hello, this is PDFXEdit, but we need PDFXCoreAPI.x64. Can I get it?

Regards

Re: Line style in EMF

Posted: Thu Aug 03, 2017 5:07 pm
by Ivan - Tracker Software
Sorry, my fault.
proper DLL can be found here: http://www.docu-track.co.uk/nightbuild/ ... 2_6_rc.zip