Core API SDK  SOLVED

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

Core API SDK

Post by Yury » Fri Oct 02, 2015 1:07 pm

Hello, I'm trying to use Core API SDK to substitute code of PDFXChange SDK.
I can’t realize on how to place an EMF image (HENHMETAFILE) ( Actually, any image )
on to the PDF page. This aspect is not covered in the only sample which is provided in the setup.

I found the “IPXC_Document::AddImageFromStream”, which looks to be the substitution of the v4 PDFXChange SDK , and I found the “IPXC::ContentCreator::PlaceImage”,
Questions:
1. PlaceImage does not allow me to specify X,Y , WIDTH, HEIGHT for the placing image. How can I do this?
2. Can I add HENHMETAFILE instead of converting the image too stream?
Thanks in advance,

Yury

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

Re: Core API SDK

Post by Ivan - Tracker Software » Fri Oct 02, 2015 3:14 pm

Hi Yury,

I or my colleagues will prepare a sample code and will post it here soon.
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.

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

Re: Core API SDK

Post by Ivan - Tracker Software » Fri Oct 02, 2015 3:56 pm

Here is code to load an image from the file and place it on the page. I broke it on several functions that can be used in different situations:

Code: Select all

HRESULT PlaceImage(IPXC_ContentCreator* pCC, IPXC_Image* pImg, const PXC_Rect& rc)
{
	PXC_Matrix im = {0};
	im.a = rc.right - rc.left;
	im.d = rc.top - rc.bottom;
	im.e = rc.lef;
	im.f = rc.bottom;
	
	pCC->SaveState();
	pCC->ConcatCS(&im);
	pCC->PlaceImage(pNewImage);
	pCC->RestoreState();
	
	return S_OK;
}

HRESULT PlaceImage(IPXC_Page* page, IPXC_Image* pImage, const PXC_Rect& rc)
{
	HRESULT hr = S_OK;

	CComPtr<IPXC_Document> pRDoc;
	CComPtr<IPXC_Content> pContent;
	CComPtr<IPXC_ContentCreator> pCC;

	page->get_Doc(&pRDoc);
	page->GetContent(CAccessMode_WeakClone, &pContent);

	pRDoc->CreateContentCreator(&pCC);
	pCC->Attach(pContent);
	PlaceImage(pCC, pImage, rc);

	page->PlaceContent(pContent, PlaceContent_Replace);
	
	return hr;
} 

HRESULT PlaceImage(IPXC_Document* pRDoc, DWORD nPageIdx, LPCWSTR sImageFileName, const PXC_Rect& rc)
{
	HRESULT hr = S_OK;
	CComPtr<IPXC_Pages> pages;
	CComPtr<IPXC_Page> page;
	pRDoc->get_Pages(&pages);
	pages->get_Item(nPageIdx, &page);


	CComPtr<IPXC_Image> pNewImage;
	hr = pRDoc->AddImageFromFile(sImageFileName, 0, 0, &pNewImage);
	if (FAILED(hr))
		return hr;

	return PlaceImage(page, pNewImage, rc);
}
With metafiles the code will be very similar, except that metafiles are loaded into IPXC_XForm object, not into IPXC_Image. Will post that code soon.
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.

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

Re: Core API SDK

Post by Ivan - Tracker Software » Fri Oct 02, 2015 4:39 pm

Placing XForm in content requires a bit of matrix arithmetic and in the current build of Core API, corresponding method are not published, so, I post some here:

Code: Select all

void Transform(const PXC_Matrix& m, double& x, double& y)
{
	double tx = x;
	x = tx * m.a + y * m.c + m.e;
	y = tx * m.b + y * m.d + m.f;
}

void UpdateMinMax(double v, double& vMin, double& vMax)
{
	if (vMin > v)
		vMin = v;
	if (vMax < v)
		vMax = v;
}

void TransformRect(const PXC_Matrix& m, double& l, double& b, double& r, double& t)
{
	double x = l;
	double y = b;
	Transform(m, x, y);
	double x1 = x;
	double x2 = x;
	double y1 = y;
	double y2 = y;
	x = l;
	y = t;
	Transform(m, x, y);
	UpdateMinMax(x, x1, x2);
	UpdateMinMax(y, y1, y2);
	x = r;
	y = t;
	Transform(m, x, y);
	UpdateMinMax(x, x1, x2);
	UpdateMinMax(y, y1, y2);
	x = r;
	y = b;
	Transform(m, x, y);
	UpdateMinMax(x, x1, x2);
	UpdateMinMax(y, y1, y2);
	l = x1;
	r = x2;
	b = y1;
	t = y2;
}

void TransformRect(const PXC_Matrix& m, PXC_Rect& r)
{
	TransformRect(m, r.left, r.bottom, r.right, r.top);
}

PXC_Matrix Rect2Rect(const PXC_Rect& from, const PXC_Rect& to)
{
	PXC_Matrix m = {0};
	m.a = m.d = 1;
	if ((to.right == to.left) || (to.top == to.bottom) ||
		(from.left == from.right) || (from.top == from.bottom))
	{
		m.a = m.d = 1.0;
	}
	else
	{
		m.a = (to.right - to.left) / (from.right - from.left);
		m.d = (to.top - to.bottom) / (from.top - from.bottom);
	}
	m.e = to.left - from.left * m.a;
	m.f = to.bottom - from.bottom * m.d;
	return m;
}
Now, here is the code to place HENHMETAFILE on a page:

Code: Select all

HRESULT PlaceXForm(IPXC_ContentCreator* pCC, IPXC_XForm* pXForm, const PXC_Rect& rc)
{
	PXC_Matrix im = {0};
	PXC_Matrix fm = {0};
	PXC_Rect bbox;
	pXForm->get_BBox(&bbox);
	pXForm->get_Matrix(&fm);
	
	TransformRect(fm, bbox);
	im = Rect2Rect(bbox, rc);
	
	pCC->SaveState();
	pCC->ConcatCS(&im);
	pCC->PlaceXForm(pXForm, L"");
	pCC->RestoreState();
	
	return S_OK;
}

HRESULT PlaceXForm(IPXC_Page* page, IPXC_XForm* pXForm, const PXC_Rect& rc)
{
	HRESULT hr = S_OK;

	CComPtr<IPXC_Document> pRDoc;
	CComPtr<IPXC_Content> pContent;
	CComPtr<IPXC_ContentCreator> pCC;

	page->get_Doc(&pRDoc);
	page->GetContent(CAccessMode_WeakClone, &pContent);

	pRDoc->CreateContentCreator(&pCC);
	pCC->Attach(pContent);
	PlaceXForm(pCC, pXForm, rc);

	page->PlaceContent(pContent, PlaceContent_Replace);
	
	return hr;
} 

HRESULT PlaceMetafile(IPXC_Document* pRDoc, DWORD nPageIdx, HENHMETAFILE hMeta, const PXC_Rect& rc)
{
	HRESULT hr = S_OK;
	CComPtr<IPXC_Pages> pages;
	CComPtr<IPXC_Page> page;
	pRDoc->get_Pages(&pages);
	pages->get_Item(nPageIdx, &page);


	CComPtr<IPXC_XForm> pXForm;
	hr = pRDoc->ConvertMetafile((HANDLE_T)hMeta, 0, nullptr, &pXForm);
	if (FAILED(hr))
		return hr;

	return PlaceXForm(page, pXForm, rc);
}
In new build IPXC_ContentCreator object has methods PlaceXFormEx and PlaceImageEx that has rect as parameter and hides all math.
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: Core API SDK

Post by Yury » Mon Oct 05, 2015 2:30 pm

Thanks Ivan, I'll be checking this. But you mentioned that new build will have all I need. When this build will be available?

Regards,
Yury

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

Re: Core API SDK

Post by Ivan - Tracker Software » Mon Oct 05, 2015 5:37 pm

Currently we have no date for new build release. Some new features that should be included in that build are still in progress.
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: Core API SDK

Post by Yury » Tue Oct 06, 2015 11:26 am

Thanks Ivan. I could make EMF inserted. So I continue transfer from PDFX4 to CoreAPI and I have more questoins which I could not find in the documentation/sample/source

1. We used call like this : "PXC_AddGotoAction( pageOn->_page, &rcLink,IndexOf( pageTo->_page), Dest_Page, 0,0,0,0,&ai );" to place the link to the desired page.
In current implementation I could find something similar, but not sure on how to use it correctly

CComPtr< PXC::IPXC_ActionsList> pActions(0);
CComPtr< PXC::IPXC_Action> pAction(0);
page->get_Actions( PXC::PXC_TriggerType::Trigger_Unknown, &pActions );
PXC::PXC_Destination dst;
pActions->AddGoto( dst, &pAction );

So, page has a list of actions. I need just place the GoTo to another page. I'm not sure which PXC_TriggerType to use and how to specify the rectangle/path of the link.

2. we used PXC_AddOutlineEntryW method for creating the table of content at the left side. Where can I find the substitution and how to use it? I need place outlines for each page I create.

Thanks in advance.
Yury.

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

Re: Core API SDK

Post by Sasha - Tracker Dev Team » Tue Oct 06, 2015 12:22 pm

Hi, Yury.

If I understood you correctly, you need to create a Link annotation on the desired page which points to the entered page with GoTo action. And also, you want to use this GoTo action to create bookmark with it.

If you can wait for a little bit, I'll write you a code sample.
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: Core API SDK

Post by Yury » Tue Oct 06, 2015 1:08 pm

Yes, like this. How can I attach the screenshot? JPG files looks not allowed...

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

Re: Core API SDK

Post by Sasha - Tracker Dev Team » Tue Oct 06, 2015 1:10 pm

Use an online image host like imgur and paste a link with "img" tag here, or pack it into archive and attach.
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: Core API SDK

Post by Yury » Tue Oct 06, 2015 2:15 pm

So here is an example of links I need
Image

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

Re: Core API SDK

Post by Sasha - Tracker Dev Team » Tue Oct 06, 2015 2:18 pm

Ok, almost done here - will post the code sample soon.
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

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

Re: Core API SDK

Post by Sasha - Tracker Dev Team » Tue Oct 06, 2015 2:44 pm

Here's the code on the Core level. If you need to use the undo/redo data you'll need to use operations for creating link annotations and bookmarks.

Code: Select all

	ULONG nLink = 0;
	pSInst->StrToAtom(L"Link", &nLink); //IPXS_Inst
	CComPtr<IPXC_Annotation> pAnnot;
	CComPtr<IPXC_Page> pPage;
	CComPtr<IPXC_Pages> pPages;
	CComPtr<IPXC_ActionsList> pAList;
	CComPtr<IPXC_Action> pAction;
	HRESULT hr = S_OK;
	do
	{
		hr = pDoc->get_Pages(&pPages); //IPXC_Document
		if (hr != S_OK)
			break;
		hr = pPages->get_Item(0, &pPage);
		if (hr != S_OK)
			break;
		//Link rectangle parameters
		PXC_Rect rcBoundRect;
		rcBoundRect.left = 0;
		rcBoundRect.bottom = 0;
		rcBoundRect.right = 100;
		rcBoundRect.top = 100;
		hr = pPage->InsertNewAnnot(nLink, &rcBoundRect, -1, &pAnnot);
		if (hr != S_OK)
			break;
		//Adding action to the link not to the page
		hr = pDoc->CreateActionsList(&pAList);
		if (hr != S_OK)
			break;
		PXC_Destination dest;
		dest.nPageNum = 1;
		dest.nNullFlags = 0xF;
		dest.nType = Dest_XYZ;
		hr = pAList->AddGoto(dest, &pAction);
		if (hr != S_OK)
			break;
		hr = pAnnot->put_Actions(Trigger_Up, pAList);
		if (hr != S_OK)
			break;
		
		//Now adding bookmark with same action list
		CComPtr<IPXC_Bookmark> pRoot;
		hr = pDoc->get_BookmarkRoot(&pRoot);
		if (hr != S_OK)
			break;
		CComPtr<IPXC_Bookmark> pBookm;
		hr = pRoot->AddNewChild(VARIANT_TRUE, &pBookm);
		if (hr != S_OK)
			break;
		hr = pBookm->put_Actions(pAList);
		if (hr != S_OK)
			break;
		
		pDoc->WriteToFile(L"D:\\YourNewFile.pdf");

	} while (false);
HTH
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: Core API SDK

Post by Yury » Tue Oct 06, 2015 3:17 pm

Sorry, Sasha, still not clear

I have 2 pages:

CComPtr<IPXC_Page> pPageOn;
CComPtr<IPXC_Page> pPageTo;

I have
PXC_Rect rcBoundRect on pPage1

How do I make a GoTo, so if I click on rcBoundRect in pPage1, it'd move me to pPage2.

IPXC_Document m_pDoc; // created

void AddGoToAction( CComPtr<IPXC_Page> pPageOn, CComPtr<IPXC_Page> pPageTo, PXC_Rect rcBoundRect )
{
/// ???? I need this implementation. Please help.
}

In your example, I'm not completely clear about this:
///////////////////////////////////////////////
ULONG nLink = 0;
pSInst->StrToAtom(L"Link", &nLink); //IPXS_Inst
hr = pPage->InsertNewAnnot(nLink, &rcBoundRect, -1, &pAnnot);
/////////////////////////////////////////////////////////////

What is this nLink, and why is it for?


Thanks for quick unswers!

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

Re: Core API SDK

Post by Ivan - Tracker Software » Tue Oct 06, 2015 10:21 pm

Here is the code:

Code: Select all

void AddGoToAction(IPXC_Page* pPageOn, IPXC_Page* pPageTo, PXC_Rect rcBoundRect)
{
	// step 1 - lets create new link annot on pPageOn
	ULONG_T nLinkAnnotType;
	g_COS->StrToAtom(L"Link", &nLinkAnnotType);		// g_COS - pointer to IPXS_Inst
	CComPtr<IPXC_Annotation> pNewAnnot;
	// add new annotation with type nLinkAnnotType and rect rcBoundRect at the end of page's annotation's list (-1)
	pPageOn->InsertNewAnnot(nLinkAnnotType, &rcBoundRect, -1 /* at the end */, &pNewAnnot);
	
	// step 2 - create an action list with goto action
	CComPtr<IPXC_ActionsList> aList;
	CComPtr<IPXC_Document> pDoc;
	pPageOn->get_Document(&pDoc);
	pDoc->CreateActionsList(&aList);
	// fill destination position for Goto action
	PXC_Destination dest = {0};
	// page number
	pPageTo->get_Number(&dest.nPageNum);
	// type;
	dest.nType = Dest_XYZ;		// goto to the point [X = dest.dValues[0]; Y = dest.dValues[1]] on page [dest.nPageNum] and Zoom dest.dValues[2]
	// position
	PXC_Rect pageRect;
	pPageTo->get_Box(PBox_CropBox, &pageRect);
	dest.dValues[0]				= pageRect.left;
	dest.dValues[1]				= pageRect.top;
	dest.dValues[2]				= 0;			// 0 means to keep zoom level unchanged; the same effect would be if bit 2 (zero based index) in field dest.nNullFlags set to 1
	aList->AddGoto(dest, nullptr);	// we don't need returned value
	// step 3 - set this action list to our link annotation
	pNewAnnot->put_Actions(Trigger_Up, aList);
}
Please note, if you don't use raw_only import, the code may be written in more 'clear' way:

Code: Select all

void AddGoToAction(IPXC_Page* pPageOn, IPXC_Page* pPageTo, PXC_Rect rcBoundRect)
{
   // step 1 - lets create new link annot on pPageOn
   IPXC_AnnotationPtr pNewAnnot = pPageOn->InsertNewAnnot(g_COS->StrToAtom(L"Link"), &rcBoundRect, -1);
   
   // step 2 - create an action list with goto action
   IPXC_ActionsListPtr aList = pPageOn->Document->CreateActionsList();
   // fill destination position for Goto action
   PXC_Destination dest = {0};
   // page number
   dest.nPageNum        = pPageTo->Number;
   // type;
   dest.nType           = Dest_XYZ;      // goto to the point [X = dest.dValues[0]; Y = dest.dValues[1]] on page [dest.nPageNum] and Zoom dest.dValues[2]
   // position
   PXC_Rect pageRect    = pPageTo->BBox;
   dest.dValues[0]      = pageRect.left;
   dest.dValues[1]      = pageRect.top;
   dest.dValues[2]      = 0;         // 0 means to keep zoom level unchanged; the same effect would be if bit 2 (zero based index) in field dest.nNullFlags set to 1
   aList->AddGoto(dest);
   // step 3 - set this action list to our link annotation
   pNewAnnot->Actions[Trigger_Up] = aList;
}
but you have to handle exceptions.

HTH
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: Core API SDK

Post by Yury » Thu Oct 08, 2015 5:08 pm

Hi, looks like working...

Quick question:
Annotations. How can I get read of border around it?
I tried several ways, but they not working... This is what I was trying to do, still think black rectangle around it:
CComPtr<PXC::IPXC_Annotation> pNewAnnot;
// add new annotation with type nLinkAnnotType and rect rcBoundRect at the end of page's annotation's list (-1)
m_hLastError = pPageOn->InsertNewAnnot(nLinkAnnotType, &rcBoundRect, -1 /* at the end */, &pNewAnnot);
if (IS_DS_FAILED(m_hLastError))
return false;

CComPtr< PXC::IPXC_AnnotData> data;
PXC::PXC_AnnotBorder border;
pNewAnnot->get_Data( &data );
data->get_Border(&border);
memset( (void*)&border, 0, sizeof( PXC::PXC_AnnotBorder ) );
data->put_Border( &border );
double opacity;
data->get_Opacity(&opacity);
data->put_Opacity( 0.0 );

Lzcat - Tracker Supp
Site Admin
Posts: 712
Joined: Thu Jun 28, 2007 8:42 am

Re: Core API SDK

Post by Lzcat - Tracker Supp » Fri Oct 09, 2015 5:41 am

You are missing the update of changed annotation data. Please call
pNewAnnot->put_Data(data);
Victor
Tracker Software
Project manager

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.

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

Re: Core API SDK

Post by Yury » Fri Oct 09, 2015 2:50 pm

OK. great. everything is working...

More questions:

1. I was using PXC_AddLink( (_PXCContent*)(pageItem->_page), &rc, (LPCSTR)str.c_str() , NULL ); to output the external URLs like http://someweb.com/s/d/
What is the substitution method for this? I could not find.
2. There were the document optimization APIs
m_hLastError = PXCp_ReadDocumentW( hDocument, strPath.c_str(), 0 );
m_hLastError = PXCp_OptimizeFonts( hDocument, 0 );
m_hLastError = PXCp_OptimizeStreamCompression( hDocument );
m_hLastError = PXCp_WriteDocumentW( hDocument, strPath.c_str(), PXCp_CreationDisposition_Overwrite, PXCp_Write_Release);

Are there any substs?

Thank you!

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

Re: Core API SDK

Post by Ivan - Tracker Software » Fri Oct 09, 2015 10:00 pm

Code: Select all

1. I was using PXC_AddLink( (_PXCContent*)(pageItem->_page), &rc, (LPCSTR)str.c_str() , NULL ); to output the external URLs like http://someweb.com/s/d/
What is the substitution method for this? I could not find.
The code is very similar to one above that adds GoTo link. The only difference is in the action associated with created link annotation.

Code: Select all

void AddLinkAction(IPXC_Page* pPageOn, PXC_Rect rcBoundRect, LPCWSTR sURL)
{
   // step 1 - lets create new link annot on pPageOn
   ULONG_T nLinkAnnotType;
   g_COS->StrToAtom(L"Link", &nLinkAnnotType);      // g_COS - pointer to IPXS_Inst
   CComPtr<IPXC_Annotation> pNewAnnot;
   // add new annotation with type nLinkAnnotType and rect rcBoundRect at the end of page's annotation's list (-1)
   pPageOn->InsertNewAnnot(nLinkAnnotType, &rcBoundRect, -1 /* at the end */, &pNewAnnot);
   
   // step 2 - create an action list with goto action
   CComPtr<IPXC_ActionsList> aList;
   CComPtr<IPXC_Document> pDoc;
   pPageOn->get_Document(&pDoc);
   pDoc->CreateActionsList(&aList);
   // fill destination position for Goto action
   aList->AddURI((BSTR)sURL, nullptr);
   // step 3 - set this action list to our link annotation
   pNewAnnot->put_Actions(Trigger_Up, aList);
}
2. There were the document optimization APIs.
Currently optimization is available only in Editor SDK. Replacement for old PXCp_OptimizeXXX function will be added in future builds of the Core API.
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: Core API SDK

Post by Yury » Sat Oct 10, 2015 2:03 pm

Ok. thank you.
We looks have issue with the Arabic text in EMF insertion.
See the attached archive.

File arabic.txt contains the original arabic text.
The PDFs are produced from the EMF & from BITMAP of the same output image.
Look, that text in the EMF version is different from what is in Bitmap & Original text.

Could you please let me know if your EMF parser correctly works with the Arbic texts?

Thank you!
Attachments
OrgCharts.zip
(103.65 KiB) Downloaded 67 times

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

Re: Core API SDK

Post by Yury » Sat Oct 10, 2015 2:54 pm

And I've just checked ...
if I save image before placing the EMF,
////////////////////////////////////////////////
RectF rcFullBound;
Unit unit;
pImage->GetBounds( &rcFullBound, &unit );
Bitmap* pBitmap = new Bitmap( (int)rcFullBound.Width, (int)rcFullBound.Height, PixelFormat32bppRGB );
Graphics* pGr = new Graphics( pBitmap );
Status status = pGr->DrawImage( pImage, rcFullBound );
pBitmap->Save( GenericUtility::ToWChar(_T("E:\\out-EMF.bmp")).c_str(), &(Encoders[_T("image/bmp")]->Clsid));
delete pImage;
delete pGr;
HENHMETAFILE hEnhMetaFile( ((Metafile*)pImage)->GetHENHMETAFILE() );
m_hLastError = PlaceMetafile( pageItem, hEnhMetaFile, rcPxc );
if (IS_DS_FAILED(m_hLastError))
return false;
////////////////////////////////////////////////////

Resulted out-EMF.bmp has correct text, but what we have in PDF, as a result of PlaceMetafile, does not.

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

Re: Core API SDK

Post by Yury » Tue Oct 13, 2015 9:47 am

Hello, any comments?

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

Re: Core API SDK

Post by Tracker Supp-Stefan » Tue Oct 13, 2015 12:17 pm

Hi Yury,

It was Thanksgiving in Canada yesterday, so Ivan was not in the office. I will ask him to take a look again today when he comes to work (it's still 5:17 AM where he is) and post back if he has any further comments.

And I've actually spoken with a colleague from the European office - and they've suggested that we will probably also need the emf file tot est - as this could be file specific.

Regards,
Stefan

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

Re: Core API SDK

Post by Ivan - Tracker Software » Tue Oct 13, 2015 11:18 pm

Can you post here your .emf file with that arabic text ?
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: Core API SDK

Post by Yury » Wed Oct 14, 2015 8:31 am

Here you are
Attachments
arabic_text.zip
(96.69 KiB) Downloaded 72 times

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

Re: Core API SDK

Post by Ivan - Tracker Software » Wed Oct 14, 2015 6:24 pm

Thanks for the file. Will try to fix the issue.
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: Core API SDK

Post by Yury » Fri Jul 01, 2016 11:19 am

Hello, are there any news about my issues, described here?
1. Arabic text
2. Optimization substitution:
m_hLastError = PXCp_OptimizeFonts( hDocument, 0 );
if (IS_DS_FAILED(m_hLastError))
return false;

m_hLastError = PXCp_OptimizeStreamCompression( hDocument );
if (IS_DS_FAILED(m_hLastError))
return false;

Regards,

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

Re: Core API SDK

Post by Sasha - Tracker Dev Team » Fri Jul 01, 2016 11:48 am

Hello Yury,

1) This should be already implemented in the 317.1 version.
2) The PXCp_OptimizeFonts and PXCp_OptimizeStreamCompression methods' analogy is not yet available.

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: Core API SDK

Post by Yury » Fri Jul 01, 2016 12:05 pm

Thanks, Alex.

Confirm p. 1 - Arabic text looks Ok now.

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

Re: Core API SDK

Post by Sasha - Tracker Dev Team » Fri Jul 01, 2016 12:06 pm

:)
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: Core API SDK

Post by Yury » Wed Jul 20, 2016 12:42 pm

Hello, seems I have another issue. Could you please research and let me know what to do with the following:

I have one machine ( screen resolution is 1920x108) at my office and I connect to it from home machine using the Remote Desktop. Home machine has 2500x1400 (QHD) resolution.
I do PDF publishing from our product, and have the resulted pdf name "Chart 1-2500x1400.pdf".
Then I disconnect RD connection and reconnect from another machine (home notebook), which has screen resolution 1920x1080.
I do same publish ( even not restarting our program) and have result named "Chart 1-1920x1080.pdf".

In both cases PDF page has one EMF image inserted. The bounds of the image are marked with blue rectangle.
You see that for the first image is scaled and shifted.

I did debugging with both cases ( when connected with 2500x1400 and 1920x1080 machines). And I didn't find any bugs in my code. For both case I'm adding the PDF page of the same size and I'm placing the same sized EMF image on to the same rectangle.
See the "Result.pdf". Unfortunately I could not attach excel or ms word file, so, I converted to pdf.
Left most column describes operations : Adding page & inserting image. columns "2500x1400" & "1920x108" reflects the parameters.

So the question is: why under the 2500x1400 connection the resulted PDF looks so different? I'll provide all the necessary information to resolve this.
This is rather critical for us.

Best regards,
Yury
Attachments
Result.pdf
(265.44 KiB) Downloaded 80 times
Chart 1-1920x1080.pdf
(80.74 KiB) Downloaded 69 times
Chart 1-2500x1400.pdf
(80.79 KiB) Downloaded 63 times

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

Re: Core API SDK

Post by Sasha - Tracker Dev Team » Wed Jul 20, 2016 1:00 pm

Hello Yury,

Is it crucial to use the EMF file types? If that cannot be avoided please provide the sample files that we can investigate with.

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: Core API SDK

Post by Yury » Wed Jul 20, 2016 2:15 pm

Try this, however, I'm not sure that MS allows save metafile on to the HD properly.
This operation is prohibited in GDI+. I used workaround and just saved memory stream
(rename pdf ext to emf. looks this is the only extension which is allowed to attach)
Attachments
output-2500.pdf
(18.12 KiB) Downloaded 95 times

Lzcat - Tracker Supp
Site Admin
Posts: 712
Joined: Thu Jun 28, 2007 8:42 am

Re: Core API SDK

Post by Lzcat - Tracker Supp » Wed Jul 20, 2016 2:23 pm

Hi Yuri.
We need emf files for both cases.
And you can attach any type of file to post if you archive it using zip/rar/7z format.
Victor
Tracker Software
Project manager

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.

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

Re: Core API SDK

Post by Yury » Wed Jul 20, 2016 2:32 pm

Here you are. Thanks. for now just renamed from EMF to PDF.
Attachments
output-1920.pdf
(18.12 KiB) Downloaded 111 times

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

Re: Core API SDK

Post by Ivan - Tracker Software » Wed Jul 20, 2016 4:03 pm

Hi Yury,

Thanks for the files. I will check what can I do here, but as I see most applications having issue with that 2500 file.
For example, it is screenshots of EMF Parser application with these two files opened:

Image
Image

On the other hand, MS Paint shows it correctly, but I'm afraid it is because these files contains GDI+ version of the metafile which we cannot handle as it is absolutely undocumented.
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: Core API SDK

Post by Yury » Thu Jul 21, 2016 2:49 pm

Hello, any updates? May be we could use some workaround?
Also, here is emf parser ( source code ), which seems parses it correctly.
http://www.codeproject.com/Articles/8410/WebControls/

Regards

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

Re: Core API SDK

Post by Ivan - Tracker Software » Thu Jul 21, 2016 4:58 pm

Actually it does not render this file correctly. Just download their .exe and open two of your files - "output-2500.emf" causes problems.
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: Core API SDK

Post by Yury » Fri Jul 22, 2016 10:25 am

Well, yes, I see it now.
However, these parsers are rather old. The one which you show on the screenshot - EMFParser.exe looks dated 2006 year. Right?

I'm not specialist in EMF structure, but this parser does not even distinguish EMR_HEADER Record Types
https://msdn.microsoft.com/en-us/library/cc230635.aspx

You mentioned that GDI+ EMF is not documented.
Here is what I found:
https://msdn.microsoft.com/en-us/library/cc230514.aspx

Isn't it what you need?

Is it possible to fix the sizing with this? We also had the texture issue early. Does this doc describe it?

Regards,

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

Re: Core API SDK

Post by Sasha - Tracker Dev Team » Mon Jul 25, 2016 6:36 am

Hello Yury,

Thank you for the links. We'll have a look at it and will reply when we have some results.

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: Core API SDK

Post by Yury » Wed Mar 22, 2017 9:53 am

Hello, I found today that update version 6.03.321 is available.
We have licensed 6.03.317 version.
After the updating the library I got the watermark image.
Could you please provide the valid key?
( How should I send you my current license key?)

Regards,
Yury

User avatar
Will - Tracker Supp
Site Admin
Posts: 6806
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Core API SDK

Post by Will - Tracker Supp » Wed Mar 22, 2017 10:00 am

Hi Yury,

Thanks for the post - Can you please email sales@tracker-software.com directly, with a link back to this topic for reference? Please also include your current license key. We cannot help with licensing issues over the forums.

Cheers,
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

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com

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

Re: Core API SDK

Post by Yury » Wed Mar 22, 2017 10:23 am

Hi, Ok, just emailed.
Thank you

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

Re: Core API SDK

Post by Sasha - Tracker Dev Team » Wed Mar 22, 2017 10:28 am

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

Post Reply