I am developing a simple c# application to save a pdf file as pdf/a file using
only PDF-XChange Editor SDK and not using IPXV_Control. After refering few forums I got this code
Code: Select all
PXV_Inst pxvInst = new PXV_Inst();
pxvInst.Init();
pxvInst.StartLoadingPlugins();
pxvInst.AddPluginFromFile(@"E:\PDFAPlugin.pvp");
pxvInst.FinishLoadingPlugins();
PDFXEdit.IAFS_Inst fsInst = pxvInst.GetExtension("AFS");
PDFXEdit.IAFS_Name destPath = fsInst.DefaultFileSys.StringToName(@"E:\Destec_RCJ.pdf");
int openFileFlags = (int)(PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_CreateAlways | PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_Read | PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_Write | PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_FullCache);
PDFXEdit.IAFS_File destFile = fsInst.DefaultFileSys.OpenFile(destPath, openFileFlags);
PDFXEdit.IPXV_ExportConverter cnv = null;
IPXC_Inst docInst = (PXC_Inst)pxvInst.GetExtension("PXC");
IPXC_Document srcDoc = docInst.OpenDocumentFromFile(@"E:\Destec_RCJ.pdf", null);
for (uint i = 0; i < pxvInst.ExportConvertersCount; i++)
{
if (pxvInst.ExportConverter[i].ID == "conv.exp.pdfa")
cnv = pxvInst.ExportConverter[i];
}
if (cnv != null)
{
cnv.Convert(pxvInst, srcDoc, destFile);
}
It throws a com exception on following line
Code: Select all
IPXC_Document srcDoc = docInst.OpenDocumentFromFile(@"E:\Destec_RCJ.pdf", null);
Please correct me where I am doing wrong.'Exception from HRESULT: 0x83FF0020'.