zedgraph quality inside PDF Doc depend on PageSize.A4.Rotate
For using you will need this two dll, I'm sure everybody knows that, but its probally the best.
http://sourceforge.net/projects/zedgraph/files/
http://sourceforge.net/projects/itex...es/itextsharp/
(this example use itextsharp-4.1.6 )
My Question
THe following Code will make a Graph, create a Bitmap, and start Adobe-Reade to present the Graph inside.
The whole code works fine. I only have trouble, when I use this line:
Dim Doc As New iTextSharp.text.Document (iTextSharp.text.PageSize.A4.Rotate())
instead of this line:
Dim Doc As New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 10, 10, 10, 10)
The quality of of the whole Picture is not good then.
Eventhough when I change width and hight for the Rectangle.
Then I tried to change the Bitmap width and hight, but in that case nothing happends?
Does anybody know a way, to handle the quality for using why nothing happends, when I change hight or width in this line:
Dim Doc As New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 10, 10, 10, 10)
Code:
Imports ZedGraph
Imports iTextSharp
Imports iTextSharp.text.pdf
Private Sub btnOrgPDFtrans_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOrgPDFtrans.Click
'Create Graph pane
Dim w As Integer = 600
Dim h As Integer = 400
Dim myPane As New GraphPane(New Rectangle(0, 0, w, h), "", "", "")
' Set the titles and axis labels
myPane.Title.Text = "My Bar Chart"
myPane.XAxis.Title.Text = "Day"
myPane.YAxis.Title.Text = ""
' Add random data
Dim list As New PointPairList()
Dim rand As New Random()
Dim i As Integer
For i = 0 To 15
Dim x As Double = CDbl(i) + 1
Dim y As Double = rand.NextDouble() * 1000
list.Add(x, y)
Next i
' Create Bar Chart
Dim myCurve As BarItem = myPane.AddBar("", list, Color.Blue)
Dim colors As Color() = {Color.Red, Color.Blue}
myCurve.Bar.Fill = New Fill(colors)
myCurve.Bar.Fill.Type = FillType.Solid
myCurve.Bar.Fill.RangeMin = 0
myCurve.Bar.Fill.RangeMax = 4
myPane.Chart.Fill = New Fill(Color.White, Color.FromArgb(220, 220, 255), 45)
myPane.Fill = New Fill(Color.White, Color.FromArgb(255, 255, 225), 45)
'Create Bitmap
Dim bm As Drawing.Bitmap = New Bitmap(1, 1)
Dim g As Graphics = Graphics.FromImage(bm)
myPane.AxisChange(g)
' Create PDF file
Dim Doc As New iTextSharp.text.Document(iTextSharp.text.PageSize.A4.Rotate())
Dim writer As iTextSharp.text.pdf.PdfWriter
writer = PdfWriter.GetInstance(Doc, New FileStream("Chap0610.pdf", FileMode.Create))
' Open PDF file for write
Doc.Open()
Dim cb As PdfContentByte = writer.DirectContent
' Write Chart/image to PDF file
Dim im As iTextSharp.text.Image
im = iTextSharp.text.Image.GetInstance(myPane.GetImage(), Drawing.Imaging.ImageFormat.Bmp)
im.SetAbsolutePosition(50.0F, 80.0F)
cb.AddImage(im)
' Close PDF document
Doc.Close()
g.Dispose()
'Open PDF Application
Process.Start("Chap0610.pdf")
End Sub
Re: zedgraph quality inside PDF Doc depend on PageSize.A4.Rotate
Re: zedgraph quality inside PDF Doc depend on PageSize.A4.Rotate
Re: zedgraph quality inside PDF Doc depend on PageSize.A4.Rotate