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

Script under FM2020 no longer works correctly

Community Beginner ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

I need a script wiwh can import multi pages PDF. Please help !

chris

Views

319

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 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

«Script under FM2020 no longer works correctly»

@Christelle5FA8

Which script?

Votes

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 Beginner ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

Hello,

I need to import multipages PDF in my FRAMEMAKER files. I had a script working with the add on Framescript. It used to work with FM2015 but no more with FM2020. When the file is imported via the script  I get : several times the first page. For a imported PDF of 10 pages, I will get 10 pages but with the 10 times the same page. I have to click en page 2, right click, and click 'in background/ or behind) I don't know what it is in English, I'm French. And do the same for all the other pages. I can send you the files, if you want to test it.

 

Thanks for your understanding,

Best regards and Merry Christmas !

Christelle

Votes

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
Adobe Employee ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

Do you have upgraded FrameScipt as well? You will need FrameScript 7 for FM 2020: https://framescr.com/wb/ 

 

That said: Can you open the FrameScript in a plain text editor (e.g. Notepad), Copy the content and insert it here? Maybe the scripting pros can see what the issue is.

Votes

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 Beginner ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

Dear Stephan, 

I've got a license for framescript 7. Here is the cript. Thanks for your help.

Best wishes,

Christelle

 

//!LABEL=Import PDF pages...
//!SHORTCUT=
//!ENABLED=3
// EnableInParaText
// ---------------------------------------------------------------
///////// THIS FILE IS SUPPOSED TO BE UTF-8 ENCODED !! ///////////
///////// UTF-8 Trigger characters: äöü
/*
capImportPDFPages.fsl
Copyright 2010 Michael Müller-Hillebrand, All Rights Reserved.

Version:
2010-07-09

PSEUDO CODE

Select PDF document
Read number of pages
Show dialog
If OK
store PDF path
import selected pages

*/

Run Main;

// ---------------------------------------------------------------

Sub Main
Local lvPgf lvPgfName('') lvPDFName('') lvPageFrom(0) lvPageTo(0) lvPage(0);
Local lvAFrame lvInset;

If (not ActiveDoc.TextSelection)
MsgBox 'A text insertion point is required for this script.' Mode(Note);
LeaveScript;
EndIf

Local lvFileName;
Run ESys.RemoveFileExtension FullPath(ThisScript) NewExt('ini') NewVar(lvFileName);
Set PlatformEncodingMode = False;

Set lvEForm = BuildDialog{lvValues};
Run lvEForm.ShowModal NewVar(lvFormResult);

If (not lvFormResult)
LeaveScript;
EndIf

Run ESys.SetINIKeyValue File(lvFileName) Section(Session.HostName) Key('LastPDFOpenFolder') Value(ESys.ExtractPathName{lvEForm['Label0'].Caption});

// Import pages into current document
Set lvPgf = ActiveDoc.TextSelection.Begin.Object;
Set lvPgfName = lvPgfName;

Set lvPDFName = lvEForm['Label0'].Caption;
Set lvPageFrom = EUtl.Convert{lvEForm['PageFrom'].Text, 'Integer'};
Set lvPageTo = EUtl.Convert{lvEForm['PageTo'].Text, 'Integer'};

Loop LoopVar(lvPage) InitVal(lvPageFrom) Incr(1) While(lvPage <= lvPageTo)
If (lvPage > lvPageFrom)
// create new pgf
New Paragraph DocObject(lvPgf.Doc) PgfFmtName(lvPgfName) PrevObject(lvPgf) NewVar(lvPgf);
EndIf

New AFrame NewVar(lvAFrame)
TextLoc(lvPgf)
AnchorType(AnchorBelow)
Alignment(AlignLeft)
Height(20mm)
Width(20mm)
;

New Inset NewVar(lvInset)
ParentObject(lvAFrame)
InsetFile(lvPDFName)
PageNum(lvPage - 1)
LocX(0)
LocY(0)
;

Set lvAFrame.Width = lvInset.Width;
Set lvAFrame.Height = lvInset.Height;

EndLoop

EndSub // Main

// ---------------------------------------------------------------

Function BuildDialog pvValues
Local lvEForm lvTop lvString lvX;
Local lvFormW(560) lvFormH(280);
Local
lvTitle('Import PDF Pages')
lvLabel0('Click Browse to select PDF document')
lvGroup0('PDF document')
lvButton0('Browse...')
lvGroup1('Page range')
lvLabel1('Document size:')
lvLabel2('undefined')
lvLabel3('Import from:')
lvLabel4('to:')
lvLabel5('') // Illegal range warning
;

New EForm NewVar(lvEForm) Caption(32S + lvTitle + 32S) FontName('Trebuchet MS') FirstFocus('Button0')
OnInitForm('SelectPDF')
Width(lvFormW) Height(lvFormH);

Set lvTop = 10;
New EGroupBox Form(lvEForm) Name('Group0') Caption(32S + lvGroup0 + 32S)
Top(lvTop) Left(10) WidthMinus(20) Height(55);
New ELabel Form(lvEForm) Name('Label0') Caption(lvLabel0) EllipsisStyle('Path')
Top(lvTop+25) Left(30) WidthMinus(160);
New EButton Form(lvEForm) Name('Button0') Caption(lvButton0) OnClick('SelectPDF')
Top(lvTop+20) LeftLocFromRight(120) Width(100) Height(25);

Set lvTop = lvTop + 65;
New EGroupBox Form(lvEForm) Name('Group1') Caption(32S + lvGroup1 + 32S)
Top(lvTop) Left(10) WidthMinus(20) Height(85);
New ELabel Form(lvEForm) Name('Label1') Caption(lvLabel1)
Top(lvTop+25) Left(30);
New ELabel Form(lvEForm) Name('Label2') Caption(lvLabel2)
Top(lvTop+25) Left(130) WidthMinus(150);
New ELabel Form(lvEForm) Name('Label3') Caption(lvLabel3)
Top(lvTop+55) Left(30);
New EEdit Form(lvEForm) Name('PageFrom') Text('') OnChange('OnChangePage')
Top(lvTop+50) Left(130) Width(30) Height(25);
New ELabel Form(lvEForm) Name('Label4') Caption(lvLabel4)
Top(lvTop+55) Left(190);
New EEdit Form(lvEForm) Name('PageTo') Text('') OnChange('OnChangePage')
Top(lvTop+50) Left(250) Width(30) Height(25);
New ELabel Form(lvEForm) Name('Label5') Caption(lvLabel5) FontWeight('Bold') ForegroundColor(EUtl.GetRGB{255,0,0})
Top(lvTop+55) Left(310) WidthMinus(330);

// Standard Buttons
New EButton Form(lvEForm) Name('ButtonOK') Caption('OK')
TopLocFromBottom(35) Left(10) Width(100) Height(25)
DefaultButton(True) CloseFormWithValue(True);
New EButton Form(lvEForm) Name('ButtonCancel') Caption('Cancel')
TopLocFromBottom(35) LeftLocFromRight(110) Width(100) Height(25)
CloseFormWithValue(False);

Set Result = lvEForm;

EndFunction

// -----------------------------------------------------------------------

Sub SelectPDF EFormVar EControlVar
Local lvFileName('') lvPrevPath('') lvBtn lvFile lvPages;
Run ESys.RemoveFileExtension FullPath(ThisScript) NewExt('ini') NewVar(lvFileName);
Set lvPrevPath = ESys.GetINIKeyValue{lvFileName, Session.HostName, 'LastPDFOpenFolder'};
DialogBox Type(ChooseFile)
Directory(lvPrevPath)
Title('Select PDF document')
Init('*.pdf')
NewVar(lvFile)
Button(lvBtn)
Mode(SelectFile);
If (lvBtn = OkButton and lvFile != '')
Set EFormVar['Label0'].Caption = lvFile;
Set lvPages = GetNumPagesInPDF{lvFile};
Set EFormVar['Label2'].Caption = '' + lvPages;
Set EFormVar['PageFrom'].Text = '1';
Set EFormVar['PageTo'].Text = '' + lvPages;
Set EFormVar.CurrentFocus = 'PageFrom';
Run EFormVar['PageFrom'].SelectAll;
Set EFormVar['ButtonOK'].Enabled = True;
Else
Set EFormVar['ButtonOK'].Enabled = False;
EndIf
EndSub

// -----------------------------------------------------------------------

Sub OnChangePage EFormVar EControlVar
Local lvFrom lvTo lvPages(0);
Set lvPages = EUtl.Convert{EFormVar['Label2'].Caption, 'Integer'};
Set lvFrom = EUtl.Convert{EFormVar['PageFrom'].Text, 'Integer'};
Set lvTo = EUtl.Convert{EFormVar['PageTo'].Text, 'Integer'};
If (lvFrom < 1 or lvTo > lvPages or lvFrom > lvTo)
Set EFormVar['ButtonOK'].Enabled = False;
Set EFormVar['Label5'].Caption = 'Illegal page range!';
Else
Set EFormVar['ButtonOK'].Enabled = True;
Set EFormVar['Label5'].Caption = '';
EndIf
EndSub

// ---------------------------------------------------------------

Function GetNumPagesInPDF pvFileName
Local lvResult(0) lvNumPages(0) lvNoSave(True);
New EActiveXObject NewVar(gvAcrobat) ProgId('AcroExch.PDDoc');
Set lvResult = gvAcrobat.EslRunMethod{'Open', pvFileName};
If (lvResult)
Set lvNumPages = gvAcrobat.EslRunMethod{'GetNumPages'};
Set lvResult = gvAcrobat.EslRunMethod{'Close', lvNoSave};
EndIf
Delete Object(gvAcrobat);
Return lvNumPages;
EndFunction

// ---------------------------------------------------------------

Votes

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
Advocate ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

I quickly browsed over your script and it is a lot of code. Also most of the people on this forum are using ESTK instead of FrameScript. So I doubt you will get an answer about exactly why the script no longer seems to be working in FM2020.

If you developed the script yourself, you should be able to figure out what has changed, or at least where the script goes wrong in FM2020. If someone developed the script for you, that would be the person to ask about the upgrades required to make it work again. 

 

Good luck

Votes

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 Beginner ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

I have no skills in coding. The script was made years ago by I-don't-know-who.

what a pity it no longer works. It's weird.

I don't despair someone manages to solve my problem.

Thanks for your message.

 

Merry Christmas !

Christelle

Votes

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
Enthusiast ,
Dec 24, 2021 Dec 24, 2021

Copy link to clipboard

Copied

I have no idea about FrameScript, but there are 2 things worth mentioning in the script:

 

1. Author is Michael Müller-Hillebrand @ Michael_Müller-Hillebrand-basb

2. Encoding is strange:

 

///////// THIS FILE IS SUPPOSED TO BE UTF-8 ENCODED !! ///////////
///////// UTF-8 Trigger characters: äöü
/*
capImportPDFPages.fsl
Copyright 2010 Michael Müller-Hillebrand, All Rights Reserved.

Version:
2010-07-09

Votes

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
Advocate ,
Dec 24, 2021 Dec 24, 2021

Copy link to clipboard

Copied

Yes, on second look I saw the author name of the script, too. Michael has stopped scripting a long time ago, and has taken a job at Docufy. I checked briefly how to do a PDF import in ExtendScript and it should be doable to create a new script that does this. I just don't know how to figure out the number of pages in a PDF file from the scripting interface. Michael used some Acrobat connector to do this. If there is another method that does not require communication to another component a script should be fairly easy to create.

 

Having said that, I will not have time for this, but if there is a small budget available one of the script gurus on this forum (Klaus, Rick, Ian?) might be able to make it work.

 

Good luck

Votes

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 24, 2021 Dec 24, 2021

Copy link to clipboard

Copied

«2. Encoding is strange»

This is propably by opening the script with a non-Unicode savvy editor and copying it into the forum.

Klaus the older

Votes

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 ,
Jan 10, 2022 Jan 10, 2022

Copy link to clipboard

Copied

Hi Chris,

 

What's the exact FrameMaker version?

For FM 2020 you have to upgrade to 16.0.3 (that's the version number in Help | About).

Here is the explanation.

https://framescr.com/wb/downloads.html

 

And of course it could be that you damaged the script file by opening in a non-Unicode text file and saving (as Klaus said).

 

Best regards

 

Winfried

Votes

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 Beginner ,
Jan 10, 2022 Jan 10, 2022

Copy link to clipboard

Copied

LATEST

Hi Winfried,

Thanks for your interest in my problem. My version is the right one : 16.0.3.379

Best wishes

Christelle

Votes

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