Combining Two Documents

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

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

Post Reply
TomChandler
User
Posts: 17
Joined: Wed May 02, 2018 6:58 pm

Combining Two Documents

Post by TomChandler » Fri Apr 19, 2019 6:55 pm

I have this code for combining two documents, but when I get to the last statement, it throws the error on the DoDocumentVerb line.. I'm not sure what I'm missing, or if there's a better way to do what I'm trying to accomplish.


_viewer.SetProperty(@"Operations.InsertPages.RangeType", @"Exact");
_viewer.SetProperty(@"Operations.InsertPages.FromExternal", 0);
_viewer.SetProperty(@"Operations.InsertPages.DocID", sourceId);
_viewer.SetProperty(@"Operations.InsertPages.InsertBefore", 0);

_viewer.DoDocumentVerb(targetId, null, @"InsertPages", null, out _, (int) PXCVA_Flags.PXCVA_NoUI);


System.Exception
HResult=0x80131500
Message=0. See inner exception for details.

Inner Exception 1:
COMException: Exception from HRESULT: 0x82130001

StackTrace:
at PDFXCviewAxLib.IPDFXCview2.DoDocumentVerb(Int32 ID, String ObjectName, String OperationName, Object DataIn, Object& DataOut, Int32 Flags)
at AxPDFXCviewAxLib.AxCoPDFXCview.DoDocumentVerb(Int32 iD, String objectName, String operationName, Object dataIn, Object& dataOut, Int32 flags)
at Teleport.PdfViewer.ViewerExceptionDecorator.<>c__DisplayClass9_0.<DoDocumentVerb>b__0(Object& d) in C:\\Palabra\\.NET\\Teleport\\Teleport.PdfViewer\\ViewerExceptionDecorator.cs:line 23
at Teleport.PdfViewer.ViewerExceptionDecorator.Run[T](T& input, OutAction`1 act) in C:\\Palabra\\.NET\\Teleport\\Teleport.PdfViewer\\ViewerExceptionDecorator.cs:line 66" string

TomChandler
User
Posts: 17
Joined: Wed May 02, 2018 6:58 pm

Re: Combining Two Documents

Post by TomChandler » Fri Apr 19, 2019 7:21 pm

Never mind, I figured out I had modified some parameters from the example, but not all the ones I needed. I got it to work without error now.

This was the code I ended up with:
_viewer.SetProperty(@"Operations.InsertPages.FromExternal", 0);
_viewer.SetProperty(@"Operations.InsertPages.DocID", sourceId);
_viewer.SetProperty(@"Operations.InsertPages.InsertBefore", 0);

_viewer.DoDocumentVerb(targetId, null, @"InsertPages", null, out _, (int) PXCVA_Flags.PXCVA_NoUI);

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

Re: Combining Two Documents

Post by Tracker Supp-Stefan » Tue Apr 23, 2019 11:41 am

:D

TomChandler
User
Posts: 17
Joined: Wed May 02, 2018 6:58 pm

Re: Combining Two Documents

Post by TomChandler » Tue Apr 23, 2019 1:38 pm

So I wanted to close the source document when this was done, but when I do that the original document disappears.

var sourceId = 4096;
var targetId = 4095;

_viewer.SetProperty(@"Operations.InsertPages.FromExternal", 0);
_viewer.SetProperty(@"Operations.InsertPages.DocID", sourceId);
_viewer.SetProperty(@"Operations.InsertPages.InsertBefore", 0);

_viewer.DoDocumentVerb(targetId, null, @"InsertPages", null, out _, (int) PXCVA_Flags.PXCVA_NoUI);

// this is the line that always seems to close the first tab regardless of the documentId
_viewer.DoDocumentVerb(sourceId, null, @"CloseDocument", null, out _, (int) PXCVA_Flags.PXCVA_NoUI);

In the end, I"m left with 4096 regardless of whether I close sourceId or targetId.

Is there an additional step I need to take to allow the combine to complete before I close the original document?

Post Reply