Advertisement
Advertisement
| 03.28.2008 at 01:41AM PDT, ID: 23276651 | Points: 500 |
|
[x]
Attachment Details
|
||
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 03.28.2008 at 01:44AM PDT, ID: 21228753 |
| 03.29.2008 at 11:42PM PDT, ID: 21239838 |
| 04.02.2008 at 09:58AM PDT, ID: 21265019 |
| 04.02.2008 at 04:31PM PDT, ID: 21268510 |
| 04.02.2008 at 04:50PM PDT, ID: 21268620 |
| 04.02.2008 at 05:02PM PDT, ID: 21268680 |
| 04.02.2008 at 06:29PM PDT, ID: 21269106 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: |
#include "fapi.h"
#include "fdetypes.h"
#include "fmemory.h"
#include "futils.h"
#include "fstrings.h"
#define SVPDF 1
#define SVHTML 2
/* Function protocols */
VoidT SaveAsPdf(VoidT);
VoidT SaveAsHtml(VoidT);
VoidT openBookFiles(F_ObjHandleT bookId);
VoidT F_ApiInitialize(IntT init)
{
F_ObjHandleT menuBarId, menuId;
switch(init)
{
case FA_Init_First:
menuBarId = F_ApiGetNamedObject(FV_SessionId, FO_Menu, "!BookMainMenu");
menuId = F_ApiDefineAndAddMenu(menuBarId, "APIMenu", "API");
F_ApiDefineAndAddCommand(SVPDF, menuId, "SvPdfCmd", "Save As PDF", "");
F_ApiDefineAndAddCommand(SVHTML, menuId, "SvHtmlCmd", "Save As HTML", "");
F_ApiBailOut();
break;
}
}
VoidT F_ApiCommand(IntT command)
{
switch(command)
{
case SVPDF:
SaveAsPdf();
break;
case SVHTML:
SaveAsHtml();
break;
default:
break;
}
}
VoidT SaveAsPdf()
{
F_PropValsT params, *returnParams = NULL;
F_ObjHandleT docId, pgfId, saveId, bookId;
IntT i = 0;
StringT name = NULL;
F_FdeInit();
bookId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_ActiveBook);
/* Open all files */
openBookFiles(bookId);
/* Get docId in order to set Acrobat Bookmark levels */
docId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_FirstOpenDoc);
if(!docId)
{
F_ApiAlert("Couldn't open first component.", FF_ALERT_CONTINUE_NOTE);
return;
}
/* Sets "Body" to the highest Acrobat Bookmark level. */
pgfId = F_ApiGetNamedObject(docId, FO_PgfFmt, "Body");
F_ApiSetInt(docId, pgfId, FP_AcrobatLevel, 1);
F_ApiSimpleSave(docId, name, False);
/* Sets the save parameters so as to save as PDF and allow user to name file.*/
params = F_ApiGetSaveDefaultParams();
i = F_ApiGetPropIndex(¶ms, FS_FileType);
params.val[i].propVal.u.ival = FV_SaveFmtPdf;
i = F_ApiGetPropIndex(¶ms, FS_SaveAsModeName);
params.val[i].propVal.u.ival = FV_SaveAsNameAskUser;
i = F_ApiGetPropIndex(¶ms, FS_SaveMode);
params.val[i].propVal.u.ival = FV_ModeSaveAs;
/* Saves the book and all its components to one PDF file */
saveId = F_ApiSave(bookId, "", ¶ms, &returnParams);
/* Close the open files.*/
while (docId)
{
F_ApiClose(docId, FF_CLOSE_MODIFIED);
docId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_NextOpenDocInSession);
}
F_ApiDeallocatePropVals(¶ms);
F_ApiDeallocatePropVals(returnParams);
}
VoidT SaveAsHtml()
{
F_PropValsT params, *returnParams = NULL;
F_ObjHandleT saveId, bookId;
IntT i = 0;
F_FdeInit();
/* Gets the active book (bookId) */
bookId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_ActiveBook);
/* Sets save parameters */
params = F_ApiGetSaveDefaultParams();
i = F_ApiGetPropIndex(¶ms, FS_FileType);
params.val[i].propVal.u.ival = FV_SaveFmtFilter;
i = F_ApiGetPropIndex(¶ms, FS_SaveFileTypeHint);
params.val[i].propVal.u.sval = F_StrCopyString("0001ADBEHTML");
i = F_ApiGetPropIndex(¶ms, FS_SaveAsModeName);
params.val[i].propVal.u.ival = FV_SaveAsNameAskUser;
i = F_ApiGetPropIndex(¶ms, FS_SaveMode);
params.val[i].propVal.u.ival = FV_ModeSaveAs;
/* Saves the book and all its components to a single HTML file.*/
saveId = F_ApiSave(bookId, "", ¶ms, &returnParams);
F_ApiDeallocatePropVals(¶ms);
F_ApiDeallocatePropVals(returnParams);
}
VoidT openBookFiles(F_ObjHandleT bookId)
{
IntT i = 0;
F_PropValsT script, *returnp = NULL;
F_ObjHandleT compId;
F_ObjHandleT docId;
StringT compName = NULL;
/* create open script which minimizes user response*/
script = F_ApiGetOpenDefaultParams();
i = F_ApiGetPropIndex(&script, FS_MakeVisible);
script.val[i].propVal.u.ival = False;
i = F_ApiGetPropIndex(&script, FS_RefFileNotFound);
script.val[i].propVal.u.ival = FV_AllowAllRefFilesUnFindable;
i = F_ApiGetPropIndex(&script, FS_FileIsOldVersion);
script.val[i].propVal.u.ival = FV_DoOK;
i = F_ApiGetPropIndex(&script, FS_FontChangedMetric);
script.val[i].propVal.u.ival = FV_DoOK;
i = F_ApiGetPropIndex(&script, FS_FontNotFoundInCatalog);
script.val[i].propVal.u.ival = FV_DoOK;
i = F_ApiGetPropIndex(&script, FS_FontNotFoundInDoc);
script.val[i].propVal.u.ival = FV_DoOK;
i = F_ApiGetPropIndex(&script, FS_LanguageNotAvailable);
script.val[i].propVal.u.ival = FV_DoOK;
i = F_ApiGetPropIndex(&script, FS_LockCantBeReset);
script.val[i].propVal.u.ival = FV_DoOK;
i = F_ApiGetPropIndex(&script, FS_UpdateTextReferences);
script.val[i].propVal.u.ival = FV_DoNo;
i = F_ApiGetPropIndex(&script, FS_UpdateXRefs);
script.val[i].propVal.u.ival = FV_DoNo;
i = F_ApiGetPropIndex(&script, FS_UseAutoSaveFile);
script.val[i].propVal.u.ival = FV_DoNo;
i = F_ApiGetPropIndex(&script, FS_UseRecoverFile);
script.val[i].propVal.u.ival = FV_DoNo;
i = F_ApiGetPropIndex(&script, FS_AlertUserAboutFailure);
script.val[i].propVal.u.ival = False;
i = F_ApiGetPropIndex(&script, FS_BeefyDoc);
script.val[i].propVal.u.ival = FV_DoOK;
i = F_ApiGetPropIndex(&script, FS_FileIsInUse);
script.val[i].propVal.u.ival = FV_OpenViewOnly;
i = F_ApiGetPropIndex(&script, FS_FileIsStructured);
script.val[i].propVal.u.ival = FV_OpenViewOnly;
i = F_ApiGetPropIndex(&script, FS_OpenFileNotWritable);
script.val[i].propVal.u.ival = FV_DoOK;
/* get all components in the active book and open using script */
compId = F_ApiGetId(FV_SessionId, bookId, FP_FirstComponentInBook);
i = 0;
while(compId){
/* get component name */
compName = F_ApiGetString(bookId, compId, FP_Name);
/* open the document with the component name */
docId = F_ApiOpen(compName, &script, &returnp);
/* check outcome of open for FV_ReferencedFilesWerentFound */
if(F_ApiCheckStatus(returnp, FV_ReferencedFilesWerentFound)){
F_Printf(NULL, (StringT) "%s contains graphic files that could not be found.\n", compName);
}
/* check status of FV_UnresolvedTextInsets */
if(F_ApiCheckStatus(returnp, FV_UnresolvedTextInsets)){
F_Printf(NULL, (StringT) "%s contains imported text files that could not be found.\n", compName);
}
/* deallocate propVals */
F_ApiPrintSaveStatus(returnp);
F_ApiDeallocatePropVals(returnp);
if(compName != NULL)
F_Free(compName);
/* get next component in book */
compId = F_ApiGetId(bookId, compId, FP_NextComponentInBook);
i++;
}
F_ApiDeallocatePropVals(&script);
}
|
| 04.03.2008 at 12:22AM PDT, ID: 21270272 |
| 04.03.2008 at 03:00AM PDT, ID: 21270928 |
| 04.03.2008 at 08:44AM PDT, ID: 21273812 |
| 04.13.2008 at 06:57PM PDT, ID: 21347077 |
| 04.13.2008 at 11:14PM PDT, ID: 21347831 |
| 07.01.2008 at 05:24PM PDT, ID: 21912605 |