ExportToRTF, DocConvertToRTF

The ExportToRTF and DocConvertToRTF method convert a PDF document to an RTF document.

 

This method needs special license.  Please, contact our Sales Department for more information

 

Syntax

ActiveX:

System.Boolean ExportToRTF(System.String FileName, CDIntfEx.acRtfExportOptions RtfOption, System.Boolean UseTabs)

DLL:

int DocConvertToRTF(EXTDOCHANDLE edhDocument, LPCWSTR FileName, DWORD OutputOptions, BOOL useTab)

 

Parameters

FileName

Full path of resulting RTF file.

RtfOption, OutputOptions

 

ActiveX Constants

DLL Constants

Value (Hex)

Value (Dec)*

Description

acRtfExportOptionAdvancedRTF

RTFOPTION_ADVANCED

0x0000

0

Using frames to position objects.

acRtfExportOptionFullRTF

RTFOPTION_FULL

0x0001

1

Text, Graphics, and images with no frames.

acRtfExportOptionRTFText

RTFOPTION_RTFTEXT

0x0002

2

Formatted text only

acRtfExportOptionText

RTFOPTION_TEXT

0x0003

3

Simple Text

 

RTFOPTION_NOTABS

0x1000

4096

 

(*) NOTE: Converting from HEX DWORD, unsigned and 32-bit unit of data

 

UseTabs

Replace tabs with spaces in the case of simple text output.

edhDocument

Handle Returned by DocOpen.

 

Return Value

The return value is True if the ExportToRTF method succeed. Otherwise, False If the ExportToRTF method fails.

The return value is zero if the DocConvertToRTF method succeed. If the DocConvertToRTF method fails, a negative value will returned.

 

Remarks

 It is recommended to use this method together with Optimize method.

 

Member of CDIntfEx.Document.

 

Example

<Flags()>

Public Enum OPTIMIZE As Integer

    NO_OPTIMIZATION = 0

    LINE_OPTIMIZATION = 1

    PARAGRAPH_OPTIMIZATION = 2

    TABLE_OPTIMIZATION = 3

End Enum

 

Private Sub Sample()

    ' Constants for Activation codes

    Const strLicenseTo As String = "Amyuni PDF Converter Evaluation"

    Const strActivationCode As String = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

    ' Declare a new cdintfex document if it does not exist in the form.

    Dim pdfDoc As New CDIntfEx.Document

 

    ' The SetLicenseKey method should be called after creating an object of type 

    ' CDIntfEx.Document to activate the advanced methods that require the object 

    ' activation code to work properly

    pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode)

 

    ' Open the document

    pdfDoc.Open("c:\temp\test.pdf")

 

    ' Optimize the document in Paragraph level

    pdfDoc.Optimize(OPTIMIZE.PARAGRAPH_OPTIMIZATION)

 

    ' Export to RTF, but the license needs to have that option

    pdfDoc.ExportToRTF("c:\temp\text.rtf", CDIntfEx.acRtfExportOptions.acRtfExportOptionFullRTF, True)

 

    ' Destroy pdfDoc object

    Set pdfDoc = Nothing

End Sub

[Flags]

public enum OPTIMIZE

{

    NO_OPTIMIZATION = 0,

    LINE_OPTIMIZATION = 1,

    PARAGRAPH_OPTIMIZATION = 2,

    TABLE_OPTIMIZATION = 3

}

private void Sample()

{

    // Constants for Activation codes

    const string strLicenseTo = "Amyuni PDF Converter Evaluation";

    const string strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";

 

    // Declare a new cdintfex document if it does not exist in the form.

    CDIntfEx.Document pdfDoc = new CDIntfEx.Document();

 

    // The SetLicenseKey method should be called after creating an object of type 

    // CDIntfEx.Document to activate the advanced methods that require the object 

    // activation code to work properly

    pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode);

 

    // Open the document

    pdfDoc.Open("c:\\temp\\test.pdf");

 

    // Optimize the document in Paragraph level

    pdfDoc.Optimize((int)OPTIMIZE.PARAGRAPH_OPTIMIZATION);

 

    // Export to RTF, but the license needs to have that option

    pdfDoc.ExportToRTF("c:\\temp\\text.rtf", CDIntfEx.acRtfExportOptions.acRtfExportOptionFullRTF, Convert.ToSByte(true));

}

// PDF Converter Cpp.cpp : Defines the entry point for the console application.

// 

 

#include <Windows.h>

#include <string>

#include <iostream>

#include "CdIntf.h"

#pragma comment (lib, "CDIntf.lib")

 

using namespace std;

 

enum OPTIMIZE 

{

    NO_OPTIMIZATION = 0,

    LINE_OPTIMIZATION = 1,

    PARAGRAPH_OPTIMIZATION = 2,

    TABLE_OPTIMIZATION = 3

};

 

int main()

{

     // Constants for Activation codes

    #define strLicenseTo  (LPCSTR)"Amyuni PDF Converter Evaluation"

    #define strActivationCode (LPCSTR)"07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

    // Declare a new cdintfex document if it does not exist in the form.

    EXTDOCHANDLE pdfDoc;

 

    // The SetLicenseKey method should be called after creating an object of type 

    // CDIntfEx.Document to activate the advanced methods that require the object 

    // activation code to work properly

    SetLicenseKeyA(strLicenseTo, strActivationCode);

 

    // Open the document

    LPBYTE passWord = nullptr;

    DocOpenA(&pdfDoc, (LPCSTR)"c:\\temp\\test.pdf", passWord);

 

    // Optimize the document in Paragraph level

    DocOptimize(pdfDoc, OPTIMIZE::PARAGRAPH_OPTIMIZATION);

 

    // Export to RTF, but the license needs to have that option

    DocConvertToRTFA(pdfDoc, (LPCSTR)"c:\\temp\\text.rtf", RTFOPTION_FULL, true);

 

    // Destroy pdfDoc object

    DocClose(pdfDoc);

    pdfDoc = nullptr;  

 

    return 0;

}

package Example;

 

import com.jacob.activeX.ActiveXComponent;

import com.jacob.com.Dispatch;

import com.jacob.com.Variant;

 

public class ExportToRTF {

    public enum OPTIMIZE 

    {

        NO_OPTIMIZATION (0),

        LINE_OPTIMIZATION (1),

        PARAGRAPH_OPTIMIZATION (2),

        TABLE_OPTIMIZATION (3);

        private int value;

        private OPTIMIZE(int value)

        {

            this.value = value;

        }

        public Object value(){

            return value;

        }

    }

 

    public enum RTFOPTION 

    {

        RtfExportOptionAdvancedRTF (0x0000),

        RtfExportOptionFullRTF (0x0001),

        RtfExportOptionRTFText (0x0002),

        RtfExportOptionText(0x0003);

        private int value;

        private RTFOPTION(int value)

        {

            this.value = value;

        }

        public Object value(){

            return value;

        }

    }

 

    public static void main(String[] args)

    {

        // Constants for Activation codes

        String strLicenseTo  = "Amyuni PDF Converter Evaluation";

        String strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";

 

        // Declare a new cdintfex document if it does not exist in the form.

        ActiveXComponent pdfDoc = new ActiveXComponent("CDIntfEx.Document.6.5"); 

 

        // The SetLicenseKey method should be called after creating an object of type 

        // CDIntfEx.Document to activate the advanced methods that require the object 

        // activation code to work properly

        Dispatch.call(pdfDoc, "SetLicenseKey", strLicenseTo, strActivationCode);

 

        // Open the document

        Dispatch.call(pdfDoc, "Open", "c:\\temp\\test.pdf");

 

        // Optimize the document in Paragraph level

        Dispatch.call(pdfDoc, "Optimize",OPTIMIZE.PARAGRAPH_OPTIMIZATION.value);

 

        // Export to RTF, but the license needs to have that option

        Dispatch.call(pdfDoc, "ExportToRTF", "c:\\temp\\text.rtf", RTFOPTION.RtfExportOptionFullRTF.value, true);

 

        // Destroy pdfDoc object

        pdfDoc = null;

    }

}

$OPTIMIZE = @{

    NO_OPTIMIZATION = 0

    LINE_OPTIMIZATION = 1

    PARAGRAPH_OPTIMIZATION = 2

    TABLE_OPTIMIZATION = 3

}

 

$RTFOPTION = @{

    RtfExportOptionAdvancedRTF = 0x0000

    RtfExportOptionFullRTF = 0x0001

    RtfExportOptionRTFText = 0x0002

    RtfExportOptionText = 0x0003

}

 

# Constants for Activation codes

$strLicenseTo  =  "Amyuni PDF Converter Evaluation"

$strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

#Declare a new cdintfex document if it does not exist in the form.

$pdfDoc = New-Object -ComObject CDIntfEx.Document.6.5

 

#The SetLicenseKey method should be called after creating an object of type 

#CDIntfEx.Document to activate the advanced methods that require the object 

#activation code to work properly

[System.__ComObject].InvokeMember('SetLicenseKey', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc, @($strLicenseTo, $strActivationCode))

 

#Open the document

[System.__ComObject].InvokeMember('Open', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,"c:\temp\test.pdf") 

 

#Optimize the document in Paragraph level

[System.__ComObject].InvokeMember('Optimize', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc, $OPTIMIZE::PARAGRAPH_OPTIMIZATION)

 

#Export to JPEG, but the license needs to have that option

[System.__ComObject].InvokeMember('ExportToRTF', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,

    @("c:\temp\text.rtf", $RTFOPTION::RtfExportOptionFullRTF.value, $TRUE)) 

 

#Destroy pdfDoc object

$pdfDoc = $null    

Const NO_OPTIMIZATION = 0

Const LINE_OPTIMIZATION = 1

Const PARAGRAPH_OPTIMIZATION = 2

Const TABLE_OPTIMIZATION = 3

 

Const acRtfExportOptionAdvancedRTF = 0

Const acRtfExportOptionFullRTF = 1

Const acRtfExportOptionRTFText = 2

Const acRtfExportOptionText = 3

Const acRtfExportOptionTextANSI = 4

 

' Constants for Activation codes

Const strLicenseTo = "Amyuni PDF Converter Evaluation"

Const strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

' Declare a new cdintfex document if it does not exist in the form.

Dim pdfDoc 

Set pdfDoc = CreateObject("CDIntfEx.Document.6.5")

 

' The SetLicenseKey method should be called after creating an object of type 

' CDIntfEx.Document to activate the advanced methods that require the object 

' activation code to work properly

pdfDoc.SetLicenseKey strLicenseTo, strActivationCode

 

' Open the document

pdfDoc.Open "c:\temp\test.pdf"

 

' Optimize the document in Paragraph level

pdfDoc.Optimize PARAGRAPH_OPTIMIZATION

 

' Export to RTF, but the license needs to have that option

pdfDoc.ExportToRTF "c:\temp\text.rtf", acRtfExportOptionFullRTF, True

 

' Destroy pdfDoc object

Set pdfDoc = Nothing