Funktion zur Behebung der Rotation - Class EnvelopeEditorController, Class FixPageRotation
This commit is contained in:
parent
7481691b4e
commit
4d34eb7adc
@ -156,7 +156,11 @@ Public Class EnvelopeEditorController
|
||||
|
||||
Public Async Function CreateDocument(pDocumentFilePath As String) As Threading.Tasks.Task(Of EnvelopeDocument)
|
||||
Try
|
||||
Dim oFileInfo = New FileInfo(pDocumentFilePath)
|
||||
Dim oFixedPath = FixPageRotation.FixPageRotation(pDocumentFilePath)
|
||||
If oFixedPath <> pDocumentFilePath Then
|
||||
Logger.Info("PageRotation has been reseted to 0.")
|
||||
End If
|
||||
Dim oFileInfo = New FileInfo(oFixedPath)
|
||||
Dim oTempFiles As New TempFiles(State.LogConfig)
|
||||
Dim oTempFilePath = Path.Combine(oTempFiles._TempPath, Guid.NewGuid().ToString + oFileInfo.Extension)
|
||||
|
||||
@ -172,7 +176,7 @@ Public Class EnvelopeEditorController
|
||||
.FileNameOriginal = oFileInfo.Name,
|
||||
.Thumbnail = Thumbnail.GetThumbnailFromPDFFile(oTempFilePath),
|
||||
.PageCount = Thumbnail.GetPageCount(oTempFilePath),
|
||||
.Byte_Data = ReadFile(pDocumentFilePath)
|
||||
.Byte_Data = ReadFile(oFixedPath)
|
||||
}
|
||||
|
||||
Return oDocument
|
||||
|
||||
@ -362,6 +362,7 @@
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Helper\Encryption.vb" />
|
||||
<Compile Include="Helper\FixPageRotation.vb" />
|
||||
<Compile Include="Helper\RefreshHelper.vb" />
|
||||
<Compile Include="Helper\TempFiles.vb" />
|
||||
<Compile Include="Helper\Thumbnail.vb" />
|
||||
|
||||
48
EnvelopeGenerator.Form/Helper/FixPageRotation.vb
Normal file
48
EnvelopeGenerator.Form/Helper/FixPageRotation.vb
Normal file
@ -0,0 +1,48 @@
|
||||
Imports System.IO
|
||||
Imports GdPicture14
|
||||
|
||||
Public Class FixPageRotation
|
||||
''' <summary>
|
||||
''' Checks if there are any rotations in the document. If so, normalizes the page rotation to 0 without affecting its visual appearance.
|
||||
''' Creates and uses a new document with the corrected properties.
|
||||
''' Fixes the issue of annotations being rotated to match the page's rotation.
|
||||
''' </summary>
|
||||
''' <param name="pFilePath"></param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function FixPageRotation(pFilePath As String) As String
|
||||
|
||||
Dim oFolder As String = Path.GetDirectoryName(pFilePath)
|
||||
Dim oChanged As Boolean = False
|
||||
|
||||
Using gdpicturePDF As New GdPicturePDF()
|
||||
|
||||
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile(pFilePath, True)
|
||||
If status = GdPictureStatus.OK Then
|
||||
|
||||
Dim count As Integer = gdpicturePDF.GetPageCount()
|
||||
For i As Integer = 1 To count
|
||||
If gdpicturePDF.SelectPage(i) = GdPictureStatus.OK Then
|
||||
Dim rotation As Integer = gdpicturePDF.GetPageRotation()
|
||||
If rotation <> 0 Then
|
||||
gdpicturePDF.NormalizePage()
|
||||
oChanged = True
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
If oChanged Then
|
||||
Dim newFilesPath As String = Path.Combine(oFolder, "RotationFixed_" & Path.GetFileName(pFilePath))
|
||||
If gdpicturePDF.SaveToFile(newFilesPath) = GdPictureStatus.OK Then
|
||||
Return newFilesPath
|
||||
End If
|
||||
End If
|
||||
|
||||
End Using
|
||||
|
||||
Return pFilePath
|
||||
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Loading…
x
Reference in New Issue
Block a user