The data stream generated by the Document Converter products can be intercepted for processing other than the default saving to a file or sending by e-mail. The data stream can be sent to a remote location without being saved to the local hard drive, or sent to an application that needs to do some specific processing with the stream before saving it to file.
This method needs special license. Please, contact our Sales Department for more information
To intercept the data stream, the below steps should be followed:
Create a Custom Dynamic Link Library (DLL) in C++ following the framework described below.
Copy the Custom DLL to the %windir%\system or %windir%\system32 directory.
Set the SendToCreator option in the FileNameOptionsEx method or function call.
Set the PageProcessor parameter using SetPageProcessor or PageProcessor property. This parameter should be set to the name of the custom DLL and only when logged in as Administrator.
// *************** File name: custompp.def ******************
LIBRARY custompp
DESCRIPTION ' Custom Page Processor DLL'
EXPORTS
PPInit
PPStartDoc
PPEndDoc
PPStartPage
PPEndPage
PPStartObject
PPEndObject
PPWriteBuffer
// *************** End of: custompp.def ******************
// *************** File name: custompp.h ******************
typedef LPVOID DOCHANDLE;
typedef DOCHANDLE* LPDOCHANDLE;
int WINAPI PPInit();
int WINAPI PPStartDoc(LPDOCHANDLE phDoc, DWORD dwFlags);
int WINAPI PPEndDoc(DOCHANDLE hDoc);
int WINAPI PPStartPage(DOCHANDLE hDoc);
int WINAPI PPEndPage(DOCHANDLE hDoc);
int WINAPI PPStartObject(DOCHANDLE hDoc);
int WINAPI PPEndObject(DOCHANDLE hDoc);
int WINAPI PPWriteBuffer(DOCHANDLE hDoc, LPBYTE pData, DWORD dwSize);
// *************** End of: custompp.h ******************
// *************** File name: custompp.c ******************
#include "Windows.h"
#include "custompp.h"
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
// standard DLL entry point
return TRUE;
}
int WINAPI PPInit()
{
// called when the DLL is initialized, and before the call to StartDoc
return 0;
}
int WINAPI PPStartDoc(LPDOCHANDLE phDoc, DWORD dwFlags)
{
// called when a new document is started
// dwFlags is 1 if the user requested the document to be printed to a physical printer
if (!phDoc)
return -1;
// create a new PDF file
*phDoc = (LPDOCHANDLE)CreateFile( "c:\\test.pdf", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL );
if ( *phDoc )
MessageBox( 0, "StartDoc", "Success", 0 );
else
MessageBox( 0, "StartDoc", "Failure", 0 );
return 0;
}
int WINAPI PPEndDoc(DOCHANDLE hDoc)
{
// document printing has ended
if (!hDoc)
return -1;
// close the destination PDF file
CloseHandle( (HANDLE)hDoc );
return 0;
}
int WINAPI PPStartPage(DOCHANDLE hDoc)
{
// a new page is started
if (!hDoc)
return -1;
return 0;
}
int WINAPI PPEndPage(DOCHANDLE hDoc)
{
// page ended printing
if (!hDoc)
return -1;
return 0;
}
int WINAPI PPStartObject(DOCHANDLE hDoc)
{
// a new PDF object is being started
// each document and page can contain a number of PDF objects
if (!hDoc)
return -1;
return 0;
}
int WINAPI PPEndObject(DOCHANDLE hDoc)
{
// finished outputting a PDF object
if (!hDoc)
return -1;
return 0;
}
int WINAPI PPWriteBuffer(DOCHANDLE hDoc, LPBYTE pData, DWORD dwSize)
{
// block of data data sent from document converter
// dwSize is the number of output bytes
DWORD dwWritten = 0;
if (!hDoc)
return -1;
// simply write data to file
if ( WriteFile( (HANDLE)hDoc, pData, dwSize, &dwWritten, NULL ) == FALSE )
return -1;
return 0;
}
Module Module1
<Flags()>
Public Enum acFileNameOptions As Integer
NoPrompt = &H1
UseFileName = &H2
Concatenate = &H4
DisableCompression = &H8
EmbedFonts = &H10
BroadcastMessages = &H20
PrintWatermark = &H40
MultilingualSupport = &H80
EncryptDocument = &H100
FullEmbed = &H200
UseTcpIpServer = &H400
SendByEmail = &H800
ConfirmOverwrite = &H1000
AppendExisting = &H2000
AddDateTime = &H3000
AddIdNumber = &H4000
LinearizeForWeb = &H8000
PostProcessing = &H10000
QualityLevelLow = &H20000
QualityLevelMedium = &H40000
QualityLevelHigh = &H60000
Colors2GrayScale = &H80000
ConvertHyperlinks = &H100000
EmbedStandardFonts = &H200000
EmbedLicensedFonts = &H400000
Color256Compression = &H800000
Jpeg2000Compression = &H1000000
SendToCreator = &H2000000
ExportToHTML = &H4000000
ExportToRTF = &H8000000
ExportToJPEG = &H10000000
CCITTCompression = &H20000000
EncryptDocument128 = &H40000000
AutoImageCompression = &H80000000
End Enum
Sub Main()
' Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Converter Evaluation"
Const strActivationCode As String = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
Const AMYUNIPRINTERNAME As String = "Amyuni PDF Converter"
' Declare a new cdintfex object if it does not exist in the form.
Dim PDF As New CDIntfEx.CDIntfEx
' Get a reference to the installed printer.
' This will fail if the printer name passed to the DriverInit method is
' not found in the printer’s folder
PDF.DriverInit(AMYUNIPRINTERNAME)
' The SetDefaultPrinter function sets the system default printer to the one
' initialized by the DriverInit functions.
PDF.SetDefaultPrinter()
' The EnablePrinter() method needs to be called right before each print job.
' and before the configuration
' Calling the EnablePrinter() method will start a 20 second time-out value
PDF.EnablePrinter(strLicenseTo, strActivationCode)
' Set Printer options
PDF.FileNameOptionsEx = acFileNameOptions.SendToCreator
' Set Custom Dll
PDF.PageProcessor = "ACPgProc.dll"
' Print a sample document
Dim fileName As String = "C:\temp\test.txt"
' The BatchConvert method converts a number of files to PDF.
PDF.BatchConvert(fileName)
' The RestoreDefaultPrinter function resets the system default printer
' to the printer that was the default before the call to SetDefaultPrinter.
PDF.RestoreDefaultPrinter()
' This function will simply detach from an existing printer because the handle was created using DriverInit
PDF.DriverEnd()
End Sub
End Module
using Microsoft.Office.Interop.Word;
using System;
namespace DataSteamConverter_CS
{
class Program
{
[Flags]
public enum acFileNameOptions
{
NoPrompt = 0x00000001,
UseFileName = 0x00000002,
Concatenate = 0x00000004,
DisableCompression = 0x00000008,
EmbedFonts = 0x00000010,
BroadcastMessages = 0x00000020,
PrintWatermark = 0x00000040,
MultilingualSupport = 0x00000080,
EncryptDocument = 0x00000100,
FullEmbed = 0x00000200,
UseTcpIpServer = 0x00000400,
SendByEmail = 0x00000800,
ConfirmOverwrite = 0x00001000,
AppendExisting = 0x00002000,
AddDateTime = 0x00003000,
AddIdNumber = 0x00004000,
LinearizeForWeb = 0x00008000,
PostProcessing = 0x00010000,
QualityLevelLow = 0x00020000,
QualityLevelMedium = 0x00040000,
QualityLevelHigh = 0x00060000,
Colors2GrayScale = 0x00080000,
ConvertHyperlinks = 0x00100000,
EmbedStandardFonts = 0x00200000,
EmbedLicensedFonts = 0x00400000,
Color256Compression = 0x00800000,
Jpeg2000Compression = 0x01000000,
SendToCreator = 0x02000000,
ExportToHTML = 0x04000000,
ExportToRTF = 0x08000000,
ExportToJPEG = 0x10000000,
CCITTCompression = 0x20000000,
EncryptDocument128 = 0x40000000,
AutoImageCompression = unchecked((int)0x80000000)
}
static void Main(string[] args)
{
// Constants for Activation codes
const string strLicenseTo = "Amyuni PDF Converter Evaluation";
const string strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";
const string AMYUNIPRINTERNAME = "Amyuni PDF Converter";
// Declare a new cdintfex object if it does not exist in the form.
CDIntfEx.CDIntfEx PDF = new CDIntfEx.CDIntfEx();
// Get a reference to the installed printer.
// This will fail if the printer name passed to the DriverInit method is
// not found in the printer’s folder
PDF.DriverInit(AMYUNIPRINTERNAME);
// The SetDefaultPrinter function sets the system default printer to the one
// initialized by the DriverInit functions.
PDF.SetDefaultPrinter();
// The EnablePrinter() method needs to be called right before each print job.
// and before the configuration
// Calling the EnablePrinter() method will start a 20 second time-out value
PDF.EnablePrinter(strLicenseTo, strActivationCode);
// Set Printer options
PDF.FileNameOptionsEx = (int)acFileNameOptions.SendToCreator;
// Set Custom Dll
PDF.PageProcessor = "ACPgProc.dll";
// Print a sample document
string fileName = @"C:\temp\test.txt";
// The BatchConvert method converts a number of files to PDF.
PDF.BatchConvert(fileName);
// The RestoreDefaultPrinter function resets the system default printer
// to the printer that was the default before the call to SetDefaultPrinter.
PDF.RestoreDefaultPrinter();
// This function will simply detach from an existing printer because the handle was created using DriverInit
PDF.DriverEnd();
// Destroy PDF object
PDF = null;
}
}
}
// PDF Converter Cpp.cpp : Defines the entry point for the console application.
//
#include <Windows.h>
#include <string>
#include <iostream>
#include "CdIntf.h"
#pragma comment (lib, "CDIntf.lib")
using namespace std;
int main()
{
// Constants for Activation codes
#define strLicenseTo "Amyuni PDF Converter Evaluation"
#define strActivationCode "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
#define AMYUNIPRINTERNAME "Amyuni PDF Converter"
// Get a reference to the installed printer.
// This will fail if the printer name passed to the DriverInit method is
// not found in the printer’s folder
HANDLE PDF = DriverInit(AMYUNIPRINTERNAME);
// The CDISetDefaultPrinter function sets the system default printer to the one
// initialized by the DriverInit functions.
CDISetDefaultPrinter(PDF);
// The EnablePrinter() method needs to be called right before each print job.
// and before the configuration
// Calling the EnablePrinter() method will start a 20 second time-out value
EnablePrinter(PDF, strLicenseTo, strActivationCode);
// Set Printer options
SetFileNameOptions(PDF, SendToCreator);
// Set Custom Dll
SetPageProcessor(PDF, "ACPgProc.dll");
// Print a sample document
LPSTR fileName = "C:\\temp\\test.txt";
// The BatchConvert method converts a number of files to PDF.
BatchConvertEx(PDF, fileName);
// The RestoreDefaultPrinter function resets the system default printer
// to the printer that was the default before the call to SetDefaultPrinter.
RestoreDefaultPrinter(PDF);
// This function will simply detach from an existing printer because the handle was created using DriverInit
DriverEnd(PDF);
// Destroy PDF object
PDF = nullptr;
return 0;
}
package Example;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
public class DataStream {
public enum acFileNameOptions
{
NoPrompt(0x00000001),
UseFileName(0x00000002),
Concatenate(0x00000004),
DisableCompression(0x00000008),
EmbedFonts(0x00000010),
BroadcastMessages(0x00000020),
PrintWatermark(0x00000040),
MultilingualSupport(0x00000080),
EncryptDocument(0x00000100),
FullEmbed(0x00000200),
UseTcpIpServer(0x00000400),
SendByEmail(0x00000800),
ConfirmOverwrite(0x00001000),
AppendExisting(0x00002000),
AddDateTime(0x00003000),
AddIdNumber(0x00004000),
LinearizeForWeb(0x00008000),
PostProcessing(0x00010000),
QualityLevelLow(0x00020000),
QualityLevelMedium(0x00040000),
QualityLevelHigh(0x00060000),
Colors2GrayScale(0x00080000),
ConvertHyperlinks(0x00100000),
EmbedStandardFonts(0x00200000),
EmbedLicensedFonts(0x00400000),
Color256Compression(0x00800000),
Jpeg2000Compression(0x01000000),
SendToCreator(0x02000000),
ExportToHTML(0x04000000),
ExportToRTF(0x08000000),
ExportToJPEG(0x10000000),
CCITTCompression(0x20000000),
EncryptDocument128(0x40000000),
AutoImageCompression(0x80000000);
private int value;
private acFileNameOptions(int value)
{
this.value = value;
}
public Object value(){
return value;
} }
public static void main(String[] args)
{
// Constants for Activation codes
String strLicenseTo = "Amyuni Tech. Evaluation";
String strActivationCode = "07EFCDAB01000100DF6EFC8664508CC905BADA9A6C56066D8219C78B8804C5D09ECA85769789782B3945B0ECA66CB3612C5D7772F0B9";
String AMYUNIPRINTERNAME = "Amyuni PDF Converter";
// Declare a new cdintfex object if it doesn' t exist in the form.
ActiveXComponent pdf = new ActiveXComponent("CDIntfEx.CDIntfEx.6.5");
// Get a reference to the installed printer.
// This will fail if the printer name passed to the DriverInit method is
// not found in the printer’s folder
Dispatch.call(pdf,"DriverInit",AMYUNIPRINTERNAME);
// The SetDefaultPrinter function sets the system default printer to the one
// initialized by the DriverInit functions.
Dispatch.call(pdf,"SetDefaultPrinter");
// The EnablePrinter()method needs to be called right before each print job.
// and before the configuration
// Calling the EnablePrinter()method will start a 20 second time-out value
Dispatch.call(pdf,"EnablePrinter", strLicenseTo, strActivationCode);
// Set Printer options
Dispatch.put(pdf,"FileNameOptionsEx",acFileNameOptions.SendToCreator.value);
// Set Custom Dll
Dispatch.put(pdf,"PageProcessor", "ACPgProc.dll");
// Print a sample document
String fileName = "C:\\temp\\test.txt";
// The BatchConvert method converts a number of files to PDF.
Dispatch.call(pdf,"BatchConvert", fileName);
// The RestoreDefaultPrinter function resets the system default printer
// to the printer that was the default before the call to SetDefaultPrinter.
Dispatch.call(pdf,"RestoreDefaultPrinter");
// This function will simply detach from an existing printer because the handle was created using DriverInit
Dispatch.call(pdf,"DriverEnd");
}
}
$acFileNameOptions = @{
NoPrompt = 0x00000001
UseFileName = 0x00000002
Concatenate = 0x00000004
DisableCompression = 0x00000008
EmbedFonts = 0x00000010
BroadcastMessages = 0x00000020
PrintWatermark = 0x00000040
MultilingualSupport = 0x00000080
EncryptDocument = 0x00000100
FullEmbed = 0x00000200
UseTcpIpServer = 0x00000400
SendByEmail = 0x00000800
ConfirmOverwrite = 0x00001000
AppendExisting = 0x00002000
AddDateTime = 0x00003000
AddIdNumber = 0x00004000
LinearizeForWeb = 0x00008000
PostProcessing = 0x00010000
QualityLevelLow = 0x00020000
QualityLevelMedium = 0x00040000
QualityLevelHigh = 0x00060000
Colors2GrayScale = 0x00080000
ConvertHyperlinks = 0x00100000
EmbedStandardFonts = 0x00200000
EmbedLicensedFonts = 0x00400000
Color256Compressio = 0x00800000
Jpeg2000Compression = 0x01000000
SendToCreator = 0x02000000
ExportToHTML = 0x04000000
ExportToRTF = 0x08000000
ExportToJPEG = 0x10000000
CCITTCompression = 0x20000000
EncryptDocument128 = 0x40000000
AutoImageCompression = 0x80000000
}
# Constants for Activation codes
$strLicenseTo = "Amyuni PDF Converter Evaluation"
$strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
$AMYUNIPRINTERNAME = "Amyuni PDF Converter"
#Declare a new cdintfex object if it does not exist in the form.
$PDF = New-Object -ComObject CDIntfEx.CDIntfEx.6.5
#Get a reference to the installed printer.
#This will fail if the printer name passed to the DriverInit method is
#not found in the printer’s folder
[System.__ComObject].InvokeMember('DriverInit', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$AMYUNIPRINTERNAME)
#The SetDefaultPrinter function sets the system default printer to the one
#initialized by the DriverInit functions.
[System.__ComObject].InvokeMember('SetDefaultPrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$null)
#The EnablePrinter() method needs to be called right before each print job.
#and before the configuration
#Calling the EnablePrinter() method will start a 20 second time-out value
[System.__ComObject].InvokeMember('EnablePrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @($strLicenseTo, $strActivationCode))
#Set Printer options
[System.__ComObject].InvokeMember('FileNameOptionsEx', [System.Reflection.BindingFlags]::SetProperty,$null,$PDF,$acFileNameOptions::SendToCreator)
#Set Custom Dll
[System.__ComObject].InvokeMember('PageProcessor', [System.Reflection.BindingFlags]::SetProperty,$null,$PDF,"ACPgProc.dll")
#Print a sample document
$fileName = "C:\temp\test.txt"
#The BatchConvert method converts a number of files to PDF.
[System.__ComObject].InvokeMember('BatchConvert', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, $fileName)
#The RestoreDefaultPrinter function resets the system default printer
#to the printer that was the default before the call to SetDefaultPrinter.
[System.__ComObject].InvokeMember('RestoreDefaultPrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$null)
#This function will simply detach from an existing printer because the handle was created using DriverInit
[System.__ComObject].InvokeMember('DriverEnd', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$null)
#Destroy PDF object
$PDF = $null
' FileNameOptions constants
Const NoPrompt = &H1
Const UseFileName = &H2
Const Concatenate = &H4
Const DisableCompression = &H8
Const EmbedFonts = &H10
Const BroadcastMessages = &H20
Const PrintWatermark = &H40
Const MultilingualSupport = &H80
Const EncryptDocument = &H100
Const FullEmbed = &H200
Const UseTcpIpServer = &H400
Const SendByEmail = &H800
Const ConfirmOverwrite = &H1000
Const AppendExisting = &H2000
Const AddDateTime = &H3000
Const AddIdNumber = &H4000
Const LinearizeForWeb = &H8000
Const PostProcessing = &H10000
Const QualityLevelLow = &H20000
Const QualityLevelMedium = &H40000
Const QualityLevelHigh = &H60000
Const Colors2GrayScale = &H80000
Const ConvertHyperlinks = &H100000
Const EmbedStandardFonts = &H200000
Const EmbedLicensedFonts = &H400000
Const Color256Compression = &H800000
Const Jpeg2000Compression = &H1000000
Const SendToCreator = &H2000000
Const ExportToHTML = &H4000000
Const ExportToRTF = &H8000000
Const ExportToJPEG = &H10000000
Const CCITTCompression = &H20000000
Const EncryptDocument128 = &H40000000
Const AutoImageCompression = &H80000000
' Constants for Activation codes
Const strLicenseTo = "Amyuni PDF Converter Evaluation"
Const strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
Const AMYUNIPRINTERNAME = "Amyuni PDF Converter"
' Declare a new cdintfex object
Dim PDF
Set PDF = CreateObject("CDIntfEx.CDIntfEx.6.5")
' Get a reference to the installed printer.
' This will fail if the printer name passed to the DriverInit method is
' not found in the printer’s folder
PDF.DriverInit AMYUNIPRINTERNAME
' The SetDefaultPrinter function sets the system default printer to the one
' initialized by the DriverInit functions.
PDF.SetDefaultPrinter
' The EnablePrinter() method needs to be called right before each print job.
' and before the configuration
' Calling the EnablePrinter() method will start a 20 second time-out value
PDF.EnablePrinter strLicenseTo, strActivationCode
' Set Printer options
PDF.FileNameOptionsEx = SendToCreator
' Set Custom Dll
PDF.PageProcessor = "ACPgProc.dll"
' Print a sample document
Dim fileName
fileName = "C:\temp\test.txt"
' The BatchConvert method converts a number of files to PDF.
PDF.BatchConvert fileName
' The RestoreDefaultPrinter function resets the system default printer
' to the printer that was the default before the call to SetDefaultPrinter.
PDF.RestoreDefaultPrinter
' This function will simply detach from an existing printer because the handle was created using DriverInit
PDF.DriverEnd
' Destroy PDF object
Set PDF = Nothing