Reading an external file

I'm new to Acrobat scripting though I've done some for JavaScript for InDesign. It seems very different and I'm having difficulty wrapping my head around it.
I need to open and read an external text file that contains names of PDF files. Then, I need to merge all those PDF file into a single new PDF. First, is this possible?
Second, can anyone point me to a source for some sample scripts that will help get me started?
Thanks.

The following code is one way to satisfy your requirements.
A supporting document may be found at
  http://www.aespen.ca/AEnswers/czigany-dec062011.pdf.
The supporting document contains a step-by-step instruction on what you need to do to use the anonymous function below.
I do not know how to upload a PDF file to this forum. This is why I am posting the supporting document to a different site.
I hope this helps.
Regards,
John
/***** Start of code *****/
(function(parms) {
  var path = parms.path;
  var width = 612;
  if (parms.width) width = parms.width;
  var height = 792;
  if (parms.height) height = parms.height;
  var mFile = "mergedFiles.pdf";
  if (parms.mFile) mFile = parms.mFile;
  var fFile = parms.fFile;
  if (parms.fFile) fFile = parms.fFile;
  var doc = app.newDoc({ nWidth: width, nHeight: height });
  var dobjName = "temp$" + (new Date().valueOf());
  doc.saveAs({ cPath: path + mFile });
  doc.importDataObject({ cName: dobjName, cDIPath: path + fFile });
  var rstr = doc.getDataObjectContents(dobjName);
  var str = util.stringFromStream(rstr);
  var fns = eval(str);
  var i;
  for (i in fns) {
  doc.insertPages({ nPage: doc.numPages-1, cPath: fns[i] });
  doc.deletePages({ nStart: 0, nEnd: 0 });
  doc.removeDataObject(dobjName);
  path: "/E/Exercises/czigany/Dec062011/",
  mFile: "mergedFiles.pdf",
  pageWidth: 612,
  pageHeight: 792,
  fFile: "Filenames.txt"
  * Author: John Chionglo
  * email: [email protected]
  * Date: December 2011
  * To use this anonymous function, you must run it as a
  * console event in Acrobat 9 Pro.
  * Anonymous Function Parameters:
  * path
  * A valid directory where the user running the script
  * will save the merged file.
  * mFile
  * The name of the merged file.
  * Default: mergedFiles.pdf.
  * pageWidth
  * The width of a page in pixels.
  * Default: 612
  * pageHeight
  * The height of a page in pixels.
  * Default: 792
  * fFile
  * The file which contains the file names of documents
  * to be merged. File format: array in JSON format.
  * For example,
  * [ "Doc1.pdf", "Doc2.pdf", "Doc3.pdf" ]
  * Summary of Acrobat/JavaScript API used in the code:
  * app.newDoc, doc.saveAs, doc.importDataObject,
  * doc.getDataObjectContents, util.stringFromStream,
  * doc.insertPages, doc.deletePages, doc.removeDataObject
  * References:
  * Adobe Systems Incorporated. (2010). Adobe Acrobat 9 Pro
  * [Version 9.4.6, software]. San Jose, CA: Adobe Systems
  * Incorporated.
  * Adobe Systems Incorporated. (2007). Adobe Acrobat SDK 8.1
  * JavaScript for Acrobat API Reference for Microsoft
  * Windows and Mac OS. Retrieved on Aug. 3, 2011 from
  * http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf.
  * Flanagan, D. (2006). JavaScript: The Definitive Guide.
  * Sebastopol, CA: O'Reilly Media Inc.
  /**** end of code *****/

Similar Messages

  • How to release and read another external file

    My vi is set to read an external file (a previously collected force plate signal), then perform a string of analyses on it and finally save the analytical output. Currently, "Read from measurement file" is outside the while loop containing all of my analysis.
    Without completely restarting the vi, I would like to be able to release the file and load another.  How might I do this?  
    Thanks!

    I would do several things to clean up the block diagram.
    whenever you have multiple outputs that are related to each other (PF, F100, F150, F200, F250, etc...) or all of the RFDs and Impulses, you can bundle them together and then display them with one big cluster, or as an array, if that makes sense.  This will reduce your total number of outputs and maybe improve organizaiton.
    If you have a seqeunce of functions that go together, you can combine them into a SubVI to save blockdiagram space and making things more logical.
    If you have several places where the same sort of function is being done, (for example, you have Extract-Statistics-Formula several times and Extract-Integral-Statisics several times) you can make this into a sub-VI and then loop through it.  That way you can execute the function multiple times (with slight changes on each loop), but you only have to have the code written once. It also makes it much easier to improve the code because you only have to make one change instead of four. 
    The attached VI shows two ways of doing something.  On the left is your code, which is four sets of the same thing.  On the right, I've taken this code and put it into a loop so it does the same thing four times.
    Attachments:
    Simplified Code.vi ‏896 KB

  • How to open and read an external file in Dashboard widget?

    I am new to Dashboard widgets and also Javascript. I have written a widget that needs to open and read a file on the local file system. I have searched a lot and have not found any documentation or reference on the internet as to how to do this.
    I know it can be done since there is a checkbox in the widget attributes that says "Allow External File Access".
    can anyone help me out here?
    Thanks

    You need to define the AllowFileAccessOutsideOfWidget key to Yes.
    You also need to define the AllowFullAccess key.
    You may also need to define the AllowSystem key (to Yes of course).
    Mihalis.
    PS. If you cannot find any other documentation please check http://widgetbook.blogspot.com.

  • Read/write external file  from remote location

    hi all,
    due to more concern about storage, we are storing some pdf/doc/jpg files in remote location, we need to write/read that files without storing in the database,
    the files would be external file. is there any procedure to do so,
    thanks in advance
    pa1

    sachinpawan wrote:
    hi all,
    due to more concern about storage, we are storing some pdf/doc/jpg files in remote location, we need to write/read that files without storing in the database,
    the files would be external file. is there any procedure to do so,
    thanks in advance
    pa1The database can only deal with files that reside on disk that is mounted to the OS that is hosting the database.

  • How to Read a External File in a livecycle form (using javascript)

    Hi Everyone,
       First of all, i would like to thank you in advanced for your help !!
       I have a situation were i need to load some values into some fields inside a dinamic pdf that was created in livecycle, what can i do so far ?
       I can load the fields with some values using a livecycle event and javascript, the values come from some functions that i have created but ... are fixed of course...
    What i need is to load up the values from the outside world.... from a external file (text or xml) or a webservice... i have some several experiences but nothing has worked so far...
    Can anyone publish a sample code in javascript to load up a file (text or xml) that works inside livecycle ??
    Thanks in advanced.
    Miguel Angelo (migas)

    Hi, Paul,
      Thanks i have looked inside the link (dam big ) but i'm still kind of lost, can anyone please publish a code example ?
    Miguel

  • Problem to read an external file in a web application

    Hello everybody.
    I'd like to know a method for reading a file (how I may connect to it?) This file is in a directory is in an external computer. I don't want to use a client/server application. I think that I must to use JNDI but I'm not sure. I think so becouse when I connect my application to external LDAP server, I use JNDI.
    I'm using Tomcat.
    Thanks a lot.
    Sorry for my English.
    I hope in your solution.
    Alessandro from Italy

    A quick Google found this:
    try
    Runtime rt = Runtime.getRuntime() ;
    Process p = rt.exec("Program.exe") ;
    InputStream in = p.getInputStream() ;
    OutputStream out = p.getOutputStream ();
    InputSream err = p,getErrorStram() ;
    //do whatever you want
    //some more code
    p.destroy() ;
    }catch(Exception exc){/*handle exception*/}Then of course you should realize that the path to the exe file must be in relation to the server.

  • Reading an external text file in WAR file

    Greetings,
    I have a question. I have an web application that writes a text message and 0's and 1's based on checkboxes. Then I have a JSP that reads this text file and prints the message and enables/disables links based on the 1's and 0's. I don't have any problems with this when testing from localhost, but when I deploy to a server the application isn't reading the file. The text file and WAR file are in the same folder, same directory. I've tried using both relative and absolute paths to read the file, but to no avail. Is there an easy way to read an external file from a WAR file or is there an easier solution. Thanks
    Nick

    You should not try to force your text file to live in the same directory as the WAR file. Instead, you should remove that kind of dependency and instead be using something like System.getProperty("java.io.tmpdir") to use the temporary directory to create and delete these files.
    Edit: I also bet you don't even need to create & read a file here. You could probably store the information in one of the contexts of the web app, such as in a Session. I'll assume you know what that means.
    By creating a file, you are also running the risk of multiple threads (simultaneous users) vying for the same file name, thus walking on each other's data.
    Message was edited by:
    warnerja

  • Load external file as a blob?

    Hi!
    The target is: to check TGA file's color depth.
    How? - to load file as a blob and to read byte number 16.
    Similar to get information about compression etc...
    So, the question is - is it possible to read an external file by javascript in AE?
    Thank you in advance!

    Pg. 47 of the JavaScript Tools Guide CC.pdf talks about the File object. My guess is that you may need something more than just ExtendScript to dive that far into a file as I didn't see any obvious direct answer in the guide.

  • Reading the Blob and writing it to an external file in an xml tree format

    Hi,
    We have a table by name clarity_response_log and content of the column(Response_file) is BLOB and we have xml file or xml content in that column. Most probably the column or table may be having more than 5 records and hence we need to read the corresponding blob content and write to an external file.
    CREATE TABLE CLARITY_RESPONSE_LOG
      REQUEST_CODE   NUMBER,
      RESPONSE_FILE  BLOB,
      DATE_CRATED    DATE                           NOT NULL,
      CREATED_BY     NUMBER                         NOT NULL,
      UPDATED_BY     NUMBER                         DEFAULT 1,
      DATE_UPDATED   VARCHAR2(20 BYTE)              DEFAULT SYSDATE
    )The xml content in the insert statement is very small because of some reason and cannot be made public and indeed we have a very big xml file stored in the BLOB column or Response_File column
    Insert into CLARITY_RESPONSE_LOG
       (REQUEST_CODE, RESPONSE_FILE, DATE_CRATED, CREATED_BY, UPDATED_BY, DATE_UPDATED)
    Values
       (5, '<?xml version="1.0" encoding="UTF-8"?><xml-response><phone-number>1212121212</tracking-number></xml-response>', TO_DATE('09/23/2010 09:01:34', 'MM/DD/YYYY HH24:MI:SS'), 1, 1, '23-SEP-10');
    Insert into CLARITY_RESPONSE_LOG
       (REQUEST_CODE, RESPONSE_FILE, DATE_CRATED, CREATED_BY, UPDATED_BY, DATE_UPDATED)
    Values
       (6, '<?xml version="1.0" encoding="UTF-8"?><xml-response><phone-number>1212121212</tracking-number></xml-response>', TO_DATE('09/23/2010 09:01:34', 'MM/DD/YYYY HH24:MI:SS'), 1, 1, '23-SEP-10');
    Insert into CLARITY_RESPONSE_LOG
       (REQUEST_CODE, RESPONSE_FILE, DATE_CRATED, CREATED_BY, UPDATED_BY, DATE_UPDATED)
    Values
       (7, '<?xml version="1.0" encoding="UTF-8"?><xml-response><phone-number>1212121212</tracking-number></xml-response>', TO_DATE('09/23/2010 09:01:34', 'MM/DD/YYYY HH24:MI:SS'), 1, 1, '23-SEP-10');
    Insert into CLARITY_RESPONSE_LOG
       (REQUEST_CODE, RESPONSE_FILE, DATE_CRATED, CREATED_BY, UPDATED_BY, DATE_UPDATED)
    Values
       (8, '<?xml version="1.0" encoding="UTF-8"?><xml-response><phone-number>1212121212</tracking-number></xml-response>', TO_DATE('09/23/2010 09:01:34', 'MM/DD/YYYY HH24:MI:SS'), 1, 1, '23-SEP-10');
    Insert into CLARITY_RESPONSE_LOG
       (REQUEST_CODE, RESPONSE_FILE, DATE_CRATED, CREATED_BY, UPDATED_BY, DATE_UPDATED)
    Values
       (9, '<?xml version="1.0" encoding="UTF-8"?><xml-response><phone-number>1212121212</tracking-number></xml-response>', TO_DATE('09/23/2010 09:01:34', 'MM/DD/YYYY HH24:MI:SS'), 1, 1, '23-SEP-10');THe corresponding proc for reading the data and writing the data to an external file goes something like this
    SET serveroutput ON
    DECLARE
       vstart     NUMBER             := 1;
       bytelen    NUMBER             := 32000;
       len        NUMBER;
       my_vr      RAW (32000);
       x          NUMBER;
       l_output   UTL_FILE.FILE_TYPE;
    BEGIN
    -- define output directory
       l_output :=
          UTL_FILE.FOPEN ('CWFSTORE_RESPONCE_XML', 'extract500.txt', 'wb', 32760);
       vstart := 1;
       bytelen := 32000;
    ---get the Blob locator
       FOR rec IN (SELECT response_file vblob
                     FROM clarity_response_log
                    WHERE TRUNC (date_crated) = TRUNC (SYSDATE - 1))
       LOOP
    --get length of the blob
    len := DBMS_LOB.getlength (rec.vblob);
          DBMS_OUTPUT.PUT_LINE (len);
          x := len;
    ---- If small enough for a single write
    IF len < 32760
          THEN
             UTL_FILE.put_raw (l_output, rec.vblob);
             UTL_FILE.FFLUSH (l_output);
          ELSE  
    -------- write in pieces
             vstart := 1;
             WHILE vstart < len AND bytelen > 0
             LOOP
                DBMS_LOB.READ (rec.vblob, bytelen, vstart, my_vr);
                UTL_FILE.put_raw (l_output, my_vr);
                UTL_FILE.FFLUSH (l_output);
    ---------------- set the start position for the next cut
                vstart := vstart + bytelen;
    ---------- set the end position if less than 32000 bytes
                x := x - bytelen;
                IF x < 32000
                THEN
                   bytelen := x;
                END IF;
                UTL_FILE.NEW_LINE (l_output);
             END LOOP;
    ----------------- --- UTL_FILE.NEW_LINE(l_output);
          END IF;
       END LOOP;
       UTL_FILE.FCLOSE (l_output);
    END;The above code works well and all the records or xml contents are being written simultaneously adjacent to each other but we each records must be written to a new line or there must be a line gap or a blank line between any two records
    the code which I get is as follow all all xml data comes on a single line
    <?xml version="1.0" encoding="ISO-8859-1"?><emp><empno>7369</empno><ename>James</ename><job>Manager</job><salary>1000</salary></emp><?xml version="1.0" encoding="ISO-8859-1"?><emp><empno>7370</empno><ename>charles</ename><job>President</job><salary>500</salary></emp>But the code written to an external file has to be something like this.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <emp>
      <empno>7369</empno>
      <ename>James</ename>
      <job>Manager</job>
      <salary>1000</salary>
    </emp>
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <emp>
    <empno>7370</empno>
    <ename>charles</ename>
    <job>President</job>
    <salary>500</salary>
    </emp>Please advice

    What was wrong with the previous answers given on your other thread:
    Export Blob data to text file(-29285-ORA-29285: file write error)
    If there's a continuing issue, stay with the same thread, don't just ask the same question again and again, it's really Pi**es people off and causes confusion as not everyone will be familiar with what answers you've already had. You're just wasting people's time by doing that.
    As already mentioned before, convert your BLOB to a CLOB and then to XMLTYPE where it can be treated as XML and written out to file in a variety of ways including the way I showed you on the other thread.
    You really seem to be struggling to get the worst possible way to work.

  • My Macbook Pro can't detect or read my CDFS file system external HDD

    My Macbook Pro can't detect or read my CDFS file system external HDD

    Open Disk Utility and see if the USB drives show in there. If they don't then it is a USB port or bus problem. If they do show in disk utility are they formatted in either Mac extended or a Windows format?

  • Can I change the file path that itunes reads my music files from? 65000 files trying to be transferrd from external to internal HD. I dont want itunes to manage my collection, just read it. thanks

    Can I change the file path that itunes reads my music files from?
    I have about 65000 music files that i have transferrd from my external to a new laptop internal HD.
    I have organised the folders myself as I use a PC and do not want itunes to organise the folders because when I'm searching through music on windows it is sorted out by artists/albums with 'the...(eg  The Beatles)' under 'T' instead of 'B'.
    Long story short.... Is there any way that I can keep my itunes library as it is on the external HD and copy it to the new laptops C drive, keep all the info (playlists etc) and still have the same folder structure as on the external HD?
    Or, is there any way of making windows sort things in alphabetical order like it is in itunes (eliminating the 'the' issue)?

    The files that weren't inside the media folder on the original machine need to be copied over to exactly the same paths as they had on the source machine. See this thread for an ongoing discussion of a similar problem. See also this post on migrating the iTunes library.
    tt2

  • Read from external source file in weblogic

    Hi,
    I am using Weblogic Server 10.3 in my project.
    In one of my modules , i have a requirement where I have to read the contents of a file from an external location.[ex: D:\Test\Sample.xml ].
    How to i configure this path in weblogic , so that I can read the content in my java source file.
    Please advice.
    Regards,
    Praveen

    only part i replied on was the part of how to read a file
    but i think in your case you could do the next
    use the sync file adapter to read in the file during your process
    based on this content you set a variable "myOutputDirectory"
    then create a file adapter (write) which will store the file on file system
    http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/adptr_file.htm#CIACICFD
    4.3.2.2.5 Specifying a Dynamic Outbound File Name
    and use that (jca.file.Directory) property to store the file either on the archive location or the delete location

  • How to read an external XML file in a indesign Plugin?

    Hi All,
    Can you please guide in reading an external XML file in a indesign Plugin in MAC system. I am an windows user.We are using this file for reading some inputs.
    Thanks,
    Daniel

    Hello Daniel,
    I am uncertain about the actual question. If you are developing a plug-in or otherwise interfacing with the guts of ID, I suggest asking the question in the SDK forum:
    InDesign SDK Forum
    Otherwise, what is it you are wanting to know concerning importing XML into InDesign?
    Mike

  • Read/Open a file in SAP DMS from an external system

    Hello Sap Gurus,
    I want to read/open a file in SAP DMS from an external system . External system is basically a non-sap system.
    Can this be achieved through an RFC..
    Does anyone know of any BAPI's/FM's that can be called from an external system (non-sap system) through RFC which will open a document which is stored in SAP DMS.
    Regards,
    Madan Shetty.

    Hi Madan,
    If you want to view documents from an external system, there are many ways of achieving this.
    It depends on the solution that you are approaching.
    Few methods that I have come across are, OData services, Custom RFC Function  Modules, to retrieve document attachments.
    FTP is also a possible solution.
    Please let us know your exact requirement.
    Regards,
    Tamilnesan G

  • Dynamic Internal Table for reading data from external file

    Hello All,
    The task was to create a internal table with dynamic columns,
    Actually this is my first task in the WebAS 6.20, my program is based on input file provided by user with certain effort. this file can have different effort for a one yr to five year frame..
    I needed to read the raw data from file, based on months create a internal table to hold the data, after this i need to validate the data...
    I have browsed thru dynamic internal table topic, but couldn't find any dynamic appending structure, the dynamic structure would contains 12 month fileds.
    can any one help me in getting my task completed..
    Thanks
    Kumar

    Hi,
    I see that you posted the same question a couple of days ago at Dynamic Internal Table for reading data from external file Didn't Charles's response address your problem?
    Regards

Maybe you are looking for