Add pdf information from gui

This commit is contained in:
Mans 2021-03-16 11:30:41 +01:00
parent 49e4ecf33f
commit 8144ac0336
2 changed files with 100 additions and 4 deletions

Binary file not shown.

View File

@ -264,13 +264,109 @@ Public Class Individual
Dim tempImg As New Bitmap(Panel_Grating.Width - 1, Panel_Grating.Height - 1)
Dim test As Graphics = Graphics.FromImage(tempImg)
test.CopyFromScreen(startPoint, New Point(0, 0), tempImg.Size)
tempImg.Save(filepath & "\Screenshot.png", Imaging.ImageFormat.Png)
tempImg.Save(filepath & "\X2021\Specification_PDF\GUI.png", Imaging.ImageFormat.Png)
Dim doc As Word.Document = New Word.Document()
doc.Content.Text = "Hello World"
doc.Content.InlineShapes.AddPicture(filepath & "\Screenshot.png")
doc.ExportAsFixedFormat(filepath & "\myfilename.pdf", Word.WdExportFormat.wdExportFormatPDF)
'doc.Content.Text = "Hello World"
Dim Para1 As Word.Paragraph
Para1 = doc.Content.Paragraphs.Add
Para1.Range.InlineShapes.AddPicture(filepath & "\X2021\Specification_PDF\Weland_Logo.png")
doc.InlineShapes(1).ScaleHeight = 50
doc.InlineShapes(1).ScaleWidth = 50
Para1.Format.SpaceAfter = 30
Para1.Range.InsertParagraphAfter()
Dim table1 As Word.Table
table1 = doc.Tables.Add(doc.Bookmarks.Item("\endofdoc").Range, 4, 2)
table1.Columns(1).SetWidth(120, 2)
table1.Rows.SetHeight(18, 2)
table1.Cell(1, 1).Range.Text = "Quote Date:"
table1.Cell(1, 2).Range.Text = Date.Today
table1.Cell(2, 1).Range.Text = "Order number:"
table1.Cell(2, 2).Range.Text = "1337"
table1.Cell(3, 1).Range.Text = "Customer number:"
table1.Cell(3, 2).Range.Text = "20041605"
table1.Cell(4, 1).Range.Text = "Sales Representative:"
table1.Cell(4, 2).Range.Text = "Sven Svensson"
table1.Range.ParagraphFormat.SpaceAfter = 30
'table1.Range.InsertParagraphAfter()
'table1.Range.Collapse(Word.WdCollapseDirection.wdCollapseEnd)
Dim oLineBreak As Word.Paragraph
oLineBreak = doc.Content.Paragraphs.Add(doc.Bookmarks.Item("\endofdoc").Range)
oLineBreak.Range.InsertParagraphBefore()
oLineBreak.Range.Text = ""
oLineBreak.Format.SpaceAfter = 0.5
oLineBreak.Range.InsertParagraphAfter()
Dim table2 As Word.Table
table2 = doc.Tables.Add(doc.Bookmarks.Item("\endofdoc").Range, 5, 5) 'FIXA generiskt
table2.Rows.SetHeight(18, 2)
For i = 1 To table2.Columns.Count
table2.Cell(1, i).Range.Font.Color = Word.WdColor.wdColorWhite
table2.Cell(1, i).Shading.BackgroundPatternColor = Word.WdColor.wdColorBlack
Next
table2.Cell(1, 1).Range.Text = "Description"
table2.Cell(1, 2).Range.Text = "QTY"
table2.Cell(1, 3).Range.Text = "Art. Nr."
table2.Cell(1, 4).Range.Text = "Unit Price"
table2.Cell(1, 5).Range.Text = "Total Price"
For i = 2 To table2.Rows.Count
table2.Cell(i, 1).Range.Text = "Floor Grating" & i
table2.Cell(i, 2).Range.Text = "QTY"
table2.Cell(i, 3).Range.Text = "Art. Nr."
table2.Cell(i, 4).Range.Text = "Unit Price"
table2.Cell(i, 5).Range.Text = "Total Price"
Next
table2.Range.ParagraphFormat.SpaceAfter = 40
Dim Para2 As Word.Paragraph
Para2 = doc.Content.Paragraphs.Add
Para2.Range.InsertParagraphBefore()
Para2.Range.Text = "Total Price: " & "2200"
Para2.Range.Font.Bold = True
Para2.Range.Font.Size = 20
Para2.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight
Para2.Format.SpaceAfter = 24
Dim table3 As Word.Table
doc.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = False
table3 = doc.Sections(1).Footers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range.Tables.Add(doc.Sections(1).Footers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range, 3, 2)
table3.Columns(1).SetWidth(360, 2)
table3.Cell(1, 1).Range.Text = "Phone Number: "
table3.Cell(2, 1).Range.Text = "Email: "
table3.Cell(3, 1).Range.Text = "Webpage: "
table3.Cell(1, 2).Range.Text = "0731-344 00"
table3.Cell(2, 2).Range.Text = "info@weland.se"
table3.Cell(3, 2).Range.Text = "www.weland.com"
For i = 1 To table3.Rows.Count
table3.Cell(i, 1).Range.Font.Bold = True
For j = 1 To table3.Columns.Count
table3.Cell(i, j).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight
table3.Cell(i, j).Range.Font.Size = 10
Next
Next
doc.ExportAsFixedFormat(filepath & "\X2021\Specification_PDF\Specification.pdf", Word.WdExportFormat.wdExportFormatPDF)
doc.Close(False)
End Sub