• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to rotate pdfs via a api

New Here ,
Aug 03, 2018 Aug 03, 2018

Copy link to clipboard

Copied

hello

we scan plans, about 300, i would rotate  all files in a folder via a vb.net program.

Sub Drehunng(inRichtung As String, inPDF As System.IO.FileInfo)

        Dim PDFout1 As New Acrobat.AcroPDDoc

        Dim Seite As Acrobat.AcroPDPage

        PDFout1.Open(inPDF.FullName)

        For i As Long = 0 To PDFout1.GetNumPages - 1

            Seite = PDFout1.AcquirePage(i)

            Select Case inRichtung

                Case "n"

                    Seite.SetRotate(0)

                Case "l"

                    Seite.SetRotate(270)

                Case "r"

                    Seite.SetRotate(90)

                Case "k"

                    Seite.SetRotate(180)

            End Select

        Next

        PDFout1.Save(1, inPDF.FullName)

        PDFout1.Close()

        gApp.CloseAllDocs()

    End Sub

it rotates but only from the orginal scanned pdf direction and not from the direction whitch is actually  saved.

How can we rotate from the actually saved direction and not from the orginal scanned pdf direction?

TOPICS
Acrobat SDK and JavaScript

Views

860

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 03, 2018 Aug 03, 2018

Copy link to clipboard

Copied

You should not just use SetRotate but you should factor in the original rotation via GetRotate. Even pages which seem upright may have a rotation value.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 14, 2024 May 14, 2024

Copy link to clipboard

Copied

I thank you very much When I'm helpless @฿69869766

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 21, 2024 May 21, 2024

Copy link to clipboard

Copied

LATEST

Hi

To rotate the pages based on the current saved direction, you'll need to retrieve the existing rotation angle of each page before applying the new rotation. Here's how you can modify your code to achieve this:

 

Sub Drehunng(inRichtung As String, inPDF As System.IO.FileInfo)
    Dim PDFout1 As New Acrobat.AcroPDDoc
    Dim Seite As Acrobat.AcroPDPage

    PDFout1.Open(inPDF.FullName)

    For i As Long = 0 To PDFout1.GetNumPages - 1
        Seite = PDFout1.AcquirePage(i)

        ' Get the current rotation angle of the page
        Dim currentRotation As Integer
        currentRotation = Seite.GetRotate()

        ' Calculate the new rotation angle based on the current saved direction and the desired rotation
        Dim newRotation As Integer
        Select Case inRichtung
            Case "n"
                newRotation = currentRotation + 0
            Case "l"
                newRotation = currentRotation + 270
            Case "r"
                newRotation = currentRotation + 90
            Case "k"
                newRotation = currentRotation + 180
        End Select

        ' Set the new rotation angle for the page
        Seite.SetRotate(newRotation)
    Next

    PDFout1.Save(1, inPDF.FullName)
    PDFout1.Close()
    gApp.CloseAllDocs()
End Sub

 

In this modified code, we first retrieve the current rotation angle of each page using the GetRotate() method. Then, we calculate the new rotation angle by adding the desired rotation angle to the current rotation angle. Finally, we set the new rotation angle for the page using the SetRotate() method.

This way, the rotation will be based on the current saved direction of each page rather than the original scanned PDF direction.

Elisendate_matcha.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines