Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old April 5th, 2010, 12:10 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,671
Default Re: Relative File Paths

Let me try to clear up a few things.

First, you can use "regular" DOS- or UNIX/POSIX-style path specifications to denote paths in FusionPro, on any platform. So "../OUTPUT/" will work fine, as will "..\OUTPUT\"; however, in the latter case, if you're defining that as a string literal in JavaScript, you need to escape the backslashes, i.e. "..\\OUTPUT\\" since those have a special meaning in JavaScript code. The HFS-style paths with colons will work too, but relative paths with multiple colons get complicated and confusing. So I would just stick with POSIX-style forward slashes ala "../OUTPUT/" and your life will be simpler.

Next, you can definitely use relative paths in FusionPro, to access just about anything. Relative paths will be resolved in this order at composition time:
  • The current working directory (mainly for FP Server jobs)
  • The input file location
  • The format file location (the template PDF for FP Desktop or the .DIF file for FP Server)
  • The user-defined Search Path (set on the "Advanced" tab of the Composition Settings dialog in FP Desktop)

Finally, while relative paths can be used and will be resolved as above, this only applies to files that already exist. For a file doesn't already exist on disk, FusionPro will only resolve a relative path based on the current working directory, which is really only relevant in certain FP Server workflows. So you can't really create your output file in a relative location like this in FP Desktop, at least not directly. However, you can use a workaround like so:
Code:
FusionPro.Composition.outputFileFullPathName = FusionPro.ResolveFile(".") + "/" + gOutputFolder + fileName;
Note that the folder must already exist.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #12  
Old April 5th, 2010, 12:25 PM
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Relative File Paths

Thanks for chiming in Dan. I just wish you could be available 24/7.
Quote:
Originally Posted by Dan Korn View Post
Next, you can definitely use relative paths in FusionPro, to access just about anything. Relative paths will be resolved in this order at composition time:
  • The current working directory (mainly for FP Server jobs)
  • The input file location
  • The format file location (the template PDF for FP Desktop or the .DIF file for FP Server)
  • The user-defined Search Path (set on the "Advanced" tab of the Composition Settings dialog in FP Desktop)
In the case of FP Server, how would it work for the .dif file to be somewhere other than the template file itself? Do you just manually move it, or does something internal to the template need to point to an alternate location?
Reply With Quote
  #13  
Old April 5th, 2010, 12:34 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,671
Default Re: Relative File Paths

Quote:
Originally Posted by esmith View Post
In the case of FP Server, how would it work for the .dif file to be somewhere other than the template file itself? Do you just manually move it, or does something internal to the template need to point to an alternate location?
Well, if you're using FP Server, the files can be anywhere you like, and you can specify either relative or absolute paths in the command-line parameters or CFG file settings. For instance, the .DIF file may have been generated by the DIF API in a network location which you could reference via a UNC path. But things will still work if everything is in the same folder too. It all depends on how you design your custom application which uses FP Server.

If you have FP Server-specific questions, feel free to post them in the FusionPro Server forum.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #14  
Old April 5th, 2010, 01:52 PM
jurgmay jurgmay is offline
Regular Contributor
 
Join Date: Aug 2009
Location: Bristol, UK
Posts: 53
Default Re: Relative File Paths

Guys - thanks for your input. I felt that this should be an easier problem to solve that it's proved!

Dan - just one thing if I may...

Quote:
Originally Posted by Dan Korn View Post
So you can't really create your output file in a relative location like this in FP Desktop, at least not directly. However, you can use a workaround like so:
Code:
FusionPro.Composition.outputFileFullPathName = FusionPro.ResolveFile(".") + "/" + gOutputFolder + fileName;
Note that the folder must already exist.
Can you explain how this works please? It's just that if I set gOutputFolder to "../OUTPUT/" a folder named OUTPUT is created in the parent folder of the parent folder of the template?! For example: I have a folder on the Desktop called FIC. Inside this is my template and resources and a folder called OUTPUT. When I run the composition, rather than the output file appearing in FIC > OUTPUT it actually creates a new folder on the Desktop and puts the file in there! If I only put one . in front of /OUTPUT/ it works fine. I'm just not sure why!

Out of interest, is there a reason why FP supports so many different conventions? If POSIX is the easiest cross-platform format then why not support just that one format?

Thanks so much to you and Eric for your help on this.

Regards,

Juerg
__________________
FusionPro Desktop 6.2P1a Windows XP & Mac OS X 10.6 (Snow Leopard)
Reply With Quote
  #15  
Old April 5th, 2010, 05:53 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,671
Default Re: Relative File Paths

Quote:
Originally Posted by jurgmay View Post
Can you explain how this works please? It's just that if I set gOutputFolder to "../OUTPUT/" a folder named OUTPUT is created in the parent folder of the parent folder of the template?!
Okay, some of the subtleties here depend on your exact operating system version. It's not clear to me which OS you're running. Your signature says, "FusionPro Desktop 6.1P1e Windows," and your original post mentioned "C:", which indicates Windows as well, but the screen-shot you attached is obviously from a Mac.

On Windows, a folder that doesn't already exist is generally not created, but on Mac it may be (depending on the version of OS X, the folder permissions, and some other things.) (The reasons for this different Windows and Mac functionality are complicated and have to do with low-level Carbon file handling routines on Mac which have been patched to work with POSIX paths; I'll just say that it would be more difficult to make it NOT work on Mac to match Windows than to just recommend that the folder already exist on both platforms.)

At any rate, I would recommend making sure that the folder exists first.
Quote:
Originally Posted by jurgmay View Post
For example: I have a folder on the Desktop called FIC. Inside this is my template and resources and a folder called OUTPUT. When I run the composition, rather than the output file appearing in FIC > OUTPUT it actually creates a new folder on the Desktop and puts the file in there! If I only put one . in front of /OUTPUT/ it works fine. I'm just not sure why!
I'm not understanding exactly what you're doing in the case that doesn't work.
Quote:
Originally Posted by jurgmay View Post
Out of interest, is there a reason why FP supports so many different conventions? If POSIX is the easiest cross-platform format then why not support just that one format?
Well, we run on both Windows and Mac, and both platforms support multiple path formats, so limiting to a subset of those formats would not only be more complicated for us to program, but would also, arguably, be more confusing to users who are used to dealing in various path formats.

It's also a historical/backwards-compatibility thing: when FusionPro (actually its predecessor DL Formatter) started out, it only ran on Windows, which used DOS paths, and then we ported to Mac OS 9, which used HFS paths (with colons), and then OS X came along with POSIX paths, and meanwhile newer versions of Windows came along which added support for using POSIX-style forward slashes as well as DOS-style backward slashes. And we don't want older jobs with the older path specifications to just stop working and break existing customers' jobs. So as in many other areas, we have to keep one foot in "legacy" specifications while at the same time supporting the newest fancy thing that Microsoft or Apple or Adobe decides that everyone should port to.

That said, at this point in time, for new jobs, I would recommend using POSIX-style paths (with forward slashes) on both Windows and Mac.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #16  
Old April 6th, 2010, 06:38 AM
tsghost tsghost is offline
Junior Community Member
 
Join Date: Oct 2008
Posts: 37
Default Re: Relative File Paths

I run on a Mac, no server.
I put my template in one folder and then create another folder which I put my DATA file and all my resources.
I do not have any problems or have to create any paths to my resources.
Seems as if FusionPro assumes the resources have the same path as the DATA file.

Not sure if this will help but thought I would throw it out there.
__________________
FusionPro Desktop 6.1.P1m
Acrobat 8.1
CS3 and Quark 7
Mac 10.5.8
2.8 Ghz Intel Core 2 Duo
Reply With Quote
  #17  
Old April 6th, 2010, 07:11 AM
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Relative File Paths

Quote:
Originally Posted by jurgmay View Post
Can you explain how this works please? It's just that if I set gOutputFolder to "../OUTPUT/" a folder named OUTPUT is created in the parent folder of the parent folder of the template?! For example: I have a folder on the Desktop called FIC. Inside this is my template and resources and a folder called OUTPUT. When I run the composition, rather than the output file appearing in FIC > OUTPUT it actually creates a new folder on the Desktop and puts the file in there! If I only put one . in front of /OUTPUT/ it works fine. I'm just not sure why
One dot (.) indicates current directory so ./OUTPUT indicates you are looking for the OUTPUT folder within the directory your template is located.

Two dots (..) indicates to go up one level from the current directory so ../OUPUT indicates you are going to the parent folder of your current directory (the Desktop in your case) and looking for OUTPUT at the same level as the folder your template is in.

So if you had a directory structure like so:
DESKTOP
-- FIC
---- INPUT
---- DATA
-- ABC
---- OUTPUT
-- XYZ

and you were in the FIC/INPUT folder, you could navigate to ABC/OUTPUT via a relative path, "../../ABC/OUTPUT". Confusing enough?
Reply With Quote
  #18  
Old April 6th, 2010, 08:36 AM
jurgmay jurgmay is offline
Regular Contributor
 
Join Date: Aug 2009
Location: Bristol, UK
Posts: 53
Default Re: Relative File Paths

Quote:
Originally Posted by esmith View Post
One dot (.) indicates current directory so ./OUTPUT indicates you are looking for the OUTPUT folder within the directory your template is located.

Two dots (..) indicates to go up one level from the current directory so ../OUPUT indicates you are going to the parent folder of your current directory (the Desktop in your case) and looking for OUTPUT at the same level as the folder your template is in.

So if you had a directory structure like so:
DESKTOP
-- FIC
---- INPUT
---- DATA
-- ABC
---- OUTPUT
-- XYZ

and you were in the FIC/INPUT folder, you could navigate to ABC/OUTPUT via a relative path, "../../ABC/OUTPUT". Confusing enough?
Actually Eric this makes perfect sense and I really appreciate the time you've taken to help me out with this. I am now 100% clear on how I need to handle paths to suit my needs. I may be wrong but I just don't see this in the documentation anywhere - would be a very useful addition for a future release (Dan - you reading this? )

Thanks again,

Juerg
__________________
FusionPro Desktop 6.2P1a Windows XP & Mac OS X 10.6 (Snow Leopard)
Reply With Quote
  #19  
Old April 6th, 2010, 08:46 AM
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Relative File Paths

Quote:
Originally Posted by jurgmay View Post
I may be wrong but I just don't see this in the documentation anywhere - would be a very useful addition for a future release
I think it's not in the FP documentation because it's a generic (albeit advanced) concept for computing. Including all the general computing and JavaScript coding examples would make for a daunting challenge. Plus, between the internet and these forums, most of the questions you might have are covered. One area that I think Dan already knows needs better documentation is for scripting objects/properties which are unique to FP (like ResolveFile) which we have no way of knowing about unless they pop up on the forums in a thread like this.

(Dan - you reading this? )
Reply With Quote
  #20  
Old April 6th, 2010, 08:46 AM
jurgmay jurgmay is offline
Regular Contributor
 
Join Date: Aug 2009
Location: Bristol, UK
Posts: 53
Default Re: Relative File Paths

Quote:
Originally Posted by Dan Korn View Post
Okay, some of the subtleties here depend on your exact operating system version. It's not clear to me which OS you're running. Your signature says, "FusionPro Desktop 6.1P1e Windows," and your original post mentioned "C:", which indicates Windows as well, but the screen-shot you attached is obviously from a Mac.
I am now using both and will update my signature accordingly.

Quote:
Originally Posted by Dan Korn View Post
On Windows, a folder that doesn't already exist is generally not created, but on Mac it may be (depending on the version of OS X, the folder permissions, and some other things.) (The reasons for this different Windows and Mac functionality are complicated and have to do with low-level Carbon file handling routines on Mac which have been patched to work with POSIX paths; I'll just say that it would be more difficult to make it NOT work on Mac to match Windows than to just recommend that the folder already exist on both platforms.)
OK, got that. Thanks for the explanation.

Quote:
Originally Posted by Dan Korn View Post
I'm not understanding exactly what you're doing in the case that doesn't work.
No worries. I thought it was clear enough but Eric has offered an explanation to this query and I now understand exactly how things work.

Just out of interest - is there anything about file paths in the documentation? I looked and looked and couldn't see anything there that really explained it fully. I'm sure the answers I've got from yourself and Eric could be of real benefit to all FP users.

Anyway, thanks for your patience and your clear explanations. I've learnt so much already from this forum especially from people like yourself and Eric and just wanted to say 'Thanks!'

Regards,

Juerg
__________________
FusionPro Desktop 6.2P1a Windows XP & Mac OS X 10.6 (Snow Leopard)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:31 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.