extern "C"
{
DLLIMPORTEXPORT NOPackageHandler NOPackage_create(NCommon::UInt32 pCreateEmptyDoc, NCommon::UTF8Char *pName);
DLLIMPORTEXPORT void NOPackage_destroyPackage(NOPackageHandler* pPackage);
DLLIMPORTEXPORT NOPackageHandler NOPackage_readPackageFromFile(NCommon::UTF8Char *pFilename);
DLLIMPORTEXPORT void NOPackage_writePackageToFile(NOPackageHandler* pPackage, NCommon::UTF8Char *pFilename);
DLLIMPORTEXPORT void NOPackage_save(NOPackageHandler* pPackage);
DLLIMPORTEXPORT void NOPackage_getFilename(NOPackageHandler* pPackage, NOStringHandler* pString);
DLLIMPORTEXPORT void NOPackage_setFilename(NOPackageHandler* pPackage, NCommon::UTF8Char* pString);
DLLIMPORTEXPORT NCommon::UInt32 NOPackage_hasFilename(NOPackageHandler* pPackage);
DLLIMPORTEXPORT NCommon::UInt32 NOPackage_getDirty(NOPackageHandler* pPackage);
DLLIMPORTEXPORT NCommon::UInt32 NOPackage_hasCoreProperties(NOPackageHandler* pPackage);
DLLIMPORTEXPORT NOCorePropertiesHandler NOPackage_getCoreProperties(NOPackageHandler* pPackage);
DLLIMPORTEXPORT NOCorePropertiesHandler NOPackage_createCoreProperties(NOPackageHandler* pPackage);
DLLIMPORTEXPORT NCommon::UInt32 NOPackage_getNumberOfDocuments(NOPackageHandler* pPackage);
DLLIMPORTEXPORT NODocumentHandler NOPackage_getDocument(NOPackageHandler* pPackage, NCommon::UInt32 pNum);
DLLIMPORTEXPORT void NOPackage_addDocument(NOPackageHandler* pPackage, NODocumentHandler pDoc, NOProgressReporterHandler pReporter);
DLLIMPORTEXPORT NCommon::UInt32 NOPackage_getDocumentNumberOf(NOPackageHandler* pPackage, NODocumentHandler pDoc);
DLLIMPORTEXPORT NCommon::UInt32 NOPackage_hasThumbnail(NOPackageHandler* pPackage);
DLLIMPORTEXPORT NOThumbnailHandler NOPackage_getThumbnail(NOPackageHandler* pPackage);
DLLIMPORTEXPORT NCommon::UInt32 NOPackage_getNumberOfPages(NOPackageHandler* pPackage);
}
DLLIMPORTEXPORT NOPackageHandler NOPackage_create(NCommon::UInt32 pCreateEmptyDoc, NCommon::UTF8Char *pName);
DLLIMPORTEXPORT void NOPackage_destroyPackage(NOPackageHandler* pPackage);
DLLIMPORTEXPORT NOPackageHandler NOPackage_readPackageFromFile(NCommon::UTF8Char *pFilename);
DLLIMPORTEXPORT void NOPackage_writePackageToFile(NOPackageHandler* pPackage, NCommon::UTF8Char *pFilename);
DLLIMPORTEXPORT NODocumentHandler NOPackage_getDocument(NOPackageHandler* pPackage, NCommon::UInt32 pNum);
DLLIMPORTEXPORT void NOPackage_addDocument(NOPackageHandler* pPackage, NODocumentHandler pDoc, NOProgressReporterHandler pReporter);
Imports System.Runtime.InteropServices
Imports System.Text
Module Module1
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
Public Structure Handler
Public mPackage As Integer
Public mID As Short
Public mType As Integer
Public mError As Integer
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
Public Structure ProgressReporterHandler
Public mFunction As Integer
Public mHandler As Integer
End Structure
' Package functions we need
Declare Function NOPackage_readPackageFromFile Lib "NiXPSAccess_D.dll" (ByVal pFilename As String) As Handler
Declare Sub NOPackage_destroyPackage Lib "NiXPSAccess_D.dll" (ByRef pPackage As Handler)
Declare Sub NOPackage_writePackageToFile Lib "NiXPSAccess_D.dll" (ByRef pPackage As Handler, ByVal pFilename As String)
Declare Function NOPackage_create Lib "NiXPSAccess_D.dll" (ByVal pCreateEmptyDoc As Integer, ByVal pFilename As String) As Handler
Declare Sub NOPackage_addDocument Lib "NiXPSAccess_D.dll" (ByRef pPackage As Handler, ByVal pDocument As Handler, ByVal pReporter As ProgressReporterHandler)
Declare Function NOPackage_getDocument Lib "NiXPSAccess_D.dll" (ByRef pPackage As Handler, ByVal pNum As Integer) As Handler
Sub Main()
Dim lFileHandler, lFileOutHandler As Handler
Dim lDoc As Handler
Dim lProgress As ProgressReporterHandler
Dim lFile1 As String = "interface.xps"
Dim lFile2 As String = "Office2007.xps"
Dim lFileOut As String = "out.xps"
lProgress.mFunction = 0
lProgress.mHandler = 0
' create a new XPS file (package) which contains all the documents
lFileOutHandler = NOPackage_create(0, lFileOut)
' Open lFile1, get the first document, and insert it in the output document, close again
lFileHandler = NOPackage_readPackageFromFile(lFile1)
lDoc = NOPackage_getDocument(lFileHandler, 0)
NOPackage_addDocument(lFileOutHandler, lDoc, lProgress)
NOPackage_destroyPackage(lFileHandler)
' Same procedure for lFile2
lFileHandler = NOPackage_readPackageFromFile(lFile2)
lDoc = NOPackage_getDocument(lFileHandler, 0)
NOPackage_addDocument(lFileOutHandler, lDoc, lProgress)
NOPackage_destroyPackage(lFileHandler)
' write out the resulting XPS doc, and clean-up
NOPackage_writePackageToFile(lFileOutHandler, lFileOut)
NOPackage_destroyPackage(lFileOutHandler)
End Sub
Subscribe to
Posts [Atom]