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.
baumunk
User
Posts: 38 Joined: Fri Nov 13, 2020 8:47 am
Post
by baumunk » Tue Apr 27, 2021 9:25 am
When converting a PDF to PDF/A I often get this error
Code:
Code: Select all
PDFXEdit.IPXV_ExportConverter cnv = null;
for (uint i = 0; i < Inst.ExportConvertersCount; i++)
{
if (Inst.ExportConverter[i].ID != "conv.exp.pdfa") continue;
cnv = Inst.ExportConverter[i];
break;
}
if (cnv == null) return;
var cab = Inst.GetFormatConverterParams(false, "conv.exp.pdfa");
PDFXEdit.ICabNode convParamsRoot = cab.Root;
var format = p.Format.ToString();
var z = format.Substring(format.IndexOf('_') + 1, 2);
int partIndex;
int conformanceIndex;
switch (z[0])
{
case '1':
partIndex = 1;
break;
case '3':
partIndex = 3;
break;
default:
partIndex = 2;
break;
}
switch (z[1])
{
case 'A':
conformanceIndex = 0;
break;
case 'U':
conformanceIndex = 2;
break;
default:
conformanceIndex = 1;
break;
}
convParamsRoot.SetInt("Part", partIndex);
convParamsRoot.SetInt("Conformance", conformanceIndex);
convParamsRoot.SetInt("ShowReport", 0);
convParamsRoot.SetString("ErrorMessage", "true");
IAFS_Inst fsInst = Inst.GetExtension("AFS");
var destPath = fsInst.DefaultFileSys.StringToName(ziel);
const int openFileFlags = (int)(AFS_OpenFileFlags.AFS_OpenFile_CreateAlways | AFS_OpenFileFlags.AFS_OpenFile_Read | AFS_OpenFileFlags.AFS_OpenFile_Write | AFS_OpenFileFlags.AFS_OpenFile_FullCache);
var destFile = fsInst.DefaultFileSys.OpenFile(destPath, openFileFlags);
IPXC_Inst docInst = (PXC_Inst)Inst.GetExtension("PXC");
var srcDoc = docInst.OpenDocumentFromFile(quelle, null);
try
{
cnv.Convert(Inst, srcDoc, destFile, 0, cab); //-> Error
}
catch (Exception exp)
{
Inst.ClearHistory(true);
destFile.Close();
srcDoc.Close();
throw new PDFConvertException("Fehler bei Konvertierung", exp);
}
How can I find out what is causing this?
Where can I read the error code?
"E_FAIL" is not meaningful.
With kind regards
Ernest Baumunk
Sasha - Tracker Dev Team
User
Posts: 5522 Joined: Fri Nov 21, 2014 8:27 am
Contact:
Post
by Sasha - Tracker Dev Team » Tue Apr 27, 2021 11:23 am
Hello baumunk,
Try saving this document to PDF/A via the End-User Editor - you will encounter the error there:
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
baumunk
User
Posts: 38 Joined: Fri Nov 13, 2020 8:47 am
Post
by baumunk » Wed Apr 28, 2021 8:33 am
Hello Alex
When I:
Code: Select all
convParamsRoot.SetInt("ShowReport", 1);
I see the report window.
When converting one PDF file all right.
But if there are 100 PDF and 5 are error?
Is it possible to read error list in code?
Sasha - Tracker Dev Team
User
Posts: 5522 Joined: Fri Nov 21, 2014 8:27 am
Contact:
Post
by Sasha - Tracker Dev Team » Wed Apr 28, 2021 10:55 am
Hello baumunk,
Here's a sample that I have that should help:
Code: Select all
IPXV_ExportConverter cnv = null;
for (uint i = 0; i < pdfCtl.Inst.ExportConvertersCount; i++)
{
if (pdfCtl.Inst.ExportConverter[i].ID == "conv.exp.pdfa")
cnv = pdfCtl.Inst.ExportConverter[i];
}
if ((cnv == null) || (pdfCtl.Doc == null))
return;
PDFXEdit.ICab cab = pdfCtl.Inst.GetFormatConverterParams(false, "conv.exp.pdfa");
PDFXEdit.ICabNode convParamsRoot = cab.Root;
//<!-- 1 - PDF/A-1; 2 - PDF/A-2; 3 - PDF/A-3 -->
//<Item id="Part" type="Int" defVal="2" />
//<!-- 0 - -a; 1 - -b; 2 - -u; -->
//<Item id="Conformance" type="Int" defVal="1" />
//This will do PDF/A-2b
convParamsRoot.SetInt("Part", 2);
convParamsRoot.SetInt("Conformance", 1);
convParamsRoot.SetInt("ShowReport", 0);
convParamsRoot.SetString("ErrorMessage", "");
LogListener ll = new LogListener();
auxInst.LogServer.RegisterListener(ll);
PDFXEdit.IAFS_Inst fsInst = (PDFXEdit.IAFS_Inst)pdfCtl.Inst.GetExtension("AFS");
PDFXEdit.IAFS_Name destPath = fsInst.DefaultFileSys.StringToName("D:\\TestFile.pdf");
cnv.Convert(pdfCtl.Inst, pdfCtl.Doc.CoreDoc, destPath, (uint)PXV_AppTypeFlags.PXV_AppType_Tools, cab);
MessageBox.Show(ll.m_sData);
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
baumunk
User
Posts: 38 Joined: Fri Nov 13, 2020 8:47 am
Post
by baumunk » Thu Apr 29, 2021 8:08 am
Hello Alex,
I have changed as you suggested:
Code: Select all
public class PDFLog : PDFXEdit.ILogListener
{
public List<PDFLogItem> Logs { get; } = new List<PDFLogItem>();
public string Message
{
get
{
var b = new StringBuilder();
foreach (var i in Logs)
{
b.AppendLine($"{i.Type}: '{i.Text}'");
}
return b.ToString();
}
}
public void OnLogMsg(LogMsgType nType, ILogMsg pMsg)
{
Logs.Add(new PDFLogItem(nType, pMsg));
}
}
public class PDFLogItem
{
public LogMsgType Type { get; }
public string Text { get; }
internal PDFLogItem(LogMsgType nType, ILogMsg pMsg)
{
Type = nType;
Text = pMsg.Text;
}
}
Code: Select all
var ll = new PDFLog();
IPXC_Inst docInst = (PXC_Inst)Inst.GetExtension("PXC");
var auxInst = (PDFXEdit.IAUX_Inst)Inst.GetExtension("AUX");
auxInst.LogServer.RegisterListener(ll);
OnLogMsg is never called though.
With kind regards
Ernest Baumunk
Vasyl-Tracker Dev Team
Site Admin
Posts: 2353 Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada
Post
by Vasyl-Tracker Dev Team » Tue Nov 09, 2021 7:00 pm
Hi Ernest.
OnLogMsg is never called though.
Yes, you are right, unfortunately. Problem is that this operation doesn't write to the Log in SDK mode. We will remove that unnecessary restriction, and soon.
Cheers.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
zarkogajic
User
Posts: 1371 Joined: Thu Sep 05, 2019 12:35 pm
Post
by zarkogajic » Fri Apr 29, 2022 1:45 pm
Hi Vasyl,
Was this restriction removed in recent versions (9.3.*) ?
-žarko
Vasyl-Tracker Dev Team
Site Admin
Posts: 2353 Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada
Post
by Vasyl-Tracker Dev Team » Sat Apr 30, 2022 3:31 am
Yes, seems it was removed in 359 build.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
TrackerSupp-Daniel
Site Admin
Posts: 8588 Joined: Wed Jan 03, 2018 6:52 pm
Post
by TrackerSupp-Daniel » Wed May 04, 2022 6:49 pm
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com