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

Removing lines of text when placing text with javascript

New Here ,
Jul 11, 2017 Jul 11, 2017

Hi. I am working on a script hat places articles from text files. The first 4 lines contain information about the service that provides the article.

Is there any method that wiil ignore or remove the first 4 paragraphs when placing the text?

TOPICS
Scripting
843
Translate
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 Beginner , Jul 12, 2017 Jul 12, 2017

I would suggest placing the text files and just removing the unnecessary paragraphs (line breaks). Example below which is rather simplistic but hopefully will get you down the right path. Just select the text frames and remove paragraphs by range.

var doc = app.activeDocument;

var myFile = "/c/test/myTxtFile.txt";

var myTxf = doc.pages.item(0).textFrames.item(0);

    myTxf.place(File(myFile));

    myTxf.paragraphs.itemByRange(0,3).remove();

Translate
Mentor ,
Jul 11, 2017 Jul 11, 2017

Look into BEFORE_PLACE and AFTER_PLACE events

Translate
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 Beginner ,
Jul 12, 2017 Jul 12, 2017

I would suggest placing the text files and just removing the unnecessary paragraphs (line breaks). Example below which is rather simplistic but hopefully will get you down the right path. Just select the text frames and remove paragraphs by range.

var doc = app.activeDocument;

var myFile = "/c/test/myTxtFile.txt";

var myTxf = doc.pages.item(0).textFrames.item(0);

    myTxf.place(File(myFile));

    myTxf.paragraphs.itemByRange(0,3).remove();

Translate
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
New Here ,
Jul 13, 2017 Jul 13, 2017

Thanks, that worked like a charm.

Translate
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
Mentor ,
Jul 13, 2017 Jul 13, 2017
LATEST

I must have been very tired when I completely misread your question

Translate
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