Hello All, I have some existing reports in VB such as invoice and purchase order that I would like to convert to pdf. Can I use Spire to convert entire printdocument from VB or do I need to re-write with Spire code?
Any help would be appriciated
Imports Spire.Xls
Namespace ConvertExcelToPDF
Class Program
Private Shared Sub Main(ByVal args() As String)
'Create a Workbook instance
Dim workbook As Workbook = New Workbook
'Load a sample Excel file
workbook.LoadFromFile("C:\Desktop\Sample.xlsx")
'Set worksheets to fit to page when converting
workbook.ConverterSetting.SheetFitToPage = true
'Save to PDF
workbook.SaveToFile("ExcelToPdf.pdf", FileFormat.PDF)
End Sub
End Class
End Namespace
Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim StringFormat = New StringFormat() : StringFormat.Alignment = StringAlignment.Far ' Right Justify
PG += 1
Down = 30
e.Graphics.DrawString("Sales Order", Font20, Brushes.Black, Right, Down, StringFormat)
Down = 60
Dim bitmap As New Bitmap("logo.jpg")
e.Graphics.DrawImage(bitmap, Left, Down, 50, 50)
'If CoAddress2 = "" Then Down = 90 Else Down = 80 ' Company Name
e.Graphics.DrawString(CoName, Font12B, Brushes.Black, Left + 55, Down) : Down += Offset
e.Graphics.DrawString(CoAddress1, Font12, Brushes.Black, Left + 55, Down) : Down += Offset
If CoAddress2 <> "" Then
e.Graphics.DrawString(CoAddress2, Font12, Brushes.Black, Left + 55, Down)
Down += Offset
End If
e.Graphics.DrawString(CoCity + ", " + CoState + " " + CoZip, Font12, Brushes.Black, Left + 55, Down)
Dim printerSettings As PrinterSettings = New System.Drawing.Printing.PrinterSettings
printerSettings.PrinterName = "Adobe PDF" 'or "Microsoft Print to PDF"