• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

How to export metadata informations like document title and author name of indesign book to pdf

Contributor ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

Hi, I am trying to export metadata informations like Author name and Document title available in first document of book to single pdf. While manually exporting whole book to single pdf, I am able to get all metadata informations by selecting the all documents in book by exporting it with option available in book menubar "Export selected documents to pdf"!

 

But while trying to export via script, unable to get meta informations available in first document of book. Attached the script for reference. Is there any other way to achieve this!

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
app.documents.everyItem().close(SaveOptions.YES);
app.activeBook.save();
var myBookName =   app.activeBook.name.replace(".indb", "");
var myFilePath = app.activeBook.filePath + "/" + myBookName + ".pdf";
var myFile = new File(myFilePath);
app.activeBook.exportFile(ExportFormat.PDF_TYPE, myFile, false);

 

TOPICS
How to , Scripting

Views

141

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 28, 2022 Dec 28, 2022

Hi @Karthik SG ,

so this should work for you:

 

var myBook = app.activeBook;
var myBookStyleSource = myBook.styleSourceDocument;

// Make the first document the style source:
myBook.styleSourceDocument = myBook.bookContents[0];

var myBookName =   app.activeBook.name.replace(".indb", "");
var myFilePath = app.activeBook.filePath + "/" + myBookName + ".pdf";
var myFile = new File(myFilePath);
app.activeBook.exportFile(ExportFormat.PDF_TYPE, myFile, false);

// Change back the style source to the 
...

Likes

Translate

Translate
Community Expert ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

Hi @Karthik SG ,

what happens if you have no documents selected in the book file and then export to PDF using the GUI?

Would the metadata come along as expected?

 

Another thing:

If you expect the first document's metadata in the PDF, is the value for styleSourceDocument the first document in your book file?

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Book.html

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

Hi @Laubender ,

what happens if you have no documents selected in the book file and then export to PDF using the GUI? - No meta information were updated in exported PDF.

 

If you expect the first document's metadata in the PDF, is the value for styleSourceDocument the first document in your book file? - I don't have idea about this  styleSourceDocument !

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

Hi @Karthik SG , Your script is working for me—the PDF includes the basic metadata of the first item in my test book when I check Document Properties in AcrobatPro. You are not including a preset parameter in your exportFile, when I tested your code my Indesign preset was defaulting to PDF/X-4.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

I don't use any selective preset , default preset was selected while exporting @rob day 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

I tried by including the presets also but for me it was not working! Is there anyway to select the documents in the book before exporting to pdf via javascript?

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
app.documents.everyItem().close(SaveOptions.YES);
app.activeBook.save();
var myPDFExportPreset = app.pdfExportPresets.item("[High Quality Print]");
var myBookName =   app.activeBook.name.replace(".indb", "");
var myFilePath = app.activeBook.filePath + "/" + myBookName + ".pdf";
var myFile = new File(myFilePath);
app.activeBook.exportFile(ExportFormat.PDF_TYPE, myFile, false, myPDFExportPreset);

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

Hi @Karthik SG ,

one document in a book file governs the synching of all documents in a book file, that's the styleSourceDocument.

In the GUI the style source is defined in the first column of the listed documents. Here for example it's the third document:

 

BookFile-styleSourceDocument.PNG

 

So my assumption is, that the style source governs the embedded metadata of an exported PDF of the book.

And indeed, it does! (Just tested that. So make sure that the first document in your book file is the one with yourBook.styleSourceDocument:

app.books[0].styleSourceDocument = app.books[0].bookContents[0];

Then the exported PDF will contain the metadata of the first document that is listed in your book file.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

Hi @Karthik SG ,

so this should work for you:

 

var myBook = app.activeBook;
var myBookStyleSource = myBook.styleSourceDocument;

// Make the first document the style source:
myBook.styleSourceDocument = myBook.bookContents[0];

var myBookName =   app.activeBook.name.replace(".indb", "");
var myFilePath = app.activeBook.filePath + "/" + myBookName + ".pdf";
var myFile = new File(myFilePath);
app.activeBook.exportFile(ExportFormat.PDF_TYPE, myFile, false);

// Change back the style source to the original one:
myBook.styleSourceDocument = myBookStyleSource;
myBook.save();

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

wow! Its working now @Laubender .Thank you very much😊

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 29, 2022 Dec 29, 2022

Copy link to clipboard

Copied

LATEST

Hi @Karthik SG ,

please be so kind to mark my answer above as "correct".

 

Thanks,
Uwe Laubender
( Adobe Community Expert )

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

Hi @Karthik SG ,

well, the script is working now as you expect it to work.

The question is: why does the style source does not contain the necessary metadata?

 

FWIW: I would not question the fact that the first document in the book file is not the style source.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines