Scripting inDesign: Generate a PDF file

Hello

I have a bug with my script. Everything is OK:

The script imports the xml file into my Indesign file and the new generated file (.indd) is correct...

But this script generates PDF files with only 2 pages.

You know the correct code to generate large PDF files?

This is my script:

var myTemplate is File.openDialog ("select a template");.

myFolder var is Folder.selectDialog ("choose a folder to treat");.


myDocs var = myFolder.getFiles ("*.xml");

for (i = 0; i < myDocs.length; i ++) {}

Open the template:

var newDoc = app.open (myTemplate);


Import XML:

var myXMLImportPreferences = newDoc.xmlImportPreferences;

myXMLImportPreferences.allowTransform = false;

myXMLImportPreferences.createLinkToXML = false;

myXMLImportPreferences.ignoreUnmatchedIncoming = false;

myXMLImportPreferences.importCALSTables = false;

myXMLImportPreferences.importTextIntoTables = false;

myXMLImportPreferences.importToSelected = false;

myXMLImportPreferences.removeUnmatchedExisting = true;

myXMLImportPreferences.ignoreWhitespace = true;

myXMLImportPreferences.repeatTextElements = true;

newDoc.importXML (myDocs [i]);

Add the additional document-specific treatment steps here


Save:

var NouveauNomFichier = myFolder.absoluteURI + ' / ' +. [i] myDocs name.replace (/ xml /, 'pdf');

app.activeDocument.exportFile (ExportFormat.pdfType, File (newFileName), false);


var NouveauNomFichier = myFolder.absoluteURI + ' / ' +. [i] myDocs name.replace (/ xml /, "indd");

newDoc.save (new file (newFileName));

app.activeDocument.close ();

}

Thank you

Hey!

Try to add before you export it in PDF format:

app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES;

--

tomaxxi

http://indisnip.WordPress.com/

Tags: InDesign

Similar Questions

  • need me an Adobe license to generate unique PDF files using iText 2.17?

    Hello


    We are building a web business application using iText v2.1.7 (Apache 2.0 under a free license) which generates unique PDF files, containing a dozen of text to fill in fields. Each PDF files are different by using multiple text labels, ensuring uniqueness.

    Each instance of the PDF file is sent to a single recipient, the recipient fills text fields, print the document and signs the document.

    Subsequently, the paper is placed in a workflow outside of our company. This workflow produces a unique XML file that is sent to our internal workflow.

    My question is: do we need to license Adobe Acrobat Reader, and that is the license appropriate for us?


    Thank you!

    You do not use any Adobe technology. Adobe do not claim that all rights to the PDF generators that do not use their technology - PDF is a public ISO standard.

    In fact, the use of Acrobat Reader and Acrobat is prohibited on a web server, but fortunately it does not apply because you don't need.

    Your end users will need Acrobat or Acrobat Reader or another PDF reader. But the licensing of your software to end users is their own interest (unless you manage their business, in which case you may need a license for the redistribution of the reader).

    However, although it is off topic, I can't really recommend basing a business on the old iText 2 just application because it's free. See Sales FAQ | iText Software, "WHY I shouldn't USE ITEXT 2.X (OR ITEXTSHARP 4.X)?". It could be the weak link in your solution, and you would have yourself locked out of commercial support.

  • Can reports character mode - I generate a PDF file?

    Hi, I work with Forms 6i character mode. Forms and reports are the Unix server.

    Now all forms call reports like this:


    run_product (REPORTS, lower (lv_reporte), SYNCHRONOUS, BATCH, filesystem, list_id, null);

    HOST ('sh print' | lv_salida |) » '|| TO_CHAR (ln_cantidad) | » '|| lv_ccola, NO_SCREEN);

    "Sh print" is a WORK, it has redirect the output to the printer.

    I need character mode, run the report in PDF format, ¿It may be possible?

    I don't want to create the read, I want to run the report and generate a PDF file.

    Thank you.

    Kind regards.

    I can't generate a PDF file, but if the form call the report in "BITMAP" mode and the character not without archive.prt, i ' ts generates a PostScript in UNIX.

    Later, I turn the Ps to PDF with ghostscript PS2PDF.

  • When I export my file to generate a .pdf file, the text box is literally a box around it! How to make this line disappear?

    When I export my file to generate a .pdf file, the text box is literally a box around it! How to make this line disappear?

    Looks like you have a line on it. Select the image and the race set to None.

  • Automatically generate a PDF file without clicking on the link and close the session

    Is there a way to change the configuration of the interview to automatically generate a PDF file instead of having to click on the link "click here for the pdf" at the end of an interview?

    Also after the interview and the generated PDF, can the session automatically close?

    Preferably, I would like to do this without JAVA.

    You can write a JavaScript code piece that going to click on the link of generation of document for you. With respect to the close of the interview, it is the same, use JavaScript to call the bond in the narrow section and then eventually to automatically submit the form of confirmation.

  • Generate blank PDF file

    Hello

    I installed the 2.0.0 Data Modeler and diagram of relational model generated using import option.
    When I try to 'print the diagram to PDF file', there generate blank PDF file, but it generates to the image file.
    Kindly help me to generate relational diagram of modal in PDF format.

    Thank you
    Jen

    Hi Jen,

    Why do you not use Data Modeler 2.0 - there is Data Modeler 3.0 and 3.1 ai2 is available. I'll recommend going with Data Modeler 3.1 ai2.

    Philippe

  • Need a script for InDesing culture pdf files

    Hello

    I have over 200 pages pdf file. I need to place pages in InDesign, jump the 4 sides about 20mm in InDesign. I did place using the script. I need to crop all pages, including at - it a script for the same... ?

    Thanks in advance.

    Hello

    You can try with the code below:

    var myDoc = app.activeDocument;
    var myGraphics = myDoc.allGraphics;
    for (var a = 0; a
    

    But make sure that your rule should be in mm.

    This is Zanelli script to put pdf in Indesign.

    Shonky

  • Generate a PDF file with sections invisible made visible through the code

    I have a poll with several which are either visible or hidden based on the selection of the user to a yes / no radio no button group.  The user can then present the investigation by e-mail or print the survey.  If the user prints the investigation before being submitted, all invisible made visible that user input are included in the printed copy; However, when the pdf file is generated to be attached to the presentation of the e-mail or saved using Save as, items that have been made visible by the code do not appear in the pdf file.  Here's the code used in the Yes option button:

    Comp4WhenImplementText.presence = "invisible";

    Comp4WhenImplement.presence = "invisible";

    Comp4MajorFactorText.presence = "invisible";

    Comp4WhenImplement.Comp4When03 = 0;

    Comp4WhenImplement.Comp4WhenNever = 0;

    If (Comp4No.selectedIndex! = - 1 |)

    Page3.COMP1.Comp1No.SelectedIndex! = -1 ||

    Page4.Comp2.Comp2No.SelectedIndex! = -1)

    {

    CorrectiveAction.presence = "visible";

    }

    on the other

    {

    CorrectiveAction.presence = "invisible";

    }

    The code in the box is as follows:

    Comp4WhenImplementText.presence = "visible".

    Comp4When.presence = "visible".

    CorrectiveAction.presence = "visible".

    The code in the button to send E-mail:

    Form1. #subform [12]. Button2::click - (JavaScript, client)

    If (CorrectiveAction.presence == 'visible')

    {

    If ((CorrectiveAction.rawValue == null) |) (CorrectiveAction.rawValue == ""))

    }

    on the other

    {

    Button1.execEvent ("Click");

    }

    {

    on the other

    {

    Button1.execEvent ("Click");

    }

    Button1 is invisible and laminates under visible e-mail submit button.  It actually supports the PDF by email.  The visible button performs a test and displays a message to the user if the user survey responses fail.  I also tried 'hidden' in all areas that are listed as 'invisible '.

    That should be added or changed so that the invisible elements of the survey that are made visible by the code can be seen in the pdf of the survey.  Any help would be greatly appreciated.

    There is a parameter that indicates it takes to save the changes via the code to the form upon registration. In the goto file/properties/Defaults form designer and make sure that the Radiobutton control that is named automatically under the Scripting to preserve changes to the form upon registration is set to.

    Paul

  • Script to generate the sys files os trail audit report

    Hello

    We have a large database, where 1000 bone trail files are generated every day.   Except sys, we get all the information lo - Gin of dba_audit_trail.

    But the listener wants the audit information sys too.

    It is very difficult to manually move all the files in the operating system. I tried to make a script to generate a report. But I do not succeed until now.

    If you have any of you have used or by using a similar script to generate a report of os audit .aud file sys. Please provide that.

    Also let me if there is another way to collect audit sys information easily.

    Thanks and greetings

    Marou

    Hi berang,.

    I wrote an article (http://www.dbarj.com.br/en/2014/10/retrieve-oracle-sysdba-audit-os-files-inside-table/) explaining exactly how to do it using the external Table with preprocessor function.

    Why don't you take a look and fit the need? I hope you enjoy.

    Kind regards

    Rodrigo

  • How to integrate the police Segoe Script in a saved pdf file?

    When I save a file .psd in .PDF (with Photoshop elements 12), two of the three fonts do appear fine in the .pdf file, but not the third (Segoe Script).  I open the PDF with Adobe Reader XI.

    How to integrate the police Segoe Script in the .pdf file?   (Depending on the printer, it must be there.)

    Thank you.

    Yes you will not be able to use either the distorted text.

    (these kinds of properties do not appear in this font)

    If you want to tilt the text as it would be for the italicized text, you can use Image > transform > Skew.

  • How to generate the PDF file through reports using forms 6i

    Hi all
    I use oracle 10g with forms 6i and reports 6i. I need to generate pdf files where clicking on a button, a report must be called and the report should be generated in PDF in the source I've specified (e.g. d:\...). Is - this popssible with forms? How can I achieve this. Kindly help me with the appropriate answers. Thanks :)





    Concerning
    Vids

    Hello
    about the report, there is a dedicated forum report. You should post here.
    but the answer to your question is form there has nothing to do with the generation of pdf. You can call the report from the usual.
    In the report, you must define properties such as
    destype to "file."
    desname 'path with file name ".
    desformat in "pdf".

  • The bookmarks do not appear when I generate a pdf file

    Hi all
    I generate un PDF from structured FrameMaker 10 .
    My book contains structured files

    When I created my PDF of the book I opened all the files .

    But when I want to Select elements (elements / tags) Add to the value bookmarks, all the do not appear in the dialog box .

    Pourrait you help me?

    thank you in advance

    As in unstructured FM, FM the first file in the book is used to pick up the paratgs and items to use for bookmarks at the level of the book. Please make sure that all tags/elements are in this file.

  • problem w / script to merge 2 PDF files

    Hello

    Is anyone please tell me what is the problem with my JavaScript?

    var newDoc = app.newDoc ();  create a new doc PDF

    newDoc.insertPages ({nPage:-1, cPath: "/ c/doc1.pdf",});    Insert doc1.pdf

    newDoc.insertPages ({nPage: newDoc.numPages, cPath: "/ c/doc2.pdf",});   Insert doc2.pdf

    newDoc.saveAs ({cPath: "/ c/myNewDoc.pdf"});     Save the new doc

    newDoc.closeDoc (true);    close the doc

    I fell on the batch processing of Adobe Pro 9.0 - he gave me the invalid argument type.

    Undefined Doc.insertPages:13:Batch: Exec = > nPage parameter.

    I'm trying to merge 2 PDF files using the Acrobat JavaScript Scripting Guide script sample, but it does not work for some reason any.

    I can has merged the 2 PDF files manually, but not by script.  I hope that in a script I can forced Adobe XFA forms that I created LCDesigner with the AcroForms.  Merge AcroForms and XFA forms.  I know that in manually may not merge. I wonder if it can it be done through JavaScript?  The doc1 doc2 I have are regular AcroForms

    Thank you 1 million for your help & suggestions

    Trang

    Hi Trang,

    XFA forms (created in the LC Designer) and AcroForms (created in Acrobat) are completely different animals!

    The XFA form is wrapped in a wrapper that runs in Acrobat/Reader. You cannot merge (AFAIK) an XFA form and a PDF (or AcroForm).

    The best that you will achieve is to attach an XFA form into a PDF file.

    Alternatively, you can group the XFA and PDF forms in a portfolio.

    Good luck

    Niall

  • The value of PDF file printed via the script name

    Hi people!

    I have a little problem with the generation of a PDF file. First my Workflow:

    I have an InDesign document with 6 pages. This document is merged with a databasefile containing 100 records. After it is merged, we need to generate a PDF file. This PDF file is opened in acrobat. In the document, I am looking for one ID for each record so I can split the document to 100 files (each with 6 pages) and name by the ID that I found.

    The Acrobat script is finished and functional. I thought: the InDesign script is over, too. But I was wrong-. -.

    I merged the databasefile with the document and it has exported to PDF. But after export, we noticed that the Acrobat script isn't finding the adressheader where ID is in. The script only noticed the text after this header. The result is, as get-Acrobat always 'null' as ID

    If print us the PDF with our PDFprinter, the header could be read by our script of Acrobat. I don't know why this is... But now, I changed the script to print the files through our PDF printer. Unfortunately I can not set a name for my exported file - do you know if it is possible to print PDF files without asking for confirmation after each other as well as with a via script name?

    Here you can see the old writing for InDesign and after her, the sript Acrobat. Maybe I made a mistake by generating my PDFexport and have no need to use the printer?

    INDESIGN SCRIPT:

    /**
    * invite filebrowser and stores the name and path of the file in variable
    */
    var sourceDocument = File.openDialog ("Bitte Indesign-Dokument Park", "*.indd", false);

    /**
    * stores the only prefix of file name to use as the new file name
    */
    newName var = sourceDocument.name.substr (0, sourceDocument.name.length - 5);

    /**
    stores in folder where the file is stored
    */
    var dbSourceFolder = sourceDocument.parent + "/"; "

    /**
    * guests for databasefile, where production is expected to begin
    */
    var dbstartfile = File.openDialog ("Start-Datenbankdatei of Bitte Park", "*.txt", false);

    /**
    * Gets databasefile basename
    */
    var dbstartfilename = dbstartfile.name.slice (0, dbstartfile.name.search(/_Teil+/));

    /**
    * Gets number of first databasefile
    */
    var i = dbstartfile.name.slice (dbstartfile.name.search(/_Teil+/) + 5) .slice (0, -4);

    /**
    * generates the path and name of the first databasefile to use
    */
    var dbSource = dbstartfile;

    /**
    * set PDF preset to generate PDFS
    */
    var PDFPreset = app.pdfExportPresets.item ("GAG - PDF");

    /**
    * stop throwing alerts
    */
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

    message will be thrown if databasefile is not existing
    If (dbSource.exists == false) {}
    reboot to launch alerts
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
    Alert ("File" + dbSourceFolder + dbprefix + "_Teil" + i + ".txt konnte nicht werden found! \n\rBitte starten Sie den procedure Rubis und Sie die right Datenbankdatei one enter.");
    }
    another process begins
    else {}
    even if (dbSource.exists == true) {}
    Opens the document indesign source without displaying
    mergeDocument = app.open (File (sourceDocument), false);
    defines what databasefile should be used for data merging
    mergeDocument.dataMergeProperties.selectDataSource (File (dbSource));
    starts the file database and the indesign document merging
    mergeDocument.dataMergeProperties.mergeRecords ();
    document generated in PDF export
    app.activeDocument.exportFile (ExportFormat.pdfType, File(sourceDocument.parent+"/"+newName+"_Teil"+i+".pdf"), false, PDFPreset);
    farm open indesign document
    mergeDocument.close (SaveOptions.no);
    i ++ ;

    change the name of the database file to get the next file
    dbSource = File(dbSource.parent+"/"+dbstartfilename+"_Teil"+i+".txt");
    }
    }
    reboot to launch alerts
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
    Alert ("PDF-Generierung sky!");

    SCRIPT ACROBAT:


    /**
    * Path where files should be saved
    * Special characters like spaces must be preceded of--------.
    * If you want to change the folder, use the following form:
    * ' / DriveLetter/foldername /... /LastFolderName/.
    * Be careful not to forget the / before and after the location
    */
    filepath var = "/ c/pdf_split_test / ';

    /**
    * Number of display pages - do not hesitate to change
    */

    pageType = app.prompt var ("Please die Seitenzahl der presentations one gewunschte.", "");
    Alert (PAGETYPE);

    /**
    to search for regular expression
    */

    var idNumber = / 08\d\d\d\d\-\d\d\d\-\d\d\d\d\d-\d\d\d-\d\d/g;

    /**
    * If possible this function gets the number sought as string
    *
    @param string of revenge that is to be found in the document
    * @return null if rematch is not found or a string if the rematch is
    */

    function ExtractFromDocument (reMatch) {}
    try {}
    var Out = new Object();
    for (var i = 0; i < 1; i ++)
    {
    numWords = this.getPageNumWords (i);
    var PageText = ' ';
    for (var j = 0; j < 30; j ++) {}
    var Word = this.getPageNthWord (i, j, false);
    PageText += Word;
    }
    var strMatches = PageText.match (reMatch);
    If (strMatches == null) continue;
    }
    Return strMatches;
    } catch (e)
    {
    App.Alert ("processing error:" + e)
    }
    }

    /**
    * tries to load given filename (excerpt number)
    *
    @param string file name of the file that should be checked
    @param n number of iterate when checking files
    * @return true if the file exists or false otherwise
    */

    function checkIfFileExists (filename, n) {}
    var existingDoc = false;
    try {}
    If (n == 0) {}
    var checkDoc = app.openDoc(filepath+filename+"-000.pdf");
    } else {}
    var checkDoc = app.openDoc(filepath+filename+"-000_"+n+".pdf");
    }
    checkDoc.closeDoc ();
    existingDoc = true;
    } catch (e) {}
    }
    If (existingDoc == true) {}
    n = n + 1;
    n = checkIfFileExists (filename, n);
    }
    return n;
    }

    var pageAmount = this.numPages;
    for (i = 0; I < pageAmount; i + pageType) {}
    var filename = ExtractFromDocument (idNumber);
    fileExistence = checkIfFileExists (filename, 0);
    If (fileExistence! = 0) {}

    this.extractPages ({nEnd:(pageType-1), cPath: filepath + filename + "-000_" + fileExistence + ".pdf"});
    } else {}
    this.extractPages ({nEnd:(pageType-1), cPath: filepath + filename + ""-000.pdf ""});
    }
    this.deletePages ({nStart:0, nEnd: pageType-1});
    }

    Hello

    I have a little problem with the generation of a PDF file. First my Workflow:

    I have an InDesign document with 6 pages. This document is merged with a databasefile containing 100 records. After it is merged, we need to generate a PDF file. This PDF file is opened in acrobat. In the document, I am looking for one ID for each record so I can split the document to 100 files (each with 6 pages) and name by the ID that I found.

    Why you are not exporting 6 pages PDF directly from InDesign?

    Robin

    www.adobescripts.co.UK

  • I have 12 FrameMaker files can I use FrameMaker 2015 to generate a PDF of older file?

    I have files created in FrameMaker 12.

    Can I use FrameMaker 2015 version to open the files and generate a PDF file?

    I get error when I try to do.

    I just want to know if it is possible or not.

    Thank you

    Alice

    Yes, it should be possible. What kind of error do you get?

    Open all files and save them as FM2015 versions first. If you have a book file, open all the files of the components before trying to create a PDF file. [Use the Shift key the shortcut in the file menu for the book to open all the files at once.]

Maybe you are looking for