Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, 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
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by zarkogajic »

Hi Support,

Say I want to convert a Word DOC to PDF (IPXC_Document).

I can use op.openDoc IOperation with NativeOnly = false.
I can use IPXV_ImportConverter.Convert (after locating the correct converter).

Is IPXV_ImportConverter.Convert internally used by op.openDoc ?

If not, what's the (significant, only related to conversion) difference in using one approach vs another?

Also, please confirm that ICab pParams in Convert method *only* deals with options such as (for Word):

image.png

If so, how can I change, for example, "Convert with Markup" if using op.openDoc ?


Finally, what would be the IUnknown* pCtx in Convert method ?


-žarko
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by zarkogajic »

Support ?

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

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

The op.openDoc operation tries all of the available registered converters (including the plugins) if the native converter returns that the opened file is not a PDF file. And yes, the IPXV_ImportConverter::Convert is used internally to do the conversion.
The difference in approaches, that some files can be theoretically opened by different converters - for example Text to PDF can process the CSV file that is normally being handled by the CSVToPDF converter. Meaning that if you want some specific converter to do the processing of the given file - then the IPXV_ImportConverter should be used directly. If you want us to find out which converter should be used for the given file automatically - then use the op.openDoc operation.

The ICab* pParams holds only the "Options" node (no Input or Output whatsoever), meaning that you can access to the needed setting from it directly.

The context interface can hold some additional data for the converter to work. It's being returned by the CheckFormat2 method in the IUnknown** pCheckRes parameter.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by zarkogajic »

Hi Alex,

Thanks, all clear on what happens behind the scenes.
The ICab* pParams holds only the "Options" node (no Input or Output whatsoever), meaning that you can access to the needed setting from it directly.
Can you give an example? Am not sure how to use this.


-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

For example we have this code for some operation:

Code: Select all

//C#
private void SetAnnotationData(PDFXEdit.IPXV_Document Doc, PDFXEdit.IPXV_Inst Inst, PDFXEdit.IPXC_Annotation Annotation)
{
	//In this sample the Free Text Annotation is used
	PDFXEdit.IPXC_AnnotData_FreeText FTData = (PDFXEdit.IPXC_AnnotData_FreeText)Annotation.Data;
	FTData.Contents = "Test String";
	int nID = Inst.Str2ID("op.annot.setData", false);
	PDFXEdit.IOperation Op = Inst.CreateOp(nID);
	PDFXEdit.ICabNode input = Op.Params.Root["Input"];
	input.Add().v = Annotation;
	PDFXEdit.ICabNode options = Op.Params.Root["Options"];
	options["NewData"].v = FTData;
	Op.Do();
}
In your case, the ICab pParams holds the Options dictionary:

Code: Select all

pParams.Root["NeededValue"].v = "Some Data";
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by zarkogajic »

Hi Alex,

Yes, that part is clear.

But the "NeededValue" is what I do not know, for the set of options in the Options dialog in my initial post.

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

The possible values are:

Code: Select all

	{ L"MacroSecurity",				dt_Int,			0,					OfficeMacroSec_ForceDisable},
	{ L"AllowConvFromRTF",			dt_Bool,	0,		_N(true),						&g_NamedBool },
	{ L"ConvertWithMarkup",			dt_Bool,	0,		_N(false),						&g_NamedBool },
	//Options from MS Word
	{ L"UpdateFields",				dt_Int,		0,		Off2PdfWordOptVal_Default,		},
Enum values:

Code: Select all

enum OfficeMacroSecurity
{
	OfficeMacroSec_Undefined	= 0,
	OfficeMacroSec_Low			= 1,	//enable all macros
	OfficeMacroSec_ByUI			= 2,	//normally not used (not reasonable, because user can't press office macro-security UI button when opening office doc with Editor)
	OfficeMacroSec_ForceDisable = 3		//disable all macros
};

enum Office2PDFWordOptValue
{
	Off2PdfWordOptVal_Default	= 0, //use MS Word's current value
	Off2PdfWordOptVal_Yes		= 1,
	Off2PdfWordOptVal_No		= 2,
};
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by zarkogajic »

HI Alex,

Yes, that's it, thanks!

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by zarkogajic »

Alex,

When using op.openDoc to do conversion - I cannot set those, correct?

Can those be set via something like Inst.Settings[] ?



-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Try changing those and see where are they being written in the registry. If they are - then you can tweak them.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by zarkogajic »

Alex,

But what values to use in Inst.Settings[???] ?


-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

The settings path would be "Converters.Import.<Converter ID with . replaced as _>".
For example

Code: Select all

 Inst.Settings["Converters.Import.conv_imp_office_doc.AllowConvFromRTF"] = true;
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by zarkogajic »

HI Alex,

Fantastic!

And the "corresponding" PXV_AppPrefsChanges for Inst.FireAppPrefsChanged ?

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

I don't see any particular event. Probably it's not needed in this case.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert  SOLVED

Post by zarkogajic »

Alex,

Ok. Thanks!

p.s.
And all the best in, hopefully better, 2021!

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

Re: Convert to PDF: op.openDoc (NativeOnly == false) vs IPXV_ImportConverter.Convert

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

And best wishes for you too :)

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply