令我有點頭大open source(我又討厭一直看英文。) 結合pdf和pic的作法。
Dim i As Integer
Try
Dim pdfreadera As New PdfReader("D:\dlltesting_process\ttest22\gg.pdf") ''先new一個pdf的物件並將要合併的pdf放入
Dim anumberofpages As Integer = pdfreadera.NumberOfPages ''計算該pdf的頁數
Dim psize As Rectangle = pdfreadera.GetPageSize(1) ''先把第一頁抓出來
Dim pdfwidth As Double = psize.Width ''讀pdf的寬度
Dim pdfheight As Double = psize.Height ''讀pdf的長度
Dim aa As Image ''新增一個image
aa = Image.GetInstance("D:\002.JPG") ''載入圖片
Dim outputstream As New FileStream("D:\aa.pdf", FileMode.Create) ''先create出一張空白的pdf檔
Dim pdfstramer As New PdfStamper(pdfreadera, outputstream) ''輸入、輸出路徑
Dim watercontent As PdfContentByte ''轉換pdf的內容
' aa.SetAbsolutePosition((250), (200))
aa.SetAbsolutePosition(100, 300) '定位
For i = 1 To anumberofpages
watercontent = pdfstramer.GetUnderContent(i) ' pdfstramer.GetUnderContent(i) ''開始狂貼 under是代表貼在下層,over是貼在上層
watercontent.AddImage(aa)
Next
''作完之後要把所有的元件關閉
pdfstramer.GetPdfLayers()
pdfreadera.Close()
pdfstramer.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
- Aug 30 Tue 2011 21:06
iTextSharp
文章標籤
全站熱搜
留言列表