I'm trying to write a simple script to merge two files together.
The files that are created show as corrupt. Is there something im doing wrong?
Sub
Main()
Dim
file1
As
Byte
() = ReadFile(
"e:\test1\test1.pdf"
)
Dim
result
As
New
IO.MemoryStream
Dim
fileWriter
As
New
PdfStreamWriter(Result,
True
)
Dim
pdfSource
As
New
PdfFileSource(
New
IO.MemoryStream(file1))
For
Each
pg
As
PdfPageSource
In
pdfSource.Pages
fileWriter.WritePage(pg)
Next
Dim
b
As
Byte
()
b = Result.ToArray()
Dim
writer
As
IO.FileStream = IO.File.OpenWrite(
"e:\test1\abc12222.pdf"
)
writer.Write(b, 0, b.Length)
writer.Close()
End
Sub
Function
ReadFile(filename
As
String
)
As
Byte
()
Dim
io
As
New
IO.FileInfo(filename)
Dim
fs
As
IO.FileStream = io.OpenRead
Dim
b()
As
Byte
ReDim
b(io.Length)
fs.Read(b, 0, io.Length)
fs.Close()
Return
b
End
Function