Support Other File Types

PDF-XChange Editor SDK for Developers

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

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
RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Support Other File Types

Post by RMan » Wed Apr 26, 2017 1:55 am

What is the best way to add in support for other files types to the Editor?

We want to be able to convert other formats to PDF for all of the open, drag and drop, and insert commands. As well as drop our supported file types into the dialog box drop downs.

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

Re: Support Other File Types

Post by Sasha - Tracker Dev Team » Wed Apr 26, 2017 6:19 am

Hello RMan,

Judging from what you say, you will need to implement your own http://sdkhelp.tracker-software.com/vie ... tConverter interface that basically is derived from the http://sdkhelp.tracker-software.com/vie ... tConverter. Then you will have to register the created import converter http://sdkhelp.tracker-software.com/vie ... tConverter so that all of the functionality that you've described would be available. I will update the description for the methods and properties of the ImportConverter and FormatConverter interfaces so that you would know what to implement.

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

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Support Other File Types

Post by RMan » Wed Apr 26, 2017 5:56 pm

Thanks. If you have a sample project that would be great also.

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

Re: Support Other File Types

Post by Sasha - Tracker Dev Team » Thu Apr 27, 2017 9:06 am

Hello RMan,

Just finished updating the description for the required interfaces that I mentioned before - be sure to check it out.
Sadly, I do not have a sample, though implementing your own converter is a pretty easy task so you shouldn't have any problems with it. The CheckFormat method should check whether the given source data is supported by the converter. If so, then the Convert method will be executed that should convert the Data to the IPXC_Document. That's all. The description for the Format Converter also should be filled. The Format Converter is the Parent class for the Import Converter.
When you have your converter ready, you should register it at the start of the program - this will allow the Control to use it when you open your types of file.

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

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Support Other File Types

Post by RMan » Tue Jan 30, 2018 4:08 pm

Sasha,

Could you please provide a VB.Net sample of doing this? I'm unable to get it to work in both VB.Net and VB6. When I tried adding the class in VB.Net it ends up giving errors on the following

'ShowPrefsDlg' cannot implement 'ShowPrefsDlg' because there is no matching sub on interface 'PDFXEdit.IPXV_FormatConverter'.
'CheckFormat' cannot implement 'CheckFormat' because there is no matching function on interface 'PDFXEdit.IPXV_ImportConverter'.
'Convert' cannot implement 'Convert' because there is no matching function on interface 'PDFXEdit.IPXV_ImportConverter'.
'ShowPrefsDlg1' cannot implement 'ShowPrefsDlg' because there is no matching sub on interface 'PDFXEdit.IPXV_ImportConverter'.

I didn't know if it because some of the optional parameters of these functions call appear to call for pSrc As Object

Where VB you would have to define it as pSrc As Object = Nothing

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

Re: Support Other File Types

Post by Sasha - Tracker Dev Team » Wed Jan 31, 2018 10:21 am

Hello RMan,

Here's a sample on C# (the interface declarations were provided by C# itself):

Code: Select all

public partial class CustomImportConverter : PDFXEdit.IPXV_ImportConverter
{
	private IPXV_Inst m_Inst = null;
	private IPXC_Inst m_pxcInst = null;
	public CustomImportConverter(IPXV_Inst Inst)
	{
		m_Inst = Inst;
		m_pxcInst = (IPXC_Inst)m_Inst.GetExtension("PXC");
	}

	public string Description
	{
		get
		{
			return "My Custom Description";
		}
	}

	public string Extensions
	{
		get
		{
			return "myext";
		}
	}

	public string FilterName
	{
		get
		{
			return "Extension Filter Name";
		}
	}

	public uint Flags
	{
		get
		{
			return 0;
		}
	}

	public IUIX_Icon Icon
	{
		get
		{
			return null;
		}
	}

	public string ID
	{
		get
		{
			return "conv.myCustom";
		}
	}

	public string MIME
	{
		get
		{
			return "";
		}
	}

	public string Name
	{
		get
		{
			return "Extension Filter Name";
		}
	}

	public PXV_FmtCheckResult CheckFormat(PXV_Inst pInst, object pSrc, uint nFlags = 0)
	{
		ICab pFmtDetails;
		object pCheckRes;
		return CheckFormat2(pInst, pSrc, nFlags, out pFmtDetails, out pCheckRes);
	}

	public PXV_FmtCheckResult CheckFormat2(PXV_Inst pInst, object pSrc, uint nFlags, out ICab pFmtDetails, out object pCheckRes)
	{
		pFmtDetails = null;
		pCheckRes = null;
		return PDFXEdit.PXV_FmtCheckResult.FmtCheckRes_OK;
	}

	public IPXC_Document Convert(PXV_Inst pInst, object pSrc, uint nFlags = 0, ICab pParams = null, IProgressMon pProgress = null, uint hWndParent = 0, [IUnknownConstant] object pCtx = null)
	{
		//throw new NotImplementedException();
		IPXC_Document coreDoc = m_pxcInst.NewDocument();
		PXC_Rect rc;
		rc.left = 0;
		rc.right = 500;
		rc.top = 800;
		rc.bottom = 0;
		PDFXEdit.IPXC_UndoRedoData urd;
		coreDoc.Pages.AddEmptyPages(0, 1, ref rc, null, out urd);
		return coreDoc;
	}

	public ICab CreateParams(PXV_Inst pInst)
	{
		//throw new NotImplementedException();
		return null;
	}

	public void ShowPrefsDlg(PXV_Inst pInst, ICab pParams, uint hWndParent = 0, [IUnknownConstant] object pSrc = null, uint nFlags = 0)
	{
		//throw new NotImplementedException();
	}
}
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Support Other File Types

Post by RMan » Wed Jan 31, 2018 12:12 pm

Thanks but that gave errors also which is why I think there is something wrong with how the interface itself is defined and why it won't work with VB.Net or VB6.
error CS0246: The type or namespace name 'IUnknownConstant' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'IUnknownConstantAttribute' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'IUnknownConstant' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'IUnknownConstantAttribute' could not be found (are you missing a using directive or an assembly reference?)

IF I manually remove the IUnknownConstant and IUnknownConstantAttribute then it will compile.

And also if it auto populated this shouldn't these two calls be essentially the same yet one is uint nFlags = 0 and one is uint nFlags?

public PXV_FmtCheckResult CheckFormat(PXV_Inst pInst, object pSrc, uint nFlags = 0)
{
ICab pFmtDetails;
object pCheckRes;
return CheckFormat2(pInst, pSrc, nFlags, out pFmtDetails, out pCheckRes);
}

public PXV_FmtCheckResult CheckFormat2(PXV_Inst pInst, object pSrc, uint nFlags, out ICab pFmtDetails, out object pCheckRes)
{
pFmtDetails = null;
pCheckRes = null;
return PDFXEdit.PXV_FmtCheckResult.FmtCheckRes_OK;
}

I also noticed looking at it in VB.Net that if I remove the Implements that it automatically ads in and just try to define my own interface similar like you did in C# that for the Convert and ShowPrefsDlg where it added in Optional hWndParent As UInteger = 0 automatically that if you use the ObjectBrowser it shows your interface as Optional hWndParent As ULong = 0. But even ith

Again it would be really, really great if you guys could provide full working copies in C# and VB.Net for this functionality as I'm at the limits of what I know how to do and think that it might still be a problem in the actual declaration of the interface and not what I'm doing. Although I have been known to make plenty of mistakes on my own. :)

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

Re: Support Other File Types

Post by Sasha - Tracker Dev Team » Wed Jan 31, 2018 12:30 pm

Hello RMan,

I have provided a working copy that works in C#. Just use the automatic interface implementation in Visual Studio and it should generate an interface methods that I gave you. Also, do that in VB.Net - should also work.

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

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Support Other File Types

Post by RMan » Wed Jan 31, 2018 4:26 pm

Thanks. Getting closer. I finally have been able to get it to compile in C# using your code but it doesn't appear to work.

It load the file type that I defined (*.plt) and if I select the file in the File->Open I see it's checking the Flags and the Extensions but if I hit Open it never checks the CheckFormat call or tries the Convert? I tired setting some of the Flags I thought might be needed but still no help.

I've attached up the C# VS2013 Sample I'm trying it in.
CSharp_VS2013-Revision1.zip
(544.17 KiB) Downloaded 52 times

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

Re: Support Other File Types

Post by Sasha - Tracker Dev Team » Thu Feb 01, 2018 2:41 pm

Hello RMan,

Found a small problem in one of the methods with .Net unique behavior. Fixed this - now the CheckFormat2 method is being called correctly. The fix itself will be available from the next release.

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

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Support Other File Types

Post by RMan » Thu Feb 01, 2018 3:19 pm

Thanks. I'm going to try to finish up converting the C# to VB.Net and VB6 today and I'll post those results up.

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Support Other File Types

Post by RMan » Thu Feb 01, 2018 6:53 pm

Sasha no go on getting close to being able to do anything in VB.Net and I believe it's because of multiple things on the interface declarations. Could you guys please build a simple VB.Net sample and confirm that this is going to work with VB.Net and VB6 also. From looking at the declarations that VB.Net drops in to me it appears that it shouldn't have a class based on another class to be a friendly interface to other programming languages but then also the 4 functions below I can not get it to accept.
ShowPrefsDlg in the FormatConverter

ShowPrefsDlg in the InputConverter
CheckFormat in the InputConverter
Convert in the InputConverter

Here's the latest I've been banging my head against the walls with.
VBNet_2013.zip
(562.05 KiB) Downloaded 48 times

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Support Other File Types

Post by RMan » Fri Feb 02, 2018 6:07 pm

Closer in C# at least. Using your sample code the new 2-1-2018 release fires the Convert call but it crashes at the following code in your sample:

IPXC_Document coreDoc = m_pxcInst.NewDocument();

Here's the error I get
An exception of type 'System.Runtime.InteropServices.COMException' occurred in CustomImportConverter.exe but was not handled in user code

Additional information: Bad variable type. (Exception from HRESULT: 0x80020008 (DISP_E_BADVARTYPE))

If there is a handler for this exception, the program may be safely continued.

Also still no luck with getting it to work in VB.Net or VB6 departments.

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

Re: Support Other File Types

Post by Sasha - Tracker Dev Team » Sat Feb 03, 2018 6:45 am

Hello RMan,

Well as for the C# error - I experience that as well - the strange thing is that the exception itself lies somewhere between our code and the .Net code, as the NewDocument method creates new instance of the IPXC_Document successfully and returns S_OK (what can I see from debugging inside of the method).
I think this has to do something with apartments, though it's just a guess. I've been thinking about this a little - what you can try is create a new document in the Constructor of the class - maybe that will work as it's a main thread.
I will try your VB.Net sample and see whether I can do something about it.

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

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Support Other File Types

Post by RMan » Sat Feb 03, 2018 1:22 pm

Apparently you can't do anything after you select a file. I tried passing in a blank document already and you can see by when it fires the Extension that the page count is 1. But once you select the file then the exact same call in the Extensions fails as does anything in the Convert that you might try to do with a document. And even if I don't do anything and just try to return the document object that was created when the form was created the function still fails.

Here's the new C# sample.
CSharp_VS2013-Revision2.zip
(546.61 KiB) Downloaded 46 times

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

Re: Support Other File Types

Post by Sasha - Tracker Dev Team » Mon Feb 05, 2018 12:47 pm

Hello RMan,

We are investigating the problem with VB.Net interface implementation. But I'm afraid that the usage scenario can be troublesome as with C#. There will be our dev. conference tomorrow, I will ask about the problems that you have experienced and hopefully can tell you more.

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

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Support Other File Types

Post by RMan » Tue Feb 06, 2018 11:24 pm

I should have thought about this earlier but can you guys provide a C++ example and verify that it works. I'm guessing so since I think some of your own plugins probably use the C++ interface to do it.

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Support Other File Types

Post by RMan » Tue Feb 06, 2018 11:25 pm

I should have thought about this earlier but can you guys provide a C++ example and verify that it works. I'm guessing so since I think some of your own plugins probably use the C++ interface to do it.

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

Re: Support Other File Types

Post by Sasha - Tracker Dev Team » Wed Feb 07, 2018 10:50 am

Hello RMan,

I will try implementing that one and will give you as sample. All of our inner format converters are implemented this way - there won't be any problem.

Cheers,
Alex
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: 4217
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Support Other File Types

Post by Sasha - Tracker Dev Team » Thu Feb 08, 2018 9:00 am

Hello RMan,

Just finished implementing a C++ sample for a custom import converter:
https://github.com/tracker-software/PDF ... tConverter

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

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Support Other File Types

Post by RMan » Thu Feb 08, 2018 1:50 pm

Thanks so much. I will check it out today hopefully.

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

Re: Support Other File Types

Post by Sasha - Tracker Dev Team » Thu Feb 08, 2018 1:51 pm

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

Eymann
User
Posts: 11
Joined: Tue Nov 13, 2018 7:06 am
Location: Kreuzlingen

Re: Support Other File Types

Post by Eymann » Wed Apr 24, 2019 2:45 pm

Hello RMan

I read your message of January 31, 2018.
I'm very interested in whether you could successfully convert a (.plt) file into a PDF?

I'm not a developer but the ability to convert a (.plt) file to a PDF using PDF Xchange Editor would be really cool.

Cheers
Ueli

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

Re: Support Other File Types

Post by Tracker Supp-Stefan » Thu Apr 25, 2019 2:40 pm

Hello Ueli,

There appear to be some online tools that can do such a conversion - and then you can open the PDF files in the Editor. As you do not need to do this programmatically - then maybe using such a tool would be a viable workaround for now?

Regards,
Stefan

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Support Other File Types

Post by RMan » Thu Apr 25, 2019 7:35 pm

Ueli,

Our AcroPlot software (www.cadzation.com) can convert most hpgl and hpgl2 files to PDF in batch and our AcroPlot Matrix is based off the PDF-XChange Editor. We do hope to have a plug-in to the PDF-XChange Editor in the future but no definite date set as we never seam to get enough free programming time to get back on it but I will let you know when we do.

Please note that we have had some customers who's plt files are not hpgl or hpgl2. PLT is mearly an extension meaning it's a printer ready format so from AutoCAD you could have created a plt for say an Epson specific printer or to a postscript printer but the vast majority of the time they are either hpgl or hpgl2.

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

Re: Support Other File Types

Post by Sasha - Tracker Dev Team » Mon Apr 29, 2019 7:34 am

Hello RMan,

When writing a plugin, better do this on C++ - as we've tried for ourselves, complex data handling may cause .Net related problems with memory that you cannot handle in any of ways.

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

Eymann
User
Posts: 11
Joined: Tue Nov 13, 2018 7:06 am
Location: Kreuzlingen

Re: Support Other File Types

Post by Eymann » Mon Apr 29, 2019 8:33 am

Hello everybody

Thank you for your feedback.

@ Stefan
Yes, we have tried some online tools, but apparently our .plt file is not in hpgl format.
We then had success with the software SPlot https://www.pdf-plt-planbetrachter.de/. With SPlot we could from the PLT. File a .DXF file to create a PDF.
Creating a PDF directly was not possible.
We'll probably rarely get .PLT files that we need to convert to a PDF, but it would be nice if you included this fringe of file in the development of PDF XChange (long term).

@RMan
Yes, with the HPGL / HPGL2 formats it really seems to be a problem.
We own a licensed AutoCAD MAP 3D version 2019 and even with this software with the function "PLT2DWG" it was not possible to generate a DWG from the .PLT file. Because the .PLT file was not created with an HPGL / HPGL2 driver, AutoCAD can not convert it to a DWG.

We got the .PLT file from an external office (probably architecture) and we do not know what software the file was created with.
@RMan, I have attached the file here, if you like, you are welcome to test the file.

Wish everyone a pleasant day,
Ueli
Attachments
Revisionsplan_Lüftung_1OG-a.zip
(644.02 KiB) Downloaded 27 times

Post Reply