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

Need VB.Net help with detecting vertical text

Guest
Aug 04, 2017 Aug 04, 2017

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

You can’t.

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

Translate
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 05, 2017 Aug 05, 2017

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.

Translate
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
Guest
Aug 07, 2017 Aug 07, 2017
LATEST

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

Translate
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