Funktion zur Behebung der Rotation - Class EnvelopeEditorController, Class FixPageRotation
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user