Hi,
I would like to use the pdfx UI for comparing two pdf files.
correction-I would like to compare two pdf files programmatically and show the compare window of PDFXedit. I will provide files programmatically, do compare operation and then show the result in the PDFXedit control as shown here- Pls see the attached screenshot-
compare pdf documents using pdfxchange interface
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
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.
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.
-
charuvasudev
- User
- Posts: 16
- Joined: Wed Feb 11, 2009 5:48 am
compare pdf documents using pdfxchange interface
You do not have the required permissions to view the files attached to this post.
-
Vasyl - PDF-XChange
- Site Admin
- Posts: 2468
- Joined: Thu Jun 30, 2005 4:11 pm
Re: compare pdf documents using pdfxchange interface
Hi charuvasudev .
The pseudocode:
HTH
The pseudocode:
Code: Select all
PXV_Inst inst;
...
IPXC_Document doc1 = inst.OpenDocumentFromFile("C:\\doc1.pdf", null);
IPXC_Document doc2 = inst.OpenDocumentFromFile("C:\\doc2.pdf", null);
IOperation op = inst.CreateOp(inst.Str2ID("op.compareDocs");
ICabNode inp = op.Params.Root["Input"];
inp.Add().v = doc1;
inp.Add().v = doc2;
ICabNode opt = op.Params.Root["Options"];
try
{
op.Do();
}
catch { }
doc1.Close();
doc2.Close();
doc1 = null;
doc2 = null;
IPXC_Document cmpReportDoc;
if (otp.Count != 0)
cmpReportDoc = (IPXC_Document)otp[0].v;
op = null;
if (cmpReportDoc != null)
inst.OpenDocumentFrom(cmpReportDoc, null); // opens in UIPDF-XChange Co. LTD (Project Developer)
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
charuvasudev
- User
- Posts: 16
- Joined: Wed Feb 11, 2009 5:48 am
Re: compare pdf documents using pdfxchange interface
Hi,
I tried to implement your code. But I am getting error- at
cmpReportDoc =opt(0).v
error is-
Unable to cast object of type 'System.Int32' to type 'PDFXEdit.IPXC_Document'.'
Here is my code-
Dim pxcInst As PDFXEdit.IPXC_Inst = CType(Inst1.GetExtension("PXC"), PDFXEdit.IPXC_Inst)
Dim doc1 As PDFXEdit.IPXC_Document = pxcInst.OpenDocumentFromFile(FileNames(0), Nothing)
Dim doc2 As PDFXEdit.IPXC_Document = pxcInst.OpenDocumentFromFile(FileNames(1), Nothing)
Dim op As IOperation = Inst1.CreateOp(Inst1.Str2ID("op.compareDocs"))
Dim inp As ICabNode = op.Params.Root("Input")
inp.Add().v = doc1
inp.Add().v = doc2
Dim opt As ICabNode = op.Params.Root("Options")
Try
op.Do()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
doc1.Close()
doc2.Close()
doc1 = Nothing
doc2 = Nothing
Dim cmpReportDoc As IPXC_Document
If opt.Count <> 0 Then
cmpReportDoc = opt(0).v //this line throws error
End If
op = Nothing
If (cmpReportDoc IsNot Nothing) Then
pxcInst.OpenDocumentFrom(cmpReportDoc, Nothing) ' opens In UI
End If
End If
I tried to implement your code. But I am getting error- at
cmpReportDoc =opt(0).v
error is-
Unable to cast object of type 'System.Int32' to type 'PDFXEdit.IPXC_Document'.'
Here is my code-
Dim pxcInst As PDFXEdit.IPXC_Inst = CType(Inst1.GetExtension("PXC"), PDFXEdit.IPXC_Inst)
Dim doc1 As PDFXEdit.IPXC_Document = pxcInst.OpenDocumentFromFile(FileNames(0), Nothing)
Dim doc2 As PDFXEdit.IPXC_Document = pxcInst.OpenDocumentFromFile(FileNames(1), Nothing)
Dim op As IOperation = Inst1.CreateOp(Inst1.Str2ID("op.compareDocs"))
Dim inp As ICabNode = op.Params.Root("Input")
inp.Add().v = doc1
inp.Add().v = doc2
Dim opt As ICabNode = op.Params.Root("Options")
Try
op.Do()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
doc1.Close()
doc2.Close()
doc1 = Nothing
doc2 = Nothing
Dim cmpReportDoc As IPXC_Document
If opt.Count <> 0 Then
cmpReportDoc = opt(0).v //this line throws error
End If
op = Nothing
If (cmpReportDoc IsNot Nothing) Then
pxcInst.OpenDocumentFrom(cmpReportDoc, Nothing) ' opens In UI
End If
End If
-
MishaH
- User
- Posts: 28
- Joined: Wed Sep 11, 2024 1:43 pm
Re: compare pdf documents using pdfxchange interface
Hi charuvasudev,
Unfortunately, there is a typo in one important line in the code sample provided by Vasyl.
The result of the operation is stored in the "Output" cab node, not in "Options".
So the correct way to retrieve the document is as follows:
Please let me know if this works for you.
Kind regards,
Misha
Unfortunately, there is a typo in one important line in the code sample provided by Vasyl.
The result of the operation is stored in the "Output" cab node, not in "Options".
So the correct way to retrieve the document is as follows:
Code: Select all
Dim output As ICabNode = op.Params.Root("Output")
If output.Count <> 0 Then
cmpReportDoc = output(0).v
End IfKind regards,
Misha
-
charuvasudev
- User
- Posts: 16
- Joined: Wed Feb 11, 2009 5:48 am
Re: compare pdf documents using pdfxchange interface
issue solved
thank you
thank you
-
Daniel - PDF-XChange
- Site Admin
- Posts: 12219
- Joined: Wed Jan 03, 2018 6:52 pm
compare pdf documents using pdfxchange interface
Dan McIntyre - Support Technician
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com