SCMS_AO_TABLE_GET - PDF Open Error
Hi All,
Iu2019ve a required to attach a vendor invoice attached to Miro document stored using Archive Link.
I'm using SCMS_AO_TABLE_GET to get the archived document into internal table. The internal table is in binary format (1024).
Inoder to convert binary internal table from 1024 to 255 as required by SO_DOCUMENT_SEND_API1, I am converting the raw data using FM SCMS_BINARY_TO_FTEXT and followed by another function module to convert it to solisti1.
I do get an email with a PDF attached but when I click on PDF, it gives an error. Looks like there is some problem decoding the data.
Please help!
Hereu2019s my piece of code.
DATA: binobject LIKE TBL1024 OCCURS 200,
archivobject LIKE DOCS OCCURS 200 WITH HEADER LINE,
length_bin TYPE I,
length_att TYPE I,
length_archive LIKE SAPB-LENGTH.
REFRESH: binobject, attachment.
CALL FUNCTION 'SCMS_AO_TABLE_GET'
EXPORTING
ARC_ID = archiv_id
DOC_ID = arc_doc_id
COMP_ID = 'data'
IMPORTING
LENGTH = length_bin
TABLES
DATA = binobject
EXCEPTIONS
error_http = 1
error_archiv = 2
error_kernel = 3
error_config = 4
others = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
RAISING ERROR_RETRIEVAL.
ENDIF.
CALL FUNCTION 'SCMS_BINARY_TO_FTEXT'
EXPORTING
input_length = length_bin
IMPORTING
output_length = length_att
TABLES
binary_tab = binobject
ftext_tab = archivobject
EXCEPTIONS
failed = 1
others = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
RAISING ERROR_RETRIEVAL.
ENDIF.
length_att = length_bin.
length_archive = length_att.
CALL FUNCTION 'Z_WF_CONVERT_DOCTABLE_2_OFFICE'
EXPORTING
LENGTH = length_archive
TABLES
ARCHIVOBJECT = archivobject
ATTACHMENT = lt_objbin.
length = length_archive.
Email Attachment Details
CLEAR l_tab_lines.
DESCRIBE TABLE lt_objbin LINES l_tab_lines.
Creation of the entry for the compressed attachment
l_objpack-transf_bin = 'X'.
l_objpack-head_start = 1.
l_objpack-head_num = 1.
l_objpack-body_start = 1.
l_objpack-doc_type = 'PDF'.
l_objpack-obj_name = l_obj.
l_objpack-obj_descr = l_obj.
l_objpack-body_num = l_tab_lines.
l_objpack-doc_size = l_tab_lines * l_c_255.
APPEND l_objpack TO lt_objpack.
CLEAR l_objpack.
Completing the recipient list
l_reclist-receiver = p_email.
l_reclist-express = 'X'.
l_reclist-rec_type = 'U'.
APPEND l_reclist TO lt_reclist.
CLEAR l_reclist.
CONCATENATE 'GOS Attachment'(018)
sy-datum INTO l_obj SEPARATED BY space.
APPEND l_obj TO lt_objhead.
Email Body Details
CLEAR l_tab_lines.
DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 +
STRLEN( l_string ). "size of doc in bytes
l_doc_chng-obj_name = sy-repid.
l_doc_chng-obj_langu = sy-langu.
l_doc_chng-obj_descr = l_string.
l_doc_chng-sensitivty = 'P'.
Send the document
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = l_doc_chng
put_in_outbox = ' '
commit_work = 'X'
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_objbin
contents_txt = lt_objtxt
contents_hex = lt_contents_hex
receivers = lt_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
ENDFUNCTION.
FUNCTION Z_WF_CONVERT_DOCTABLE_2_OFFICE.
""Lokale Schnittstelle:
*" IMPORTING
*" VALUE(LENGTH) LIKE SAPB-LENGTH
*" TABLES
*" ARCHIVOBJECT STRUCTURE DOCS
*" ATTACHMENT STRUCTURE SOLISTI1
Die ArchiveLink-API liefert das Dokument in einer internen
Tabelle, der Länge 1024 zurück.
SAP-Office-API benötigt eine interne Tabelle der Länge 255.
Diese Funktion konvertiert von der ArchiveLink-Tabelle in
die SAP-Office konforme Tabelle.
DATA: currentPos TYPE I, " Zeiger auf die Leseposition in
" der ArchiveLink-Tabelle
writePos TYPE I, " Zeiger auf Schreibposition
remain TYPE I, " Anzahl Zeichen in der aktuellen
" Zeile des ArchiveLink-Objektes,
" Max=255
written TYPE I, " Anzahl bytes übertragen
targetLines TYPE I, " Größe der Zieltabelle in Zeilen
lines_attachment TYPE I, " Anzahl der Zeilen im Attachement.
currentIndex TYPE I, " Aktuelle Zeile in der Quelltab.
line_out(255) TYPE C,
line_attachment TYPE solix,
line_len TYPE I. " Länge derselbigen
currentPos = 0.
writePos = 0.
REFRESH: attachment.
CLEAR: line_out, attachment.
targetLines = length / 255.
" Rest prüfen
remain = length - ( targetLines * 255 ).
IF remain <> 0. " Ja, noch eine Restzeile
ADD 1 TO targetLines.
ENDIF.
remain = 255. " Wieder initialisieren
currentIndex = 1.
WHILE lines_attachment <= targetLines.
READ TABLE archivobject INDEX currentIndex.
line_OutwritePos(remain) = archivobjectcurrentPos(remain).
" Concat schluckt spaces
written = remain.
line_len = writePos + remain. " writePos beginnt ja bei 1
writePos = writePos + remain.
IF writePos = 255. " Voll gefüllt, dann appenden
APPEND line_out TO attachment.
CLEAR line_out.
writePos = 0.
ELSEIF writePos > 255.
" exception
ENDIF.
" Jetzt prüfen, ob dies bereits der Rest der Quell-Zeile war.
" Wenn ja, dann müssen wir beim nächsten Durchlauf die
" nächste Zeile lesen.
IF currentPos > 769.
ADD 1 TO currentIndex.
" Und den Rest ausrechnen, mit dem die nächste Zeile
" noch gefüllt werden muss.
remain = currentPos + 255 - 1024.
*---> Insert part IIId
" Wenn die letzten Bytes exakt reingepaßt haben, dann eine
" neue volle zeile lesen
IF remain <= 0.
remain = 255.
ENDIF.
*<---- end of Insert
currentPos = 0.
ELSE. " Die aktuelle Zeile enthält noch genügend Bytes, um
" voll zu lesen.
ADD written TO currentPos. " Zeiger weiterschieben
IF currentPos > 769. " Nächste Zeile kann nicht mehr
" voll gefüllt werden, da keine
" 255 byte übrig sind
*---> Insert part IIId
IF currentPos >= 1024. " Hat genau bis zum Ende gereicht
remain = 255.
ADD 1 TO currentIndex.
currentPos = 0.
ELSE.
remain = 1024 - currentPos. " Rest ausrechnen
ENDIF.
*<---- end of Insert
ELSE.
remain = 255. " sonst voll befüllen
ENDIF.
ENDIF.
DESCRIBE TABLE attachment LINES lines_attachment.
ENDWHILE.
ENDFUNCTION.
Hi Sandra,
I get the arc_id from the TOA01 table.
The result of the data parameter is a HTML file saying that file doesnt exist.
But, when I access the OAR transaction, the file is there.
Thanks for helping
Similar Messages
-
PDF opening error for smartform
Hi All.
after excuting dmartform ,
it will generated Pdf and sending to mail.
when iam opening pdf file in SOST transaction or mail
it will giving error like " There was on error opening this document. this file is damaged and could not be repaired.
how should overcome this issue.
saimedhaHi saimedhaa ,
What Karthik said is correct
i faced same problem
please check wheter OTF conversion hapen or not
gt_otfdata is having data or not
if it have data than u will not get any problem -
Eine PDF-Datei kann unter Android nicht geöffnet werden. Unter Windows ist diese Datei zu öfnnen.
Eine andere PDF-Datei kann in gleicher Situation unter beiden Betriebssystemen geöffnet werden.
Can´t open PDF-File under Android, but same File could be opend under Windows.
Another PDF-File could be opend under Android an Windows.I Found the problem:
Android App can´t handle multiple layers in pdf-document -
Hi, I am having pdf save functionality using trusted functions in my application. earlier we used adobe reader 8.1.3 and it worked fine, now we upgraded to adobe reader 9.4.0 and there on the problem comes in. when ever we are saving it is creaing a code in DBConnects.sav file. we as having large number of users we use to push this file to the field. now that with this upgrade this file is becoming system depending. how can we get ridoff this. Please help me out.
some of the sample data from my DBConnect.sav file as shown below. the code before Provider is appeding all the time.
7DE10A1A000010000A002FF200203029, Provider=MSDASQL.1;Persist Security Info=False;User ID=pmxuser;Data Source=ides;Initial Catalog=ides
E22BBE8EFFFF1FFF0A002FF1FF503028, Provider=MSDASQL.1;Persist Security Info=False;Data Source=edocExcelThanks Paul for your response.
While doing research I found out that Adobe generates a file called DBConnects.sav inside "C:\Documents and Settings\.....\Application Data\Adobe\Acrobat\8.0" which remebers the data connection. If I am making an entry of my data connection (eg. Provider=MSDASQL;Persist Security Info=False;Data Source=eDocMDB;) in this file then for all the forms which are having the same data connection is not asking any confirmation for allowing the data connection. Adobe made the same entry even If you check the checkbox "Remeber this choice" in the database confirmation dialog.
Now the problem which I am facing is for Adobe Reader 9.4 version. Adobe 9.4 is also making an entry in DBConnects.sav file but now it is form dependent. It is appending an unique string before the actual data connection string. It is making an entry like "9805AD51FFFF1FFF0A002FF1FFE03028, Provider=MSDASQL;Persist Security Info=False;Data Source=eDocMDB;" in DBConnect.sav. Now even the other form is also using the same connection string, it is asking me to allow the connection at least once for each form. If I checking the remember choice at least once for each connection of each form, it works fine. Myforms are dynamic and they change everyday for every user. Please let me know if you have any idea so that Adobe 9.4 do not append the unique string before makning entry into DBConnects.sav. -
Hi,
Not able to open PDF or do any changes even if the PDF opens. Run Time Error is shown every time when trying to open PDF. Please helpHi Shilpa ,
Please refer to the following link and see if that helps you out.
https://helpx.adobe.com/acrobat/kb/runtime-error-roaming-profile-workflows.html
Are you trying to access the PDF with Acrobat or Adobe Reader?
Regards
Sukrit Dhingra -
'failed to open the PDF file' error - Indesign CS3 on Mac
Hi,
Whenever I place PDFs that were created by any other app besides indesign or Illustrator I get a 'failed to open the PDF file' error, previously these PDFs were fine to place but all of a sudden they're not... Help?
I'm not too keen on opening in Illustrator and resaving for the rest of the foreseeable future either...
JaredThanks for the reminder, Scott.
http://indesignsecrets.com/failed-to-open-pdf-error-show-options-to-fix-it.php
Bob -
Trouble opening pdf file, error 1074724867:3
trouble opening pdf file, error 1074724867:3
Ask in the Acrobat/ Adobe Reader forum and provide more info. What system? what version of the program(s)? What PDF?
Mylenium -
Just installed reader.Have windows 8.1 Lenova. cant open Reader or pdfs without error: AcroMissingCompWClass: AcroRD32.exe Application Error.
it only fails to open PDF attachments to Outlook 2010 operating with 8.1 or 8.2. you previw them and save them and open but not open directly.
-
"PDF Open Options" in Applescript
So I am trying to batch convert a bunch of PDFs to JPEG files as part of a larger Applescript, and I'm finding that some of the parameters in "PDF Open Options" are ignored. Namely, the "height", "width" and "constrain proportions" parameters.
This code is lifted directly from the Photoshop CS3 Scripting Guide (with filename changed, of course):
tell application "Adobe Photoshop CS3"
set myFilePath to alias "WABEL0457937:Users:Charles:Desktop:8925.pdf"
with timeout of 10000 seconds
open myFilePath as PDF with options {class:PDF open options, height:pixels 100, width:pixels 200, mode:RGB, resolution:72, use antialias:true, page:1, constrain proportions:false}
end timeout
end tell
In the resulting file, the "resolution" is correct, but the height and width are calculated using the PDF's original height and width multiplied by the resolution, and the image is constrained to the original proportions.
I thought it might be a collision with specifying the resolution and the height/width in pixels, so I tried omitting the resolution, but then it just defaults to 300.
Anyone else create a script that opens PDFs and run into this?Thanks for that!
(If those parameters are deprecated since CS2, it's probably bad form for Adobe to use them in their documentation for CS3. Just sayin'!)
Anyway, it looks like the shell script you quoted gives the page height in points with an assumed resolution of 72 DPI. I can use that with my target dimension to calculate what to set the resolution to.
In case it helps anyone else, here's the working code I came up with:
-- ("str_replace" is a custom function to find and replace text in a string, it's not built-in to Applescript)
set pageHeight to do shell script "/usr/bin/mdls -name kMDItemPageHeight " & quoted form of (POSIX path of this_item as string)
set pageHeight to my str_replace("kMDItemPageHeight = ", "", pageHeight)
set pageWidth to do shell script "/usr/bin/mdls -name kMDItemPageWidth " & quoted form of (POSIX path of this_item as string)
set pageWidth to my str_replace("kMDItemPageWidth = ", "", pageWidth)
if (pageHeight as number) is greater than (pageWidth as number) then
set pdf_resolution to round (1000 / (pageHeight as number) * 72) rounding up
else
set pdf_resolution to round (1000 / (pageWidth as number) * 72) rounding up
end if
try
with timeout of 5 seconds
open alias ("WABEL0457937:Users:Charles:Desktop:Test:image_prep:" & image_id & ".pdf") as PDF with options {class:PDF open options, resolution:pdf_resolution, mode:RGB, use antialias:true, suppress warnings:false, use page number:true, page:1, crop page:media box}
end timeout
on error
-- I have some sections here that check for and handle progress windows, password prompts, and such
-- so the script can either continue or fail gracefully
end try
All of the images coming out of this script are just over 1000 pixels at their widest dimension. Since it's not critical that they be exactly 1000 (just very close), I was able to completely eliminate the resizing portion of the script to save even more processing time.
Thanks for the pointers, everyone! -
PDF opens in all versions of Acrobat except 7
I am working on a project where we create PDF documents with FOP. The generated PDFs open in Version 6, 8 and 9 but NOT 7! We get an error
"There was a problem reading this document(114)" The document is partially rendered and disappears when you scroll down etc. I need to know is there a setting specific to Acrobat 7 that is causing this or is there something in the XSL mark-up that Acrobat 7 does not like. I am really under pressure for a fix on this one so any help or assistance is greatly appreciatedApache Fop http://xmlgraphics.apache.org/fop/ takes an xml file and combines with an xsl stylesheet to create a PDF. (Although we are using a .net verion FONET)
-
We are creating PDF Form in Adobe Live Cycle ES 8.2. These forms are rendered in an IFRAME within browser.
On IE7, when we submit one form (On pressing submit button on pdf) we have save XML data in database and redirects on Form List page.
When we reopens same form again and again, PDF opens in TOP frame instead of iframe.
Everything works fine in first time with fresh browser (IE7), The code is running successfully on Mozilla and IE8.
We can reproduce this error on IE7 + Adobe reader 9.2 machine
Please suggest.Which PDF viewer are you using?
-
Slow processing and getting opening errors/warnings
I've modified the PDF Binder sample to get a plugin that would open PDF's and Tif files, and save them as PDF/A-1b (code below).
It's working. The problem: it's processing too slow (compared with the Actions batch processing)... and I've been getting warnings/and errors about "The imput file is corrupt or of an unknown/unsupported type" type. This is stopping my batch process until I click OK, and the it continues.
I am trying to process a few thousand of tif files now. I tried first to use the Batch processing capability built in the Acrobat X... an it works, but only with the first 255 documents in the folder... then gives an "insufficient disk space" message for the rest of the files in the directory.
So, 2 questions: Does anyone knows why it is so slow processing the tiff files and... how I can make my code "silent" so it does not wait for the OK after the message??
Thanks in advance.
The code:
ADOBE SYSTEMS INCORPORATED
Copyright (C) 1998-2006 Adobe Systems Incorporated
All rights reserved.
NOTICE: Adobe permits you to use, modify, and distribute this file
in accordance with the terms of the Adobe license agreement
accompanying it. If you have received this file from a source other
than Adobe, then your use, modification, or distribution of it
requires the prior written permission of Adobe.
\file PDFBinder.cpp
- Implements a method to convert multiple files into PDFs and bind the PDFs
into one PDF file. The code shows how to use AVConversionToPDFHandler to
convert files to PDF and how to use PDDocInsertPages() to combind PDF files.
// Headers.
#include <stdio.h>
#include <ctype.h>
#ifndef MAC_PLATFORM
#include <direct.h>
#include "PIHeaders.h"
#endif
// Defines ----------
// Define this flag to show AVConversionToPDFEnumHandler info. in log file.
#define SHOW_TOPDF_HANDLER_TYPES
// define this flag to use file type filter
#define USE_FILE_FILTER
Constants/Declarations
// Message display control. Ture: display
ASBool bEcho = true;
// File location. User can change the following filenames.
#if WIN_PLATFORM
const char* STRING_PDFBinderFolder = "C:\\Fairfax\\Adobe\\in";
const char* STRING_PDFOutputFolder = "C:\\Fairfax\\Adobe\\PDFA";
const char* FOLDERSYMBOL="\\";
#endif
#if MAC_PLATFORM
const char* STRING_PDFBinderFolder = "/PDFBinder";
const char* FOLDERSYMBOL="/";
#endif
char* OutputPdfFileName = "PDFBinderOutput.pdf";
char* LogFileName = "PDFProcessLog.txt";
static ASInt32 gNumToPDFExt;
static ASInt32 gNumFromPDFExt;
static AVConversionFromPDFHandler RightHandler;
const int MAX_FILENAME_LENGTH = 256;
char sLogFileName[MAX_FILENAME_LENGTH];
// Filter -----------
// Filter is a list of file types which can be converted to PDF in this program.
// Use a filter may fit user's specific needs and ensure a smooth automation process.
// Of course, the user can turn off the filter in two ways:
// (1) gPDFBinderFileFilter = "";
// (2) comment out //USE_FILE_FILTER
// The filter should be consistent with the Acrobat viewer's menu capability:
// Create PDF from multiple files ...
// Here we put the types which have been tested, but user can expand it.
const char* gPDFBinderFileFilter = "pdf,tif,tiff,PDF,TIF,TIFF";
const int MAX_STRING_LENGTH = 2048;
AVConversionToPDFHandler gHandler;
// functions in this file.
int ConvertAndInsertFileToPDF(ASPathName aspItem, char* aFileName, PDDoc PDFfile);
void BindingFileToPDF(ASPathName aPathName, char* aFilename, ASFileSysItemPropsRec nFileAttrb, PDDoc targetPDdDoc, ASPathName outputPathName, int *ipTotal, int *ipConverted);
ASBool PassPDFBinderFileFilter(char* filename);
int ConvertAndSavePDFInTargetFolder(ASPathName aPathName, char* aFileName, PDDoc PDFfile, ASPathName outputPathName);
char* NewFileName(char *& aFileName);
// callbacks
ACCB1 ASBool ACCB2 MyAVConversionToPDFEnumProc(AVConversionToPDFHandler handler, AVConversionEnumProcData data);
ACCB1 ASBool ACCB2 AVConversionToPDFEnumFindHandler(AVConversionToPDFHandler handler, AVConversionEnumProcData data);
static ACCB1 ASBool ACCB2 myAVConversionFromPDFEnumProc(AVConversionFromPDFHandler handler, AVConversionEnumProcData data);
Implementation
/** This sample implements a method to convert multiple files into PDF
and bind the PDFs into one PDF file .
This sample shows developers how to grammatically implement To-PDF file
converson functionality. Basically, the code uses AVConversionToPDFHandler
to convert files to PDF and PDDocInsertPages()to combine PDF files.
This plug-in is designed to run from a menu item, and by setting bEcho = false
it may be run without any graphics user interface on the screen. Therefore, it
can be executed from other programs such as C IAC, VB IAC, and JavaScript
to meet enterprise workflow needs.
How to run it :
- This sample adds a menu item "PDF Binder" under the Acrobat SDK submenu. Two ways to
execute it: 1) click the menu item to run the program using a fixed file location
hard coded; 2) press the shift key and click the menu item to choose a folder where
files to be converted are located.
- Without folder selection, this original code is to convert and bind files in a
directory C\test\PDFBinder for Win, or a folder MacHD:test:PDFBinder for Mac.
You can copy the test files in the project's testfiles folder to the appropriate location
for testing. You may locate files to be converted in another directory/folder, and
specify the location in the string variable PDFBinderFolder in the code.
- When you have the files to be converted ready in the specified location,
run Acrobat 6 menu Advanced->AcrobatSDK->PDF Binder to start the operation. There are
echo messages informing you of the operation start and end, but you can change and
rebuild the code to turn off the display on screen.
- An output file PDFBinderOutput.pdf in the same location is created
when the program succeeds. A text log file PDFBinderLog.txt in the same
location records the process and results.
- You can set bEch = false in the code to turn off any display on the screen.
This is necessary when you call the menu function from within other programs
of C IAC, VB IAC, JavaScript.
- An optional file filter is used to pre-process the files. The filter only allows
the files with predefined types to be processed. You can change the file type list
as you wish. Using a filter may ensure a smooth automation process, since you can put
only well-tested file types in the filter. To turn off the filter, you can set
gPDFBinderFileFilter = "" or not to define USE_FILE_FILTER
- Note this is a sample only, developers need to make further improvement for
their actual use. For example, you can set up a list of files to use the method for
the conversion and binding. And you can add code to handle special file types.
@see AVConversionConvertToPDFWithHandler
@see AVConversionEnumToPDFConverters
@see ASFileSysDestroyFolderIterator
@see PDDocOpen
@see PDDocClose
@see PDDocInsertPages
@see PDDocCreatePage
@see PDDocDeletePages
@see PDPageRelease
@see ASFileSysCreatePathName
@see ASFileSysFirstFolderItem
@see ASFileSysNextFolderItem
@see ASFileSysGetNameFromPath
@see ASFileSysReleasePath
ACCB1 void ACCB2 PDFBinderCommand(void*)
// if the menu item clicked with Shift key pressed down, go to interactive mode.
// let the user to choose a folder and process all the file in the folder.
ASText dispText = ASTextNew();
char PDFBinderFolder[MAX_STRING_LENGTH];
ASBool shiftKeyIsDown = ((AVSysGetModifiers() & AV_SHIFT) != 0);
if(shiftKeyIsDown) {
AVOpenSaveDialogParamsRec dialogParams;
// Configure the dialog box parameters.
memset (&dialogParams, 0, sizeof (AVOpenSaveDialogParamsRec));
dialogParams.size = sizeof(AVOpenSaveDialogParamsRec);
dialogParams.windowTitle = ASTextFromScriptText("Choose folder with files to bind",kASRomanScript);
dialogParams.flags |= kAVOpenSaveAllowForeignFileSystems;
dialogParams.initialFileSys = ASGetDefaultUnicodeFileSys();
ASPathName thePath;
ASFileSys fileSys;
AVAppBeginModal(NULL);
if(ASBoolToBool(AVAppChooseFolderDialog(&dialogParams, &fileSys, &thePath)) != true){
AVAppEndModal();
//AVAlertNote("Failed to select the folder");
return;
AVAppEndModal();
#ifdef WIN_PLATFORM
ASFileSysDisplayASTextFromPath(ASGetDefaultUnicodeFileSys(), thePath, dispText);
ASHostEncoding bestEnc = ASTextGetBestEncoding(dispText, (ASHostEncoding)PDGetHostEncoding());
strncpy(PDFBinderFolder, ASTextGetEncoded(dispText, bestEnc), MAX_STRING_LENGTH - 1);
#else
ASPlatformPath aspPath;
ASFileSysAcquirePlatformPath(fileSys, thePath, ASAtomFromString("POSIXPath"), &aspPath);
strncpy(PDFBinderFolder, (char *)ASPlatformPathGetPOSIXPathPtr(aspPath), MAX_STRING_LENGTH - 1);
ASFileSysReleasePlatformPath(fileSys, aspPath);
// remove extra path separator
char e = PDFBinderFolder[strlen(PDFBinderFolder)-1];
if(e == ':' || e == '/')
PDFBinderFolder[strlen(PDFBinderFolder)-1]='\0';
dispText = ASTextFromScriptText(PDFBinderFolder, kASEUnicodeScript);
#endif
ASFileSysReleasePath(fileSys, thePath);
// Otherwise, the hard coded file path will be used.
else {
strcpy(PDFBinderFolder, STRING_PDFBinderFolder);
dispText = ASTextFromScriptText(PDFBinderFolder, kASRomanScript);
// instruction message
char strMsg[MAX_STRING_LENGTH] = "";
sprintf(strMsg, "This function will convert and process Tiff and PDF files in the selected directory. ");
strcat(strMsg, " You need to copy your files in C:\\Fairfax\\Adobe\\in directory." );
strcat(strMsg, " Files will be processed into C:\\Fairfax\\Adobe\\PDFA directory." );
strcat(strMsg, " If you are ready, click OK to continue, or click Cancel to quit. " );
strcat(strMsg, " \nNote you can press down Shift key and click the menu item to have a folder selection. " );
strcat(strMsg, " \nNote you can turn off the echo message by setting bEcho = false and rebuild the code. " );
if(ASBoolToBool(bEcho)==true){
ASInt32 choice = AVAlert(ALERT_CAUTION, strMsg, "OK", "Cancel", NULL, true);
if(choice==2) {
return;
// create a new target pdf file with one empty page
PDDoc TargetPDF = PDDocCreate();
ASFixedRect mediaBox = { fixedZero, ASInt32ToFixed(792), ASInt32ToFixed(612), fixedZero };
PDPage emptyPage = PDDocCreatePage (TargetPDF, PDBeforeFirstPage, mediaBox);
PDPageRelease (emptyPage);
// get available headlers and set our file filter
char ValidExt[MAX_STRING_LENGTH];
memset(ValidExt, 0, MAX_STRING_LENGTH);
#ifdef SHOW_TOPDF_HANDLER_TYPES
// enumerate AVConversioToPDF handlers to get all available file
// types which can be converted to PDF.
AVConversionEnumToPDFConverters(MyAVConversionToPDFEnumProc, (AVConversionEnumProcData) ValidExt);
//AVAlertNote("Converters Defined");
//AVAlertNote(ValidExt);
//AVAlertNote(gPDFBinderFileFilter);
#endif
#ifdef USE_FILE_FILTER
// set File filter
strcpy(ValidExt, gPDFBinderFileFilter);
//AVAlertNote(ValidExt);
#endif
// process all files in the directory
int iNumFiles = 0;
int iNumFilesConverted = 0;
char* Done = "Converted";
char* NotDone = " - ";
char fileName[MAX_FILENAME_LENGTH+1];
ASFileSysItemPropsRec props;
ASFolderIterator iter;
ASPathName aspItem = NULL;
memset(&props, 0, sizeof(props));
props.size = sizeof(props);
//AVAlertNote("Props Defined");
ASPathName theFolder = NULL;
ASFileSys fileSys = NULL;
DURING
#ifdef WIN_PLATFORM
fileSys = ASGetDefaultFileSysForPath(ASAtomFromString("ASTextPath"), dispText);
theFolder = ASFileSysCreatePathName (fileSys, ASAtomFromString("ASTextPath"), dispText, 0);
//AVAlertNote("FileSys and Folder Defined");
#else
fileSys = ASGetDefaultFileSysForPath(ASAtomFromString("POSIXPath"), PDFBinderFolder);
theFolder = ASFileSysCreatePathName (fileSys,
ASAtomFromString("POSIXPath"), PDFBinderFolder, 0);
#endif
if (theFolder==NULL) {
//AVAlertNote("Fail to create ASPathName for the selected folder.");
E_RTRN_VOID
// Find first file in current directory
if((iter = ASFileSysFirstFolderItem(fileSys, theFolder, &props, &aspItem))==FALSE) {
//AVAlertNote("This is either an invalid folder or the folder contains no files.");
E_RTRN_VOID
ASFileSysReleasePath(fileSys, theFolder);
//AVAlertNote("Folder Released");
// get filename only
if(ASFileSysGetNameFromPath(fileSys, aspItem, fileName, sizeof(fileName))) {
E_RTRN_VOID
HANDLER
// exception handling
char errorMsg[256];
ASGetErrorString (ASGetExceptionErrorCode(), errorMsg, 256);
if(aspItem!=NULL) ASFileSysReleasePath(fileSys, aspItem);
if(theFolder!=NULL) ASFileSysReleasePath(fileSys, theFolder);
// display an error message.
if(ASBoolToBool(bEcho)==true) {
AVAlertNote (errorMsg);
return;
END_HANDLER
//AVAlertNote(fileName);
// go to binding if it's a valid type of file
if(props.type == kASFileSysFile && PassPDFBinderFileFilter(fileName)) {
char outFileName[] = "";
//strcat(outFileName, STRING_PDFOutputFolder);
//strcat(outFileName, FOLDERSYMBOL);
//strcat(outFileName, fileName);
strcat(outFileName, STRING_PDFOutputFolder);
strcat(outFileName, FOLDERSYMBOL);
strcat(outFileName, fileName);
//AVAlertNote(outFileName);
ASPathName outputFileName = ASFileSysCreatePathName (ASGetDefaultFileSys(), ASAtomFromString("Cstring"), outFileName, 0);
BindingFileToPDF(aspItem, fileName, props, TargetPDF, outputFileName ,&iNumFiles, &iNumFilesConverted);
//AVAlertNote("File Processed");
ASFileSysReleasePath(fileSys, aspItem);
// process all other files
while(ASFileSysNextFolderItem(fileSys, iter, &props, &aspItem)) {
// get filename only
if(ASFileSysGetNameFromPath(fileSys, aspItem, fileName, sizeof(fileName))) {
return;
// go to binding if it's a valid type of file
if(props.type == kASFileSysFile && PassPDFBinderFileFilter(fileName)) {
char outFileName[] = "";
//strcat(outFileName, STRING_PDFOutputFolder);
//strcat(outFileName, FOLDERSYMBOL);
//strcat(outFileName, fileName);
strcat(outFileName, STRING_PDFOutputFolder);
strcat(outFileName, FOLDERSYMBOL);
strcat(outFileName, fileName);
//AVAlertNote(outFileName);
ASPathName outputFileName = ASFileSysCreatePathName (ASGetDefaultFileSys(), ASAtomFromString("Cstring"), outFileName, 0);
BindingFileToPDF(aspItem, fileName, props, TargetPDF, outputFileName, &iNumFiles, &iNumFilesConverted);
//AVAlertNote("File Processed");
ASFileSysReleasePath(fileSys, aspItem);
ASPathName pdfPathName = NULL;
DURING
// close the findfile
ASFileSysDestroyFolderIterator(fileSys, iter);
// save and close the output pdf file
// create path
ASText pathText = ASTextNew();
ASTextCatMany(
pathText,
dispText,
ASTextFromScriptText(FOLDERSYMBOL, kASRomanScript),
ASTextFromScriptText(OutputPdfFileName, kASRomanScript),
NULL);
#ifdef WIN_PLATFORM
ASFileSys fileSys = ASGetDefaultFileSysForPath(ASAtomFromString("ASTextPath"), pathText);
pdfPathName = ASFileSysCreatePathName (fileSys,
ASAtomFromString("ASTextPath"), pathText, 0);
#else
char path[MAX_STRING_LENGTH];
strncpy(path, ASTextGetEncoded(pathText,
ASTextGetBestEncoding(pathText, (ASHostEncoding)PDGetHostEncoding())), MAX_STRING_LENGTH - 1);
ASFileSys fileSys = ASGetDefaultFileSysForPath(ASAtomFromString("POSIXPath"), path);
pdfPathName = ASFileSysCreatePathName (fileSys,
ASAtomFromString("POSIXPath"), path, 0);
#endif
if(pdfPathName==NULL) {
E_RTRN_VOID
// delete the empty page
if(PDDocGetNumPages(TargetPDF)>1) {
PDDocDeletePages (TargetPDF, 0,0,NULL, NULL);
// save
//PDDocSave (TargetPDF, PDSaveFull | PDSaveCollectGarbage | PDSaveLinearized,
// pdfPathName, ASGetDefaultUnicodeFileSys(), NULL, NULL);
PDDocClose (TargetPDF);
//ASFileSysReleasePath(fileSys, pdfPathName);
HANDLER
// exception handling
char errorMsg[256];
ASGetErrorString (ASGetExceptionErrorCode(), errorMsg, 256);
if(pdfPathName!=NULL) ASFileSysReleasePath(fileSys, pdfPathName);
// display an error message.
if(ASBoolToBool(bEcho)==true) {
AVAlertNote (errorMsg);
return;
END_HANDLER
// use this line to show the massage on screen if you need
//if(ASBoolToBool(bEcho)==true) {
AVAlertNote ("Folder Completed. PDF/A Output files generated.");
return;
/* ConvertAndInsertFileToPDF
/** Internal function \n
** Convert a file to PDF, then insert it to target PDF file.
** @param aFileName IN char string, filename.
** @param PDFfile IN/OUT PDDoc of the target PDF file.
** @return 0 if OK, 1 if failed.
int ConvertAndInsertFileToPDF(ASPathName aPathName, char* aFileName, PDDoc PDFfile)
PDDoc tempPDF;
char* Ext;
DURING
// get file extention
Ext = strrchr(aFileName,'.');
if(Ext) {
Ext++;
else {
E_RETURN (1);
// if the file is PDF, open PDDoc
if(strcmp(Ext,"PDF")==0 || strcmp(Ext,"pdf")==0) {
tempPDF = PDDocOpen (aPathName, ASGetDefaultFileSys(), NULL, true);
if(tempPDF==NULL) {
PDDocClose(tempPDF);
E_RETURN (1);
// else convert it to PDF
else
// let it automatically find right handler for the file and do the job.
AVConversionStatus stat = AVConversionConvertToPDF
(kAVConversionAsyncOkay, //kAVConversionNoFlags
aPathName, ASGetDefaultFileSys(), &tempPDF, NULL);
// check if successful
if(stat != kAVConversionSuccess) {
//AVAlertNote("Cannot convert the file.");
E_RETURN (1);
HANDLER
// exception handling
char errorMsg[256];
ASGetErrorString (ASGetExceptionErrorCode(), errorMsg, 256);
// display an error message.
if(ASBoolToBool(bEcho) == true) {
AVAlertNote (errorMsg);
return 1;
END_HANDLER
// insert new PDF into target PDF
DURING
// insert all pages of new pdfc to TargetPDFfile.
PDDocInsertPages(PDFfile, PDLastPage, tempPDF, 0,
PDAllPages, PDInsertAll, NULL, NULL, NULL, NULL);
PDDocClose(tempPDF);
HANDLER
char errorMsg[256];
ASGetErrorString (ASGetExceptionErrorCode(), errorMsg, 256);
if(ASBoolToBool(bEcho)==true) {
AVAlertNote(errorMsg);
END_HANDLER
if(strcmp(Ext,"doc")==0) {
char fname[40];
sprintf(fname,"%s.pdf",aFileName);
remove(fname);
return 0;
/* MyAVConversionToPDFEnumProc
/** Internal callback function \n
** called for every AVConversionToPDFHandler.
** get the valid type (file extention) for the conversion.
** @return true.
ACCB1 ASBool ACCB2 MyAVConversionToPDFEnumProc(AVConversionToPDFHandler handler,
AVConversionEnumProcData data)
ASUns16 numFileExt = handler->convFilter.numFileDescs;
for (int i = 0; i < numFileExt; i++) {
char* ext = handler->convFilter.fileDescs[i].extension;
if(strlen(ext)>0) {
strcat((char*) data, ext);
strcat((char*) data, ",");
return true;
/* this is alternative code to get right conversion handler for a specific file
to be converted. It works with function AVConversionConvertToPDFWithHandler.
It's not used now, but kept for user's reference.
ACCB1 ASBool ACCB2 AVConversionToPDFEnumFindHandler(AVConversionToPDFHandler handler,
AVConversionEnumProcData data)
ASUns16 numFileExt = handler->convFilter.numFileDescs;
for ( int i = 0; i < numFileExt; i++)
char* ext = handler->convFilter.fileDescs[i].extension;
if(strlen(ext)) {
if(!strcmp((char*) data, ext)) {
gHandler = handler;
return false;
return true;
/* BindingFileToPDF
/** Internal callback function for binding process \n
** IN: char* aFilename, ASFileSysItemPropsRec nFileAttrb \n
** PDDoc targetPDdDoc, int *ipTotal, \n
** int *ipConverted, FILE *logfile \n
** OUT: int *ipTotal, int *ipConverted. \n
void BindingFileToPDF(ASPathName aPathName, char* aFilename, ASFileSysItemPropsRec nFileAttrb, PDDoc targetPDdDoc, ASPathName outputPathName, int *ipTotal, int *ipConverted)
// ignore system, hidden files, and our target PDF and log file.
if( nFileAttrb.isHidden
|| (strcmp(aFilename,".")==0) || (strcmp(aFilename,".." )==0)
|| (strcmp(aFilename,OutputPdfFileName)==0) || (strcmp(aFilename,LogFileName)==0)) {
return;
(*ipTotal)++;
char msg[MAX_STRING_LENGTH] = "";
char* Done = "Converted";
char* NotDone = " - ";
// try to convert and insert it to target PDF file.
// rc would be 0 for success, otherwise 1.
int rc = ConvertAndSavePDFInTargetFolder(aPathName, aFilename, targetPDdDoc, outputPathName);
// if converted
if(rc==0) {
(*ipConverted)++;
/* PassPDFBinderFileFilter
/** Internal callback function for binding process
** @return true if the IN aFilename is a valid file for PDF conversion,
** otherwise false.
ASBool PassPDFBinderFileFilter(char* aFilename)
#ifdef USE_FILE_FILTER
// if the filter is empty, any file will pass.
if(strlen(gPDFBinderFileFilter)==0)
return true;
char* Ext = strrchr(aFilename,'.');
if(Ext!=NULL) {
Ext++;
if(strstr(gPDFBinderFileFilter, Ext)) {
return true;
return false;
#else
// not use filter, any file will pass.
return true;
#endif
/* ConvertAndInsertFileToPDF
/** Internal function \n
** Convert a file to PDF, then insert it to target PDF file.
** @param aFileName IN char string, filename.
** @param PDFfile IN/OUT PDDoc of the target PDF file.
** @return 0 if OK, 1 if failed.
int ConvertAndSavePDFInTargetFolder(ASPathName aPathName, char* aFileName, PDDoc PDFfile, ASPathName outputPathName)
PDDoc tempPDF;
char* Ext;
DURING
// get file extention
Ext = strrchr(aFileName,'.');
if(Ext) {
Ext++;
else {
E_RETURN (1);
// if the file is PDF, open PDDoc
if(strcmp(Ext,"PDF")==0 || strcmp(Ext,"pdf")==0) {
tempPDF = PDDocOpen (aPathName, ASGetDefaultFileSys(), NULL, true);
if(tempPDF==NULL) {
PDDocClose(tempPDF);
E_RETURN (1);
// else convert it to PDF
else
// let it automatically find right handler for the file and do the job.
AVConversionStatus stat = AVConversionConvertToPDF
(kAVConversionAsyncOkay, //kAVConversionNoFlags
aPathName, ASGetDefaultFileSys(), &tempPDF, NULL);
// check if successful
if(stat != kAVConversionSuccess) {
//AVAlertNote("Cannot convert the file.");
E_RETURN (1);
else {
//change Extension
ASText asTmp = ASTextNew();
ASFileSysDisplayASTextFromPath(ASGetDefaultUnicodeFileSys(), outputPathName, asTmp);
//AVAlertNote(ASTextGetScriptText(asTmp, kASRomanScript));
if(strcmp(Ext,"TIF")==0 || strcmp(Ext,"tif")==0){
ASTextReplace(asTmp, ASTextFromScriptText(".tif", kASRomanScript), ASTextFromScriptText(".pdf", kASRomanScript));
} else {
ASTextReplace(asTmp, ASTextFromScriptText(".tiff", kASRomanScript), ASTextFromScriptText(".pdf", kASRomanScript));
//AVAlertNote(ASTextGetScriptText(asTmp, kASRomanScript));
outputPathName = ASFileSysCreatePathName (ASGetDefaultUnicodeFileSys(), ASAtomFromString("ASTextPath"), asTmp, 0);
HANDLER
// exception handling
char errorMsg[256];
ASGetErrorString (ASGetExceptionErrorCode(), errorMsg, 256);
// display an error message.
if(ASBoolToBool(bEcho) == true) {
AVAlertNote (errorMsg);
return 1;
END_HANDLER
// Run OCR and Save new PDF into target PDF
DURING
// OCR
ASAtom cmdName;
AVCommand cmd;
cmdName=ASAtomFromString("PaperCapture");
cmd=AVCommandNew(cmdName);
ASCab config = ASCabNew();
ASCabPutInt (config, "UIPolicy", kAVCommandUISilent); //hide the interface
if (kAVCommandReady == AVCommandSetConfig (cmd, config)) {
//AVAlertNote("Config Ready");
ASCab inputs = ASCabNew();
ASCabPutPointer (inputs, kAVCommandKeyPDDoc, PDDoc, tempPDF, NULL);
if (kAVCommandReady == AVCommandSetInputs (cmd, inputs)) {
//AVAlertNote("Input Ready");
ASCabDestroy (inputs);
AVCommandStatus status = AVCommandExecute(cmd);
//switch (status) {
// case kAVCommandReady :
// AVAlertNote("Not working, but ready to work.");
// break;
// case kAVCommandWorking :
// AVAlertNote("Still working");
// break;
// case kAVCommandDone :
// AVAlertNote("Done working");
// break;
// case kAVCommandInError :
// AVAlertNote("In Error");
// break;
// case kAVCommandNotExecuted :
// AVAlertNote("Command not executed due to lack of objects on which the command to be executed");
// break;
AVCommandDestroy(cmd);
//Save
//PDDocSave (tempPDF, PDSaveFull | PDSaveCollectGarbage | PDSaveLinearized, outputPathName, ASGetDefaultUnicodeFileSys(), NULL, NULL);
//ClosePDF
//PDDocClose(tempPDF);
//Convert to PDF/A Compliance
//Select the right handler
AVConversionEnumFromPDFConverters(myAVConversionFromPDFEnumProc, NULL);
// do conversion
AVConversionStatus stat = AVConversionConvertFromPDFWithHandler(RightHandler, NULL, kAVConversionAsyncOkay, tempPDF, outputPathName, ASGetDefaultFileSys(), NULL);
// check the returned status and show message
//if (stat == kAVConversionSuccess)
// AVAlertNote( "The PDF/A file was saved in output folder." );
//else if (stat == kAVConversionFailed)
// AVAlertNote( "The PDF/A conversion failed." );
//else if (stat == kAVConversionSuccessAsync)
// AVAlertNote( "The conversion will continue asynchronously." );
//else if (stat == kAVConversionCancelled)
// AVAlertNote( "The conversion was cancelled." );
//Save
//PDDocSave (tempPDF, PDSaveFull | PDSaveCollectGarbage | PDSaveLinearized, outputPathName, ASGetDefaultUnicodeFileSys(), NULL, NULL);
//ClosePDF
PDDocClose(tempPDF);
ASFileSysReleasePath(ASGetDefaultFileSys(), outputPathName);
HANDLER
char errorMsg[256];
ASGetErrorString (ASGetExceptionErrorCode(), errorMsg, 256);
if(ASBoolToBool(bEcho)==true) {
AVAlertNote(errorMsg);
END_HANDLER
if(strcmp(Ext,"doc")==0) {
char fname[40];
sprintf(fname,"%s.pdf",aFileName);
remove(fname);
return 0;
//Select the appropiate handler for the PDF/A conversion
static ACCB1 ASBool ACCB2 myAVConversionFromPDFEnumProc(AVConversionFromPDFHandler handler, AVConversionEnumProcData data)
AVFileFilterRec filter = handler->convFilter;
ASUns16 numFileExt = filter.numFileDescs;
char *kUniqueID = handler->uniqueID;
// go through the conversion handlers to find a handler for PDF extension files and the unique key matches the PDF/A one.
for (ASInt32 i = 0; i < numFileExt; i++)
if (strlen(handler->convFilter.fileDescs[i].extension)>0)
// found it, fill in the handler and return false to stop going on.
if (!strcmp(handler->convFilter.fileDescs[i].extension, "pdf") && !strcmp(kUniqueID,"com.callas.preflight.pdfa")) {
RightHandler = handler;
return false ;
return true;There are some options for various APIs to run "kinda silent" - but again, Acrobat is designed for INTERACTIVE use…so "completely silent" isn't really an option.
As for speed – you'd need to be MUCH MORE specific about where your slow downs are. Have you profiled?
From: Adobe Forums <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
Date: Mon, 12 Dec 2011 07:39:08 -0800
To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
Subject: Slow processing and getting opening errors/warnings
Re: Slow processing and getting opening errors/warnings
created by FFX-ER<http://forums.adobe.com/people/FFX-ER> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4079175#4079175 -
Trouble with a PDF opening correctly from a link
When I click the link to a certain pdf on a web page, a new window opens but I get the error message "The file is damaged and could not be repaired." I click OK, then close that window. I go back to the link, click on it again, and sometimes the pdf opens fine at that time, and sometimes it takes one more time for it to open correctly. Other people have opened the pdf the first time with no trouble at all. I can open other pdf links on the same web page without a problem. Any thoughts?
Hi Kim,
It seems the document had Reader extended rights. Those form are created using different feature and when a person save the document with Data those rights will not remain intact with the form.
Means you cant make any changes with the form.
Regards,
Ajlan Huda. -
Adobe Reader will not open, error O:104
Adobe Reader will not open, error O:104
That looks like a perfectly good PDF, but since it's trying to open in Microsoft Word, that means your file association for .pdf files is incorrect. You should change it to point to Adobe Reader instead of Word.
If you are on Windows, see http://windows.microsoft.com/en-us/windows/change-file-open-program#1TC=windows-7 -
Just upgraded to 10.9 & Preview won't open Error Message -10810
Just upgraded to 10.9 & Preview won't open Error Message -10810
I went into the file, "Get Info" and opened the .pdf in the Safari browser, but Preview won't work.
Otherwise, 10.9 is great. I am really enjoying Mavericks.
Thanks everybody!Contact this address below and request a new download, and that the one you have does not open or it crash whe doing so.
They open up my account and allowed me to reinstall.
My redowndloaded Mainstage is now working on my MacB Pro, and four [4] externals, with out any problems.
Hope this will help others, who are having a problem with Mainstage v 2.2.1
See below;
iTunes Store <[email protected]>
Maybe you are looking for
-
How big of a power supply should I get? / ram question
Here's what I have K7T266 Pro2-RU motherboard Radeon 9800 pro 2 40gb hd's raided 1 20gb hd cd burner dvd drive Audiophile sound card (forgot the model #) and i'll soon have either 512 or 1024 of kingston hyper x pc2700 ram right now my power supply i
-
Modify amount of space after line return
hi I'm creating a html email (using a table and a new inline style each time i insert text, as advised) However, this query may apply to any form of html produced in dreamweaver: Can I set and modify the amount of space inserted after a line return?
-
6.0 upgrade..still seeing left side menu
I have just upgraded a 4.x install to 6.0 and am still seeing the left nav sidebar. In a new install this, of course, is replaced by the second layer of tabs. is this a settting I need to change in a config file? Or does the upgrade somehow keep the
-
IPod 5G Movie Length Limit?
Greetings, I had earlier ripped The Lord of the Rings: The Return of the King (extended edition) onto my iPod 5G as two separate MP4 files (since it came on two DVDs). However, I didn't like having one movie broken up as two files. So I converted the
-
HT1595 Apple tv3 can't find wireless network
Apple tv3 can't find wireless network