Need VB.Net help with detecting vertical text

Aug 04, 2017

Copy link to clipboard

Copied

I have a process that detects rotated pages and sets their orientation to 0 but I also need to detect vertical text on a page and act on that. In the test files I an using the page has not been rotated but the text (rasterized) is vertical. Using the Acrobat 11.0 object model through VB.NET, how can I achieve that? The following code does handle where the page has been rotated but does not detect the vertical text. Any help is appreciated.

    Private Sub cmdConvert_Click(sender As Object, e As EventArgs) Handles cmdConvert.Click

        Dim AcroXApp As Acrobat.AcroApp

        Dim AcroXAVDoc As Acrobat.AcroAVDoc

        Dim AcroXPDPage As Acrobat.AcroPDPage

        Dim AcroXPDDoc As Acrobat.AcroPDDoc

        Dim JSO As Object

        AcroXApp = CreateObject("AcroExch.App")

        AcroXApp.Hide()

        AcroXAVDoc = CreateObject("AcroExch.AVDoc")

        AcroXAVDoc.Open(txtTargetFile.Text, "")

        AcroXPDDoc = AcroXAVDoc.GetPDDoc

        JSO = AcroXPDDoc.GetJSObject

        Dim iPageCount = AcroXPDDoc.GetNumPages

        For i = 0 To iPageCount - 1

            Dim rotation = JSO.getPageRotation(i)

            Select Case rotation

                Case 90

                    AcroXPDPage = AcroXPDDoc.AcquirePage(i)

                    Debug.Print("Page " & i & " was set at " & rotation & " degree rotation")

                    AcroXPDPage.SetRotate(0)

                Case 180

                    AcroXPDPage = AcroXPDDoc.AcquirePage(i)

                    Debug.Print("Page " & i & " was set at " & rotation & " degree rotation")

                    AcroXPDPage.SetRotate(0)

                Case 270

                    AcroXPDPage = AcroXPDDoc.AcquirePage(i)

                    Debug.Print("Page " & i & " was set at " & rotation & " degree rotation")

                    AcroXPDPage.SetRotate(0)

            End Select

        Next

        Dim strOutFileName As String = Replace(txtTargetFile.Text, ".pdf", "_Rotated.pdf")

        JSO.SaveAs(strOutFileName)

        AcroXAVDoc.Close(False)

        AcroXApp.Exit()

        AcroXApp = Nothing

        AcroXAVDoc = Nothing

        AcroXPDDoc = Nothing

        JSO = Nothing

    End Sub

TOPICS
Acrobat SDK and JavaScript

Views

339

Likes

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

Need VB.Net help with detecting vertical text

Aug 04, 2017

Copy link to clipboard

Copied

I have a process that detects rotated pages and sets their orientation to 0 but I also need to detect vertical text on a page and act on that. In the test files I an using the page has not been rotated but the text (rasterized) is vertical. Using the Acrobat 11.0 object model through VB.NET, how can I achieve that? The following code does handle where the page has been rotated but does not detect the vertical text. Any help is appreciated.

    Private Sub cmdConvert_Click(sender As Object, e As EventArgs) Handles cmdConvert.Click

        Dim AcroXApp As Acrobat.AcroApp

        Dim AcroXAVDoc As Acrobat.AcroAVDoc

        Dim AcroXPDPage As Acrobat.AcroPDPage

        Dim AcroXPDDoc As Acrobat.AcroPDDoc

        Dim JSO As Object

        AcroXApp = CreateObject("AcroExch.App")

        AcroXApp.Hide()

        AcroXAVDoc = CreateObject("AcroExch.AVDoc")

        AcroXAVDoc.Open(txtTargetFile.Text, "")

        AcroXPDDoc = AcroXAVDoc.GetPDDoc

        JSO = AcroXPDDoc.GetJSObject

        Dim iPageCount = AcroXPDDoc.GetNumPages

        For i = 0 To iPageCount - 1

            Dim rotation = JSO.getPageRotation(i)

            Select Case rotation

                Case 90

                    AcroXPDPage = AcroXPDDoc.AcquirePage(i)

                    Debug.Print("Page " & i & " was set at " & rotation & " degree rotation")

                    AcroXPDPage.SetRotate(0)

                Case 180

                    AcroXPDPage = AcroXPDDoc.AcquirePage(i)

                    Debug.Print("Page " & i & " was set at " & rotation & " degree rotation")

                    AcroXPDPage.SetRotate(0)

                Case 270

                    AcroXPDPage = AcroXPDDoc.AcquirePage(i)

                    Debug.Print("Page " & i & " was set at " & rotation & " degree rotation")

                    AcroXPDPage.SetRotate(0)

            End Select

        Next

        Dim strOutFileName As String = Replace(txtTargetFile.Text, ".pdf", "_Rotated.pdf")

        JSO.SaveAs(strOutFileName)

        AcroXAVDoc.Close(False)

        AcroXApp.Exit()

        AcroXApp = Nothing

        AcroXAVDoc = Nothing

        AcroXPDDoc = Nothing

        JSO = Nothing

    End Sub

TOPICS
Acrobat SDK and JavaScript

Views

340

Likes

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
Aug 04, 2017 0
Adobe Employee ,
Aug 04, 2017

Copy link to clipboard

Copied

You can’t.

The .NET APIs don’t have access to content.

Likes

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
Reply
Loading...
Aug 04, 2017 0
Most Valuable Participant ,
Aug 05, 2017

Copy link to clipboard

Copied

Using wild guesswork you might use the JavaScript getPageNthWord and getPageNthWordQuads to pick likely candidates. A sufficiently long string that is taller than it is wide is suggestive. Deriving the parameters for guesswork will be an interesting exercise.

Likes

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
Reply
Loading...
Aug 05, 2017 0
Aug 07, 2017

Copy link to clipboard

Copied

The below code allows me to identify the vertical text:

        For i = 0 To iPageCount - 1

            AcroXPDPage = AcroXPDDoc.AcquirePage(i)
            iNumWordsOnPage = JSO.getPageNumWords(i)

            For j = 0 To iNumWordsOnPage - 1
                strCurrentWord = JSO.getPageNthWord(i, j)

                Dim Array() As Object
                Array = JSO.getPageNthWordQuads(i, j)

                Dim itemFromArray As Object
                itemFromArray = Array(0)

                Dim coord1 As Double
                Dim coord2 As Double
                Dim coord3 As Double
                Dim coord4 As Double

                coord1 = itemFromArray(0)
                coord2 = itemFromArray(1)
                coord3 = itemFromArray(2)
                coord4 = itemFromArray(3)

                If coord2 <> coord4 Then
                    MsgBox("Vertical Text = " & strCurrentWord)
                End If

            Next

        Next

Likes

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
Reply
Loading...
Aug 07, 2017 0