Mailversand, etc.

This commit is contained in:
2025-04-30 16:56:55 +02:00
parent 9ebf29e1e5
commit 7713060873
6 changed files with 136 additions and 67 deletions

View File

@@ -988,13 +988,19 @@ Public Class cMDMFunctionsAllgemein
For page As Integer = 1 To pdfReader.NumberOfPages
Dim canvas As PdfContentByte = stamper.GetOverContent(page)
Dim bf As BaseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED)
canvas.SetFontAndSize(bf, 16)
canvas.SetFontAndSize(bf, 12)
canvas.BeginText()
'The origin (0,0) is at the bottom-left corner of the page and represent coordinates in points!!!!!
Dim _height = pdfReader.GetPageSizeWithRotation(page).GetTop(25) 'oberer Rand
Dim _width = pdfReader.GetPageSizeWithRotation(page).GetRight(0) / 2 'Mitte
'Workaround!
If _height > 2000 Then
canvas.SetFontAndSize(bf, 45)
_height -= 70
End If
canvas.ShowTextAligned(PdfContentByte.ALIGN_CENTER, nummierung, _width, _height, 0)
'canvas.ShowTextAligned(PdfContentByte.ALIGN_CENTER, nummierung, 350, 550, 0)

View File

@@ -1,9 +1,9 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class frmScan
Inherits System.Windows.Forms.Form
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
<System.Diagnostics.DebuggerNonUserCode()> _
<System.Diagnostics.DebuggerNonUserCode()>
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
@@ -20,7 +20,7 @@ Partial Class frmScan
'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
'Das Bearbeiten ist mit dem Windows Form-Designer möglich.
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmScan))
Me.dsViewer = New Dynamsoft.Forms.DSViewer()
@@ -56,6 +56,7 @@ Partial Class frmScan
Me.tbxCurrentImageIndex = New System.Windows.Forms.Label()
Me.tbxTotalImageNum = New System.Windows.Forms.Label()
Me.pnl = New System.Windows.Forms.Panel()
Me.cboOrientation = New System.Windows.Forms.ComboBox()
Me.cbxAltFormat = New System.Windows.Forms.CheckBox()
Me.cboFormat = New System.Windows.Forms.ComboBox()
Me.grpFarbe.SuspendLayout()
@@ -383,7 +384,7 @@ Partial Class frmScan
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(395, 654)
Me.Label3.Location = New System.Drawing.Point(405, 654)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(31, 13)
Me.Label3.TabIndex = 18
@@ -406,7 +407,7 @@ Partial Class frmScan
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(436, 654)
Me.Label2.Location = New System.Drawing.Point(446, 654)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(25, 13)
Me.Label2.TabIndex = 17
@@ -415,7 +416,7 @@ Partial Class frmScan
'tbxCurrentImageIndex
'
Me.tbxCurrentImageIndex.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.tbxCurrentImageIndex.Location = New System.Drawing.Point(416, 654)
Me.tbxCurrentImageIndex.Location = New System.Drawing.Point(426, 654)
Me.tbxCurrentImageIndex.Name = "tbxCurrentImageIndex"
Me.tbxCurrentImageIndex.Size = New System.Drawing.Size(28, 13)
Me.tbxCurrentImageIndex.TabIndex = 19
@@ -425,7 +426,7 @@ Partial Class frmScan
'tbxTotalImageNum
'
Me.tbxTotalImageNum.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.tbxTotalImageNum.Location = New System.Drawing.Point(447, 654)
Me.tbxTotalImageNum.Location = New System.Drawing.Point(457, 654)
Me.tbxTotalImageNum.Name = "tbxTotalImageNum"
Me.tbxTotalImageNum.Size = New System.Drawing.Size(25, 13)
Me.tbxTotalImageNum.TabIndex = 20
@@ -434,6 +435,7 @@ Partial Class frmScan
'
'pnl
'
Me.pnl.Controls.Add(Me.cboOrientation)
Me.pnl.Controls.Add(Me.cbxAltFormat)
Me.pnl.Controls.Add(Me.cboFormat)
Me.pnl.Controls.Add(Me.Label2)
@@ -464,6 +466,15 @@ Partial Class frmScan
Me.pnl.Size = New System.Drawing.Size(741, 683)
Me.pnl.TabIndex = 21
'
'cboOrientation
'
Me.cboOrientation.Enabled = False
Me.cboOrientation.FormattingEnabled = True
Me.cboOrientation.Location = New System.Drawing.Point(639, 565)
Me.cboOrientation.Name = "cboOrientation"
Me.cboOrientation.Size = New System.Drawing.Size(88, 21)
Me.cboOrientation.TabIndex = 23
'
'cbxAltFormat
'
Me.cbxAltFormat.AutoSize = True
@@ -479,9 +490,9 @@ Partial Class frmScan
'
Me.cboFormat.Enabled = False
Me.cboFormat.FormattingEnabled = True
Me.cboFormat.Location = New System.Drawing.Point(594, 565)
Me.cboFormat.Location = New System.Drawing.Point(575, 565)
Me.cboFormat.Name = "cboFormat"
Me.cboFormat.Size = New System.Drawing.Size(133, 21)
Me.cboFormat.Size = New System.Drawing.Size(58, 21)
Me.cboFormat.TabIndex = 22
'
'frmScan
@@ -539,4 +550,5 @@ Partial Class frmScan
Friend WithEvents pnl As System.Windows.Forms.Panel
Friend WithEvents cboFormat As Windows.Forms.ComboBox
Friend WithEvents cbxAltFormat As Windows.Forms.CheckBox
Friend WithEvents cboOrientation As Windows.Forms.ComboBox
End Class

View File

@@ -1,27 +1,22 @@
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Drawing
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Text
Imports System.Threading
'Imports Dynamsoft.Barcode
Imports Dynamsoft.TWAIN
Imports System.Windows.Forms
Imports Dynamsoft.Core
Imports Dynamsoft.Core.Annotation
Imports Dynamsoft.Core.Enums
'Imports Dynamsoft.UVC
'Imports Dynamsoft.OCR
Imports Dynamsoft.PDF
Imports Dynamsoft.Core.Annotation
Imports Dynamsoft.PDF.Enums
'Imports Dynamsoft.Barcode
Imports Dynamsoft.TWAIN
'Imports Dynamsoft.UVC.Common
Imports Dynamsoft.TWAIN.Interface
Imports Dynamsoft.Core.Enums
Imports System.IO
Imports Dynamsoft.TWAIN.Enums
Imports Dynamsoft.DotTwain
Imports ClosedXML.Excel
Imports Dynamsoft.PDF.Enums
Imports Spire.Pdf
'Aktuell3
@@ -64,25 +59,6 @@ Public Class frmScan
init()
End Sub
Public Enum TwainSupportedSizes As UShort
TWSS_NONE = 0
TWSS_A4 = 1
TWSS_JISB5 = 2
TWSS_USLETTER = 3
TWSS_USLEGAL = 4
TWSS_A5 = 5
TWSS_ISOB4 = 6
TWSS_ISOB6 = 7
TWSS_USLEDGER = 9
TWSS_USEXECUTIVE = 10
TWSS_A3 = 11
TWSS_B4 = 12
TWSS_B6 = 13
TWSS_BUSINESSCARD = 14
End Enum
Public Sub OnPostAllTransfers() Implements IAcquireCallback.OnPostAllTransfers
Me.Invoke(New CrossThreadOperationControl(AddressOf CallMe))
End Sub
@@ -267,8 +243,8 @@ Public Class frmScan
'startScanTimeout()
startScan()
cboFormat.SelectedIndex = cboFormat.FindStringExact("A4")
If cboFormat.SelectedIndex > 0 Then cbxAltFormat.Checked = True
'cboFormat.SelectedIndex = cboFormat.FindStringExact("A4")
'If cboFormat.SelectedIndex > 0 Then cbxAltFormat.Checked = True
End Sub
@@ -457,6 +433,18 @@ Public Class frmScan
.ValueMember = "Value"
End With
cboOrientation.Items.Clear()
Dim itemsOrient = [Enum].GetValues(GetType(PdfPageOrientation)).Cast(Of PdfPageOrientation)().Select(Function(e) New KeyValuePair(Of String, PdfPageOrientation)(e.ToString(), e)).ToList()
With cboOrientation
.DataSource = itemsOrient
.DisplayMember = "Key"
.ValueMember = "Value"
End With
If hasTwainSource Then
cboSource.Enabled = True
@@ -497,9 +485,13 @@ Public Class frmScan
Select Case ART
Case "DirectScan"
If cboFormat.SelectedIndex >= 0 Then
Dim selectedPaper As EnumPageSize = CType(cboFormat.SelectedValue, EnumPageSize)
If cbxAltFormat.Checked Then m_PDFCreator.PageSize = selectedPaper
Dim selectedPaper As EnumPageSize = CType(cboFormat.SelectedValue, EnumPageSize)
Dim orient As PdfPageOrientation = CType(cboOrientation.SelectedValue, PdfPageOrientation)
If cbxAltFormat.Checked Then
m_PDFCreator.PageSize = selectedPaper
If orient = PdfPageOrientation.Landscape Then
saveAsLandscape()
End If
End If
Dim PDF_bytes As Byte() = m_PDFCreator.SaveAsBytes(TryCast(Me, ISave))
@@ -596,10 +588,17 @@ Public Class frmScan
If SaveFileDialog.ShowDialog() = DialogResult.OK Then
' Multi page PDF
If cboFormat.SelectedIndex >= 0 Then
Dim selectedPaper As EnumPageSize = CType(cboFormat.SelectedValue, EnumPageSize)
If cbxAltFormat.Checked Then m_PDFCreator.PageSize = selectedPaper
End If
m_PDFCreator.Save(TryCast(Me, ISave), SaveFileDialog.FileName)
Dim orient As PdfPageOrientation = CType(cboOrientation.SelectedValue, PdfPageOrientation)
If cbxAltFormat.Checked Then
m_PDFCreator.PageSize = selectedPaper
If orient = PdfPageOrientation.Landscape Then
saveAsLandscape()
End If
End If
End If
m_PDFCreator.Save(TryCast(Me, ISave), SaveFileDialog.FileName)
End If
End If
Else
@@ -775,9 +774,13 @@ Public Class frmScan
Case "QuickScan"
Do
startScan()
If cboFormat.SelectedIndex >= 0 Then
Dim selectedPaper As EnumPageSize = CType(cboFormat.SelectedValue, EnumPageSize)
If cbxAltFormat.Checked Then m_PDFCreator.PageSize = selectedPaper
Dim selectedPaper As EnumPageSize = CType(cboFormat.SelectedValue, EnumPageSize)
Dim orient As PdfPageOrientation = CType(cboOrientation.SelectedValue, PdfPageOrientation)
If cbxAltFormat.Checked Then
m_PDFCreator.PageSize = selectedPaper
If orient = PdfPageOrientation.Landscape Then
saveAsLandscape()
End If
End If
Dim PDF_bytes As Byte() = m_PDFCreator.SaveAsBytes(TryCast(Me, ISave))
Me.fileName = addExtension(tbxSaveFileName.Text) ' DS.LAST_ID
@@ -828,7 +831,44 @@ Public Class frmScan
Private Sub cbxAltFormat_CheckedChanged(sender As Object, e As EventArgs) Handles cbxAltFormat.CheckedChanged
cboFormat.Enabled = cbxAltFormat.Checked
cboOrientation.Enabled = cbxAltFormat.Checked
End Sub
Private Sub saveAsLandscape()
Dim iImageWidth As Integer = m_ImageCore.ImageBuffer.GetBitmap(m_ImageCore.ImageBuffer.CurrentImageIndexInBuffer).Width
Dim iImageHeight As Integer = m_ImageCore.ImageBuffer.GetBitmap(m_ImageCore.ImageBuffer.CurrentImageIndexInBuffer).Height
'Dim tempListAnnotation As List(Of AnnotationData) = DirectCast(m_ImageCore.ImageBuffer.GetMetaData(m_ImageCore.ImageBuffer.CurrentImageIndexInBuffer, EnumMetaDataType.enumAnnotation), List(Of AnnotationData))
'For Each tempAnnotation As AnnotationData In tempListAnnotation
' Dim x As Integer = iImageHeight - (tempAnnotation.Location.Y + tempAnnotation.Size.Height)
' Dim y As Integer = tempAnnotation.Location.X
' Dim iWidth As Integer = tempAnnotation.Size.Height
' Dim iHeight As Integer = tempAnnotation.Size.Width
' Select Case tempAnnotation.AnnotationType
' 'case AnnotationType.enumLine:
' Case Dynamsoft.Core.Enums.AnnotationType.enumEllipse, Dynamsoft.Core.Enums.AnnotationType.enumRectangle, Dynamsoft.Core.Enums.AnnotationType.enumText
' tempAnnotation.StartPoint = New Point(x, y)
' tempAnnotation.EndPoint = New Point((tempAnnotation.StartPoint.X + iWidth), (tempAnnotation.StartPoint.Y + iHeight))
' Exit Select
' Case Dynamsoft.Core.Enums.AnnotationType.enumLine
' Dim startPoint As Point = tempAnnotation.StartPoint
' x = iImageHeight - startPoint.Y
' y = startPoint.X
' tempAnnotation.StartPoint = New Point(x, y)
' Dim endPoint As Point = tempAnnotation.EndPoint
' x = iImageHeight - endPoint.Y
' y = endPoint.X
' tempAnnotation.EndPoint = New Point(x, y)
' Exit Select
' End Select
'Next
If iImageHeight > iImageWidth Then
m_ImageCore.ImageProcesser.Rotate(m_ImageCore.ImageBuffer.CurrentImageIndexInBuffer, 90, False, EnumInterpolationMethod.BestQuality)
End If
End Sub
End Class