This object represents an open PDF file. It enables a series of post-processing operations to be performed on a PDF file without closing and re-parsing it after each operation, thus optimizing efficiency when multiple operations are applied to a PDF at once. The output is not written out until all operations are complete and the handle is closed. PDFProcessorHandle works equally well with physical (on disk) files and in-memory streams.
For users who are familiar with the PDFProcessor object, PDFProcessorHandle offers much of the same functionality and its methods take very similar arguments. The key difference is that the individual processing functions in PDFProcessorHandle do not require an input or output filename, as it maintains an internal state which knows about your PDF.
Note that PDFProcessorHandle should never be instantiated directly. A PDFProcessorHandle instance should always be obtained from an instance of the PDFProcessor object by calling OpenFile or OpenMem.
Set oProcessor = CreateObject("easyPDF.PDFProcessor.7")
Set oProcessorHandle = oProcessor.OpenFile("C:\input.pdf", "C:\output.pdf")
oProcessorHandle.AddHyperlink 0, _
0, _
50, _
80, _
370, _
100, _
"http://www.bcltechnologies.com/", _
PRC_BORDERSTYLE_DASHLINE_MEDIUM, _
RGB(255, 0, 0)
oProcessorHandle.AddStamp "C:\image.jpg", _
0, _
PRC_STAMP_HPOS_CENTER, _
PRC_STAMP_VPOS_CENTER, _
PRC_STAMP_ZORDER_TOP, _
0, _
0, _
0, _
100
oProcessorHandle.Close
Dim inMem() As Byte = File.ReadAllBytes("C:\input.pdf")
Dim oProcessor As PDFProcessor = Nothing Dim oProcessorHandle As PDFProcessorHandle = Nothing
Try
oProcessor = New PDFProcessor
oProcessorHandle = oProcessor.OpenMem(inMem, Nothing)
oProcessorHandle.AddHyperlink(0, _
0, _
50, _
80, _
370, _
100, _
"http://www.bcltechnologies.com", _
prcAnnotBorderStyle.PRC_BORDERSTYLE_DASHLINE_MEDIUM, _
0)
oProcessorHandle.AddStamp("C:\image.jpg", _
0, _
prcStampHPosition.PRC_STAMP_HPOS_CENTER, _
prcStampVPosition.PRC_STAMP_VPOS_CENTER, _
prcStampZOrder.PRC_STAMP_ZORDER_TOP, _
0, _
0, _
0, _
100)
Dim outMem() As Byte = oProcessorHandle.CloseMem()
File.WriteAllBytes("C:\output.pdf", outMem)
Catch ex As System.Runtime.InteropServices.COMException
MessageBox.Show(ex.Message)
Finally
oProcessorHandle.Close()
End Try
byte[] inMem = File.ReadAllBytes(@"C:\input.pdf");
PDFProcessor oProcessor = null; PDFProcessorHandle oProcessorHandle = null;
try
{
oProcessor = new PDFProcessor();
oProcessorHandle = oProcessor.OpenMem(inMem, null);
oProcessorHandle.AddHyperlink(0,
0,
50,
80,
370,
100,
"http://www.bcltechnologies.com",
prcAnnotBorderStyle.PRC_BORDERSTYLE_DASHLINE_MEDIUM,
0);
oProcessorHandle.AddStamp(@"C:\image.jpg",
0,
prcStampHPosition.PRC_STAMP_HPOS_CENTER,
prcStampVPosition.PRC_STAMP_VPOS_CENTER,
prcStampZOrder.PRC_STAMP_ZORDER_TOP,
0,
0,
0,
100);
byte[] outMem = (byte[])oProcessorHandle.CloseMem();
File.WriteAllBytes(@"C:\output.pdf", outMem);
}
catch(System.Runtime.InteropServices.COMException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
oProcessorHandle.Close();
}