VintaSoft PDF .NET Plug-in Discussions
Questions, comments and suggestions concerning VintaSoft PDF .NET Plug-in.
Board index < VintaSoft Imaging < VintaSoft PDF .NET Plug-in Discussions
Dim stream As System.IO.Stream = System.IO.File.Open(PDFName, System.IO.FileMode.Open)
Dim document As PdfDocument = PdfDocumentController.OpenDocument(stream)
For p As Integer = 0 To document.Pages.Count - 1
Using g As PdfGraphics = PdfGraphics.FromPage(document.Pages(p))
Dim font As New Font("Arial", 12)
Dim brush As New PdfBrush(Color.Black)
Dim PDFPage As Vintasoft.Imaging.Pdf.Tree.PdfPage = document.Pages(p)
Dim X As Single = PDFPage.Size.Height
Dim Y As Single = PDFPage.Size.Width
Dim Location As New System.Drawing.Point(1, 1)
g.DrawString(p.ToString("00000"), font, brush, Location)
End Using
Next
document.SaveChanges()
PdfDocumentController.CloseDocument(document)
Dim stream As System.IO.Stream = System.IO.File.Open(PDFName, System.IO.FileMode.Open)
Dim document As PdfDocument = PdfDocumentController.OpenDocument(stream)
For p As Integer = 1 To document.Pages.Count - 1
Using g As PdfGraphics = PdfGraphics.FromPage(document.Pages(p))
Dim font As New Font("Arial", 12, FontStyle.Bold)
Dim brush As New PdfBrush(Color.Black)
Dim PDFPage As Vintasoft.Imaging.Pdf.Tree.PdfPage = document.Pages(p)
Dim X As Single = PDFPage.Size.Height
Dim Y As Single = PDFPage.Size.Width
' --------------------------
Dim StringPage As String = p.ToString("00000")
Dim StringSize As Size = TextRenderer.MeasureText(StringPage, font)
Dim Location As New System.Drawing.Point(Y - StringSize.Width, 10)
g.DrawString(StringPage, font, brush, Location)
End Using
Next
document.SaveChanges()
PdfDocumentController.CloseDocument(document)
stream.Close()
at the moment I solved in this way... is the best way ?Your code adds number as vector graphics. Added text is not searchable on PDF page.
...
Dim font As PdfFont = document.FontManager.GetStandardFont(PdfStandardFontType.TimesRoman)
For p As Integer = 1 To document.Pages.Count - 1
Using g As PdfGraphics = PdfGraphics.FromPage(document.Pages(p))
Dim brush As New PdfBrush(Color.Black)
Dim PDFPage As Vintasoft.Imaging.Pdf.Tree.PdfPage = document.Pages(p)
Dim StringPage As String = p.ToString("00000")
Dim textWidth As Single
Dim textHeight As Single
g.MeasureString(StringPage, font, 12, textWidth, textHeight)
Dim Location As New System.Drawing.Point(PDFPage.MediaBox.X + PDFPage.MediaBox.Width - textWidth - 10, 10)
g.DrawString(StringPage, font, 12, brush, Location)
End Using
Next
Best regards, Alexander
- insert a image every page
Dim stream As System.IO.Stream = System.IO.File.Open(PDFName, System.IO.FileMode.Open)
Dim document As PdfDocument = PdfDocumentController.OpenDocument(stream)
Dim image As New Vintasoft.Imaging.VintasoftImage("F:\stamp.GIF")
Dim imageDim As New System.Drawing.SizeF(60, 60)
For p As Integer = 0 To document.Pages.Count - 1
Dim PdfPage As Vintasoft.Imaging.Pdf.Tree.PdfPage = document.Pages(p)
Dim X As Single = PdfPage.Size.Height
Dim Y As Single = PdfPage.Size.Width
Dim imageXY As New System.Drawing.PointF(Y - 65, 5)
Using graphics As Vintasoft.Imaging.Pdf.Drawing.PdfGraphics = PdfPage.GetGraphics()
Dim imageResource As New Vintasoft.Imaging.Pdf.Tree.PdfImageResource(document, image, PdfCompression.Auto)
graphics.DrawImage(imageResource, New System.Drawing.RectangleF(imageXY, imageDim))
End Using
Next
document.SaveChanges()
PdfDocumentController.CloseDocument(document)
stream.Close()
Thanks in advance.
Dim imageResource As New Vintasoft.Imaging.Pdf.Tree.PdfImageResource(document, image, PdfCompression.Auto)Do not do this and use 1 image-resource for all PDF pages.