SaveEx, DocSaveEx

The SaveEx and DocSaveEx methods save a modified PDF document using different Saving Options.

 

Syntax

ActiveX:

System.String SaveEx(System.String FileName, CDIntfEx.FileSaveOptionConstants SaveOptions)

DLL:

int DocSaveEx(EXTDOCHANDLE edhDocument, LPCSTR szFileName, int Options)

 

Parameters

FileName, szFileName

Full path of the PDF file to save.

SaveOptions, Options

Option

Value

Description

acFileSaveAll

0

Save document data and view.

The document can be viewed with any PDF viewer and retains all design data.

acFileSaveView

1

Save only document view.

The document can be viewed with any PDF viewer including Amyuni PDF Creator but all design data such as database connection, OLE objects, is lost.

acFileSaveDesign

2

Save only document data.

The document can be opened, viewed and edited only with the Amyuni PDF Creator. It will show as blank pages in other viewers.

acFileSaveDefault

-1

Take the default Save option stored in the document object, i.e., one of the 3 options above.

acFileSavePDFA_7

3

[Obsolete].

acFileSavePDFA

4

Save document keeping the PDFALevel value from the original file. Otherwise, it will be marked as PDF/A-1b.  However, this flag doesn't adjust the other requirements to be valid PDF/A like Embedding Fonts, etc, only the PDFALevel value.

acFileSavePDF14

5

Save document PDF Specifications Version 1.4.

edhDocument

Handle Returned by DocOpen.

 

 

Return Value

The return value of the ActiveX interface’s SaveEx is a string. The string contains the log of the save process, and throws an exception if an error occurs.

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

 

Remarks

Member of CDIntfEx.Document.

 

Example

Public 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")

 

    ' Set AutoBookmarks

    pdfDoc.AutoBookmarks(2, "", 1)

 

    ' Save the document

    Dim saveOptions As CDIntfEx.FileSaveOptionConstants = CDIntfEx.FileSaveOptionConstants.acFileSaveView

    pdfDoc.SaveEx("c:\temp\AutoBookmarked.pdf", saveOptions)

End Sub

public void AutoBookmarks()

{

    // 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");

 

    // Set AutoBookmarks

    pdfDoc.AutoBookmarks(2, "", 1);

 

    // Save the document

    CDIntfEx.FileSaveOptionConstants saveOptions = CDIntfEx.FileSaveOptionConstants.acFileSaveView;

    pdfDoc.SaveEx(@"c:\temp\AutoBookmarked.pdf", saveOptions);

}

// 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 FileSaveOptionConstants

{

    acFileSaveAll = 0,

    acFileSaveDefault = -1,

    acFileSaveView = 1,

    acFileSaveDesign = 2,

    acFileSavePDFA_7 = 3,

    acFileSavePDFA = 4,

    acFileSavePDF14 = 5

}; 

 

int main()

{

     // Constants for Activation codes

    #define strLicenseTo  "Amyuni PDF Converter Evaluation"

    #define strActivationCode "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, "C:\temp\\test.pdf", passWord);

 

    // Set AutoBookmarks

    DocAutoBookmarksA(pdfDoc, 2, "", 1);

 

    // Save the document

    int saveOptions = (int)FileSaveOptionConstants::acFileSaveView;

    DocSaveExA(pdfDoc, "C:\temp\\AutoBookmarked.pdf", saveOptions);

 

    // 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 Sample {

    public enum FileSaveOptionConstants

        {

            acFileSaveAll(0),

            acFileSaveDefault(-1),

            acFileSaveView(1),

            acFileSaveDesign(2),

            acFileSavePDFA_7(3),

            acFileSavePDFA(4),

            acFileSavePDF14(5);

            public int value;

            public FileSaveOptionConstants(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");

 

        // Set AutoBookmarks

        Dispatch.call(pdfDoc, "AutoBookmarks", 2, "", 1);

 

        // Save the document

        int saveOptions = FileSaveOptionConstants.acFileSaveView.value;

        Dispatch.call(pdfDoc, "SaveEx", "C:\temp\\AutoBookmarked.pdf", saveOptions);

 

        // Destroy pdfDoc object

        pdfDoc = null;

    }

}

$FileSaveOptionConstants = @{

    acFileSaveAll = 0

    acFileSaveDefault = -1

    acFileSaveView = 1

    acFileSaveDesign = 2

    acFileSavePDFA_7 = 3

    acFileSavePDFA = 4

    acFileSavePDF14 = 5

 

# 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") 

 

#Set AutoBookmarks

[System.__ComObject].InvokeMember('AutoBookmarks', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,@(2, "", 1)) 

 

#Save the document

$saveOptions = $FileSaveOptionConstants::acFileSaveView

[System.__ComObject].InvokeMember('SaveEx', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,@("c:\temp\AutoBookmarked.pdf", $saveOptions)) 

 

#Destroy pdfDoc object

$pdfDoc = $null

' FileSaveOptionConstants

Const acFileSaveAll = 0

Const acFileSaveDefault = -1

Const acFileSaveView = 1

Const acFileSaveDesign = 2

Const acFileSavePDFA_7 = 3

Const acFileSavePDFA = 4

Const acFileSavePDF14 = 5

 

' Constants for Activation codes

Const strLicenseTo = "Amyuni PDF Converter Evaluation"

Const strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

' Declare a new Document object

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"

 

' Set AutoBookmarks

pdfDoc.AutoBookmarks 2, "", 1

 

' Save the document

Dim saveOptions

saveOptions = acFileSaveView

pdfDoc.SaveEx "c:\temp\AutoBookmarked.pdf", saveOptions

 

' Destroy pdfDoc object

Set pdfDoc = Nothing