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

FDK select all components (files) in a book

New Here ,
Nov 04, 2008 Nov 04, 2008

Copy link to clipboard

Copied

Hi,

I need to open a FrameMaker book (by double-clicking the file for the book in file explorer) and then select all the files in the book window (the short cut is ctrl-g).

I was able to open each file without having them visible and I can also bypass the missing font dialog box by allowing missing font in the parameters for opening files.

Can anyone show me how to do that?

Thanks,

coderRL
TOPICS
Structured

Views

1.1K
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
Mentor ,
Nov 05, 2008 Nov 05, 2008

Copy link to clipboard

Copied

Robert,

I'm not clear on what you are asking for. Do you want to open the book with the FDK, or have the FDK respond after a book is opened? What is the importance of selecting files in the book window?

To select all book components, you could do something like (warning, untested)

F_ObjHandleT bookId, compId;

bookId = F_ApiGetId(0, FV_SessionId, FP_ActiveBook);
compId = F_ApiGetId(FV_SessionId, FP_FirstComponentInBook);

while(compId)
{
F_ApiSetInt(bookId, compId, FP_ComponentIsSelected, True);
compId = F_ApiGetId(bookId, compId, FP_NextComponentInBook, True);
}

Russ

Votes

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
New Here ,
Nov 05, 2008 Nov 05, 2008

Copy link to clipboard

Copied

Hi Russ,

Thanks for code and it works, actually it is:

F_ObjHandleT bookId, compId;

bookId = F_ApiGetId(0, FV_SessionId, FP_ActiveBook);
compId = F_ApiGetId(FV_SessionId, bookId, FP_FirstComponentInBook);

while(compId)
{
F_ApiSetInt(bookId, compId, FP_ComponentIsSelected, True);
compId = F_ApiGetId(bookId, compId, FP_NextComponentInBook, True);
}

I was trying to save a book as PDF but it runs into the font unavailable message and I have to respond to it one by one. So I was writing the code to open each fm file (component) with:
i = F_ApiGetPropIndex(&script, FS_FontNotFoundInDoc);
script.val.propVal.u.ival = FV_DoOK;

Now the user can double-click from File Explorer to open the book and then run this function to open all the documents in the book and the documents will be selected at the same time in the book window.

At the moment, I have a few more questions,
1. Can I use API to save the book into a specified directory, with specific "PDF Job Option" and "Generate Separate PDF document for Each Selected File." checked?

2. How can I open documents without inducing .lck files?

3. How can I report the source and target information of a broken hyperlink? I try the badlink example but it gives only the hyperlink IDs.

I am new to programming FrameMaker with FDK. May I use the same topic thread or should I start a new one?

Thanks again,

Robert

Votes

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
Mentor ,
Nov 06, 2008 Nov 06, 2008

Copy link to clipboard

Copied

Hi Robert,

I think this thread is OK to continue. For your questions:

1 - Yes. You'll need to use F_ApiSave() and set up your save parameters with the FV_SaveFmtPdf property. Look up F_ApiGetSaveDefaultParams() in the FDK ref. Also, you'll need to set some properties on the book to get the PDF behavior you want, namely FP_PDFJobOption and FP_PDFSeparateFiles.

2 - I don't think this is possible to control with the FDK, unless you were to open a copy of the file which probably wouldn't give you the desired results. You can disable the locking option manually with File > Preferences > General. Or, you could use F_DeleteFile() after opening the book component to delete the LCK file... this shouldn't have any adverse affect for your application.

3 - You can't really report on the target, because you don't know where it is (hence the "broken" part). You can use the FO_XRef properties to tell a bit about the xref itself.

I hope this helps some. You may just need to get to know the FDK a little better, after some time the basic logic of how it works should fall into place.
Russ

Votes

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
New Here ,
Nov 11, 2008 Nov 11, 2008

Copy link to clipboard

Copied

Hi Russ,<br /><br />Thanks for all the information. Now, I have to work on another piece first. I have to say that I am not really a FrameMaker authoring expert.<br /><br />I need to output the name of the flows (is flow an element?) and their text in the order they appear in each document inside a book.<br /><br />I read the fdkguide and fdkref, I came up with 2 pieces of code and I do not know the differences between them. Would you like to enlight my ignorance?<br /><br />A)<br /> activeDocId = F_ApiGetId(0,FV_SessionId,FP_ActiveDoc);<br /> // the flow<br /> objId = F_ApiGetId( FV_SessionId, activeDocId, FP_FirstFlowInDoc );<br /> while( objId ){<br /> textItems = F_ApiGetText( activeDocId, objId, FTI_String );<br /> text = CreateStringFromTextItems( textItems );<br /> // {...Do some comparison using F_StrSubstr ...}<br /> F_Sprintf(msg, "The document paragraph text is:\n%s.",text);<br /> F_Printf(chan, msg);<br /> F_Printf(chan, "\n");<br /> // F_ApiAlert(msg, FF_ALERT_CONTINUE_NOTE);<br /> F_Free( text );<br /> F_ApiDeallocateTextItems( &textItems );<br /> // pgfId = F_ApiGetId( activeDocId, pgfId, FP_NextPgfInDoc);<br /> objId = F_ApiGetId( activeDocId, objId, FP_NextFlowInDoc);<br /> }<br /> <br />B)<br /> docId = F_ApiGetId(0, FV_SessionId, FP_ActiveDoc);<br /> flowId = F_ApiGetId(FV_SessionId, docId, FP_MainFlowInDoc);<br /> tis = F_ApiGetText(docId, flowId, FTI_String | FTI_LineEnd);<br /> /* Traverse text items and print strings and line ends. */<br /> for (i=0; i<tis.len; i++)<br /> {<br /> ip = &tis.val;<br /> if (ip->dataType == FTI_String)<br /> // F_Printf(NULL,"%s", ip->u.sdata);<br /> F_Printf(chan,"%s", ip->u.sdata);<br /> else <br /> // F_Printf(NULL,"\n");<br /> F_Printf(chan,"\n");<br /> }<br /><br />One starts with the first flow and the other starts with the main flow. Should they be the same? Is this the way of reporting name of flows and their text?<br /><br />Also, it gives me some non-ascii characters in the text output when I print it to a specified channed. Is there anyway that I can convert the FrameMaker text strings into iso or ascii strings to output?<br /><br />Thanks,<br /><br />Robert

Votes

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
Mentor ,
Nov 11, 2008 Nov 11, 2008

Copy link to clipboard

Copied

Robert,

Those code samples look very similar to me, except:

- The first example iterates through all flows in the doc, while the second one reads the main flow only. The main flow is the standard flow in which authoring takes place, normally named flow "A". A document typically has many other flows, though, such as any text frame, including text frames on the reference pages.

- The second example reads the line ends into the textitemsT structure, while the first does not. I don't think this really matters to you because you'll get separate strings in the structure for each line anyway, I believe.

Some other points related to your questions:

- I don't know how you can get the flows in document order. Maybe there is some trick to finding out what page the first text frame of a flow is on, then deducing the order from that. I don't know how to do it. I do know, however, that iterating through the internal stack like your first example will not necessarily give you the flows in document order. Furthermore, you won't even know whether they are even on the body pages.

- Most flows do not have names. For example, if somebody sticks in a text frame for a graphic callout, it won't have a name. So I'm not sure how much that would help you, unless you are dealing with an exceptionally rigid template that was specially designed for your application.

- I don't know any way to ASCIItize your strings, except iterating over the characters and looking for characters in the unicode range and then converting them to something. I'm no expert in this area, though, so that's just my quick answer.

- A flow is not an element. A flow is one or more connected text frames that contain a flow of text, which may or may not have that text wrapped in a tree of structural elements. If you really are talking about elements instead of flows, then much of what we have said so far is not applicable, because you might be barking up the wrong tree, so to speak. Can you maybe clarify what your goal is?

Russ

Votes

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
New Here ,
Nov 11, 2008 Nov 11, 2008

Copy link to clipboard

Copied

Hi Russ,

Thanks for your response. What I am trying to do is to extract meta-data (attribute) information from the documents, I need to tag each document of a given book.

After looking at a few documents, I found that they are structurally very similar, meaning that the title information can be found in each document inside a flow of certain name. To be sure about that, I was hoping that I can write something to output the flow name and the corresponding content so that I can verify.

When I click at the area that shows the title information, it shows "Flow: A : 100_01_01_header" at the lover left hand corner of the FrameMaker application window (by looking a... : 010_01_00_Heading01". The third one is in "Flow: B : 060_02_01_body number" or "Flow: B : *060_01_01_body number".

Here are my questions:
Why some names have an asterisk (*) in it?

Can I...







Votes

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
Mentor ,
Nov 12, 2008 Nov 12, 2008

Copy link to clipboard

Copied

Robert,

Based on your description, I don't think your document has any elements in it, at least structural elements defined by an EDD. When you see "Flow A: 100_01_01_header" in the document footer, I believe that this means your insertion point is in a paragraph in flow A (the main flow) and the paragraph has the "100_01_01_header" paragraph format applied. If it were a structured document with elements, the element name would show in the footer instead, but it would be preceded by an "E:".

I confess that I still don't quite follow what you are trying to do. I think you are using words like "element," "metadata," and "attribute" to describe something different than I am used to. For those of us who live in XML and structured content, these words specifically apply to structural markup, but I'm not so sure that your document is even structured or that you are concerned with structure.

Having said that, I'd be happy to look at a file. Send it to russ@weststreetconsulting.com, with perhaps a little bit of description inside of it to elaborate on what your goals are.

Thanks,
Russ

Votes

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
Mentor ,
Nov 12, 2008 Nov 12, 2008

Copy link to clipboard

Copied

Oh, sorry, for your other question... an asterisk means that a format override was made to the paragraph format. In other words, a format was applied, then someone made a spot change to that paragraph only which deviated from the format rules.

Votes

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
New Here ,
Nov 12, 2008 Nov 12, 2008

Copy link to clipboard

Copied

Hi Russ,

In the email attachment, please find a zip file (sec_01-03.zip) that contains a sample of the FrameMaker documents that I am working on and a text file (output.txt) generated with some code for extracting the paragraph text along with the paragraph name. I am also attaching the code in fcn.txt. Please feel free to comment to help me improve.

Thanks for the hints in the forum. I should not go after FO_FLOW. Instead, I should use the list of PO_Pgf objects in the documents, as indicated in the code. With the information in output.txt, I can write another program to parse it to get the information needed. But please let me know if I am still not on the right track.

What I actually meant was to extract some texts from the content of the FrameMaker documents. These texts will then be attributes (for example, title) associated with the document.

When you open output.txt, you will see some special characters. Is there anyway to print them out in a recognizable way?

Thanks,

Robert

Votes

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
Mentor ,
Nov 13, 2008 Nov 13, 2008

Copy link to clipboard

Copied

LATEST
Hi Robert,

I got your file. I'll need to defer this until tomorrow due to workload, but I will look at it in more detail then.

Russ

Votes

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