Combining Two Documents

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

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

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

Combining Two Documents

Post by TomChandler »

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: 21
Joined: Wed May 02, 2018 6:58 pm

Re: Combining Two Documents

Post by TomChandler »

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: 17823
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Combining Two Documents

Post by Tracker Supp-Stefan »

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

Re: Combining Two Documents

Post by TomChandler »

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