在vb.net請儘可能itextsharp:我如何設置文檔的背景顏色?
0
A
回答
4
您可以創建一個Rectangle
對象並設置它的BackgroundColor
屬性。用你的Rectangle
初始化Document
。
This tutorial在SourceForge上的iTextSharp站點上對此進行了描述(請參閱PageSize部分)。
相同的網站有一個code sample,演示你需要做什麼。 (參見'步驟1')。該示例是用C#編寫的,我知道你在VB.NET中需要它,所以我通過developerfusion站點上的C# to VB.NET converter運行它。我無法測試編譯機器的結果我現在不是,但代碼看起來是合理的:
Imports System
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Public Class Chap0102
Public Shared Sub Main()
Console.WriteLine("Chapter 1 example 2: PageSize")
' step 1: creation of a document-object
Dim pageSize As New Rectangle(144, 720)
pageSize.BackgroundColor = New Color(&Hff, &Hff, &Hde)
Dim document As New Document(pageSize)
Try
' step 2:
' we create a writer that listens to the document
' and directs a PDF-stream to a file
PdfWriter.getInstance(document, New FileStream("Chap0102.pdf", FileMode.Create))
' step 3: we open the document
document.Open()
' step 4: we Add some paragraphs to the document
For i As Integer = 0 To 4
document.Add(New Paragraph("Hello World"))
Next
Catch de As DocumentException
Console.[Error].WriteLine(de.Message)
Catch ioe As IOException
Console.[Error].WriteLine(ioe.Message)
End Try
' step 5: we close the document
document.Close()
End Sub
End Class
試試看。
1
color
不存在命名空間和錯誤是在你的代碼:
pageSize.BackgroundColor = New **Color**(&Hff, &Hff, &Hde)
相關問題
- 1. 設置contentbyte的背景顏色itextsharp
- 2. iTextSharp頁腳背景顏色
- 3. 如何將IFRAME的背景顏色設置爲其父文檔的BG顏色?
- 4. Google文檔 - 背景顏色
- 5. 如何設置NSTabView的背景顏色?
- 6. 如何設置menuitem的背景顏色
- 7. 如何設置UIWebView的背景顏色
- 8. 如何設置tableView的背景顏色
- 9. 如何設置UIWebView的背景顏色?
- 10. 設置背景顏色2
- 11. 設置背景顏色
- 12. Angular4背景顏色設置
- 13. 設置背景顏色[JAVA]
- 14. angular2設置背景顏色
- 15. 設置背景顏色
- 16. 設置背景顏色
- 17. 設置背景顏色:Android
- 18. Cardview設置背景顏色
- 19. 設置背景顏色toolbaritems
- 20. 設置VIM背景顏色
- 21. 設置背景顏色CMDIFrameWnd
- 22. 設置行背景顏色
- 23. 如何設置AlertDialog背景顏色
- 24. 如何設置背景顏色?
- 25. 如何設置標籤背景顏色
- 26. 如何設置Canvas3D背景顏色?
- 27. 如何設置tableview背景顏色?
- 28. 如何爲NSTableCellView設置背景顏色?
- 29. JTextField - 如何設置背景顏色?
- 30. 如何設置RelativeLayout背景顏色?