Dim PDFdoc As New Document()
'load a document
Dim PDFsection As Section = PDFdoc.AddSection()
'Add a new paragraph to the section.
Dim PDFparagraph As Paragraph = PDFsection.AddParagraph()
'Insert an OLE object (PDF) from the disk to the document.
Dim stream2 As Stream = New FileStream(Server.MapPath("icon.png"), FileMode.Open, FileAccess.Read)
Dim stream1 As Stream = New FileStream(Server.MapPath("Test.pdf"), FileMode.Open, FileAccess.Read)
PDFparagraph = PDFsection.AddParagraph()
Dim docPic As New DocPicture(PDFdoc)
docPic.LoadImage(System.Drawing.Image.FromStream(stream2))
docPic.HeightScale = 25
docPic.WidthScale = 25
Try
PDFsection.AddParagraph.AppendOleObject(stream1, docPic, OleObjectType.AdobeAcrobatDocument)
Catch
End Try
PDFdoc.SaveToFile(Server.MapPath("CasePack/PDF" & EncID & ".doc"), FileFormat.Doc)
Imports System.Web.UI
'using System.Web.UI.WebControls;
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports Spire.Doc.Fields
Namespace InsertObject
Partial Public Class test
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim document As New Document()
Dim path As String = Server.MapPath(".\Test.docx")
document.LoadFromFile(path, FileFormat.Docx2010)
Dim pic As New DocPicture(document)
Dim imgPath As String = Server.MapPath(".\icon.png")
Dim image As Image = Image.FromFile(imgPath)
pic.LoadImage(image)
Dim pdfPath As String = Server.MapPath(".\Test.pdf")
document.LastParagraph.AppendOleObject(pdfPath, pic, OleObjectType.Package)
document.SaveToFile(Server.MapPath(".\Result.docx"), FileFormat.Docx2010, Response, HttpContentType.Attachment)
'document.SaveToFile(@"..\..\sample.docx", FileFormat.Docx2010);
'System.Diagnostics.Process.Start(@"..\..\sample.docx");
End Sub
End Class
End Namespace