Loop Page Style Sheet to set file name.
I am exporting pages to jpgs and pngs using a script that pulls the name from an applied style sheet.
http://forums.adobe.com/message/5913479#5913479
the above works perfectly if I only want to specify one style sheet as the file name.
the challenge may need to use different style sheets on each page to create the name.
I am not sure how to loop through each page and grab the style in play.
or if I need to loop at all.
This is where I am...
function MakePNGfile()
for(var myCounter = 0; myCounter < myDoc.pages.length; myCounter++)
if (myDoc.pages.item(myCounter).appliedSection.name != "")
myDoc.pages.item(myCounter).appliedSection.name = "";
var myStyle1 = "sheetlabel-text";
var myStyle2 = "sheetlabel-text-2";
var myParagraphs = myDoc.pages.item(0).textFrames.item(0).parentStory.paragraphs;
var myPageName = myDoc.pages.item(myCounter).name;
var myPNGPrefix = "";
for( i = 0; i < myParagraphs.length; i++)
var paragraph = myParagraphs.item(i);
if (paragraph = myStyle1)
(myPNGPrefix = getParagraphContent(myDoc.paragraphStyles.item("sheetlabel-text"), myDoc.pages.item(myCounter))+ '-0' + myPageName)
else
(myPNGPrefix = getParagraphContent(myDoc.paragraphStyles.item("sheetlabel-text-2"), myDoc.pages.item(myCounter))+ '-0' + myPageName)
Thanks for your help!
Good to hear .
Find attached the next version. You can now insert in 'paraStyleNames' as many style names as you want. The script will check from left to right, if there is one found on the page. If this is true, the script will ignore the other styles.
Removing leading zero should work now.
Maybe one problem: If one page contains no style, this page will be exported nevertheless with it’s correct page number, but with the founded text of the previous page. If this can never happen, we are done and you should mark the answer as correct. If this is a real problem for you, please let me know, what should happen in this case and I will try to fix that too.
// Export pages as JPG with additional info by Kai Rübsamen
// http://forums.adobe.com/message/6326425#6326425
main ();
function main() {
var curDoc = app.activeDocument;
// Array of paragraph Style names
var paraStyleNames = ["h1", "h2"]; // insert here your para names !
var missingParaStyles = [];
// check, if the styles are valid
for ( var p = 0; p < paraStyleNames.length; p++ ) {
var curName = paraStyleNames[p];
// if the style is missing, push it to the array
if ( !curDoc.paragraphStyles.itemByName(curName).isValid ) {
missingParaStyles.push( curName );
// if some styles are missing, give an alert
var nMiss = missingParaStyles.length;
if ( nMiss > 0 ) {
var display = missingParaStyles.join( "\r" );
alert ( "Missing para(s):\r" + display );
exit();
// loop through all pages
for ( var i = 0; i < curDoc.pages.length; i++ ) {
// the current page
var curPage = curDoc.pages[i];
// the current pages name
var pName = curPage.name;
// controls the loop
var controller = true;
// all paragraphs on the current page
var allPageParas = curPage.textFrames.everyItem().paragraphs.everyItem().getElements();
// loop through all paragraphs and check, if one has the para style applied
for ( var p = 0; p < allPageParas.length; p++ ) {
if ( !controller ) break;
// the current para
var curPara = allPageParas[p];
// loop through the styles
for ( var n = 0; n < paraStyleNames.length; n++ ) {
if ( curPara.appliedParagraphStyle.name == paraStyleNames[n] ) {
var paraContents = curPara.contents;
var paraString = "-" + paraContents.replace( /\s+$/ , "" ).replace( /\s+/g , "-" ).toLowerCase();
controller = false;
break;
} // end if
} // end for paraStyleNames
} // end for allPageParas
//~ var folderPath = "~/-client/JOYS - Just Organize Your Stuff/-Art/-art-book-kindle/";
var folderPath = Folder.desktop;
if ( pName < 10 ) {
var appendix = "-0" + pName + paraString;
else {
var appendix = "-" + pName + paraString;
var filePath = folderPath + "/" + curDoc.name.replace(/\.indd$/,"") + appendix + ".jpg";
var myFile = File( filePath );
with ( app.jpegExportPreferences ) {
jpegQuality = JPEGOptionsQuality.high; // low medium high maximum
exportResolution = 72;
jpegExportRange = ExportRangeOrAllPages.exportRange;
pageString = pName;
curDoc.exportFile( ExportFormat.jpg, myFile, false );
} // end for pages
} // end main
–Kai
Similar Messages
-
Set file name as a variable. Then use it to name a folder
I'm making a workflow that I want to get the selected file, then create a new folder using that file's name. I made a workflow as follows:
Get selected Finder Item (In this case a JPG image)
Set Value of Variable
New Folder (dragging the variable from 'Set Value of Variable')
But running this workflow it adds the path of the file to the new folders name, as well as the file's name (e.g. instead of the folder being called 'Photo1' it's called '/Users/Jono/Desktop/Photo1.jpg').
Does anybody know how I could get it to just the file name (preferably without the extension) instead of prefixing it with the path?The New Folder action uses the specified text for the file name. The following Run AppleScript action will return just the names of the Finder Items passed to it:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFDDFF;
overflow: auto;"
title="this text can be pasted into an Automator 'Run AppleScript' action">
on run {input, parameters}
get a name from a file path
input: a list of Finder Items (aliases)
output: a list of names
set output to {}
repeat with AnItem in the input -- step through each item in the input
set {name:TheName, name extension:TheExtension} to (info for AnItem)
if TheExtension is missing value then set TheExtension to ""
set end of output to (text 1 thru -((count TheExtension) + 2) of TheName) -- just the name part
end repeat
return the output -- pass the result(s) to the next action
end run
</pre> -
Link style sheet to .html file?
Hey dreamweaver community i'm really new to dreamweaver but have a slight grasp.
But i am creating a website (ethicistbeats.com). I have a design by using a css. style sheet and everything looks good in dreamweaver safari preview (on a mac), but when i upload it to my ftp client my designs/ format of my page does not show up, at all.
If you guys could reply and try to help me out that would be cool. i tried talking to one pf my friends who took a class on html code, but he couldn't help me.
Anyways, thanks in advance.
If you guys need more info about code and stuff i'll gladly upload it. Just again i'm new to this so i don't really know much... i just dove into dreamweaver like a need a webpage, not much help, but my site wasmade from a template - not sure if that helps.
Peace.Unfortunatly, you have quite a mess on your hands. First you have embedded css above the external style sheets, which takes away one of the big advantages of embedded css, namely to override any rules in the external style sheet.
<style type="text/css">
.A {
color: #E12000;
.b {
color: #000;
</style>
But that is peanuts to the other probelms,
Your style sheets are not css files, they appear to be an html file. To create an external style sheet, go up to File | New | CSS and a new CSS blank file will be created. Paste your css rules into it.
You have
<link href="http://www.ethicistbeats.com.css" rel="stylesheet" type="text/css" />
While I suppose you could link using an absolute link, I dont see an advantage,
but it would be more like
<link href="http://www.ethicistbeats.com/stylesheet.css" rel="stylesheet" type="text/css" />
a better way would be
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
This is not a style sheet, but another html file.
<link href="Index.html.css" rel="stylesheet" type="text/css" />
Take whatever css is in the files and put them into a new css file.
Start there, but there is more work to do.
gary -
Record set file names not appearing ?
Could anyone tell me why the file names for the record sets that I'm creating don't show up. The "lightning bolts" representing the data show up under the rs name and it appears within the code, but the file names are not next to the bolts as expected ?
Thank you,
Fred...Hello PZ,
Thanks for jumping in and trying to help. Sorry for my ignorance when
it comes to this as I am just diving into the world of data bases
using php and mysql. I believe I was referring to the created "table
set name" and the "fields" within them (see bottom) . In the bindings
panel the lightning bolts appear under the created table set, but the
name of the table set is not appearing and these highlighted file
names "fields" that should be next the lightning bolts to identify
them are not appearing. These names , and so on
appear in the code but not in the bindings panel next to the lightning
bolts to help me identify which one I am choosing .
The php page is working the way I want but I have to go through the
process of elimination to figure out which "field" e.g
I'm choosing when placing them in a table in my dreamweaver page. I
hope I am explaining myself properly and thank you very much again for
your efforts.
Fred...
Here is the code I'm talking about and a picture of the database I'm
getting them from.
Year built
Floors
Address
Elevator
Doorman
Gym
Contact
Pets
Parking
Fireplace
Phone:
Email:
Description:
buildingID propName address neighborhood phone email floors do orman
elevator pets yearBuilt propPic inParking outParking fireplace
description gym
14 BC670 280 East 2nd Street Downtown 2125559876 [email protected]
6 0 0 0 1977 BC670.jpg 0 0 0 Located between Avenues C and D at
Houston Street ... 0 -
I'm looking for an action that will take files as input and output the file names as text. Does anyone know of an included or free action to do this?
Message was edited by: KatieS1975You can use AppleScript's text item delimiters to add some text between the (text) items when converting the input list to text:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run {input, parameters} -- convert the input list to text using the specified delimiter
try
set tempTID to AppleScript's text item delimiters -- save the current delimiter
set AppleScript's text item delimiters to return -- change the delimiting text as desired
set the output to the input as text
set AppleScript's text item delimiters to tempTID
on error errorMessage number errorNumber -- restore the original delimiter before passing on the error
set AppleScript's text item delimiters to tempTID
error errMessage number errorNumber
end try
return the output
end run
</pre> -
Hi,
On server side I read the (Pdf) file and then stream the file content thru response object so that this pdf file opens in browser using Adobe reader. This works just fine.
And right now, if user wants to save this file in browser, complete jsp url appears as file name in save as dialog box.
For eg.:
If my jsp has stream the pdf file from this url
http://www.xy.com/jsp/displayFileJsp?f=xyz.pdf
then
when user tries to save this file, browser save as dialog displays file name as "http://www.xy.com/jsp/displayFileJsp?f=xyz.pdf"
But I want user should download that file name with specific file name like xyz.pdf.
I tried to set the content type
response.setHeader("Content-Disposition", " filename=xyz.pdf" );
But it didn't work.
any suggestions ?
rki have created a zip file and i have to make it downloadable i.e. pop-up box should be invoked. my code is
try {
outFilename = "D:\\Product.zip";
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename));
for (int i=0; i<filenames.length; i++) {
FileInputStream in = new FileInputStream(filenames);
out.putNextEntry(new ZipEntry(filenames[i]));
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
out.closeEntry();
in.close();
out.close();
catch (IOException e)
e.printStackTrace();
String d1file = outFilename;
File f1 = new File (d1file);
response.setContentType ("text/plain");
response.setHeader("Content-Disposition", "attachment;filename=\"" + d1file + "\"");
try {
InputStream in = new FileInputStream(f1);
ServletOutputStream outs = response.getOutputStream();
int bit = 256;
while ((bit) >= 0)
bit = in.read();
outs.write(bit);
outs.flush();
outs.close();
in.close();
catch (IOException ioe)
ioe.printStackTrace(System.out);
it is creating zip file and placing it at D:\\ . I want to invoke download "Save As" pop up box, which is not appearing here! what should I do? -
Chain interfaces to set file name in sender channel dynamically
Hi,
I have a requirement to use the Seeburger SFTP adapter to import a file from an external server to an SAP ECC system.
The adapter must be Seeburger as the protocol has to be SFTP, not FTPS as with the File adapter.
Although I can set a wildcard selection, I really want to poll for specific filenames with predetermined naming criteria.
The sender SFTP communication channel doesn't provide any options to specify dynamic attributes but I wonder if I can link several interfaces together, please can you confirm if the following process would work conceptually:
1) SAP ECC program runs and determines the fixed filename that I wish to import (e.g. file_abc123.xml).
2) SAP ECC program calls an outbound proxy with a mapping to set the relevant parameter in dynamic configuration ('http://seeburger.com/xi' is the namepsace, 'dtSubject' is the parameter name for the filename of the SFTP adapter). Besides mapping I think the Seeburger attribute mapper module could also be used to set this value.
3) The outbound proxy is configured on the receiver side to call an SFTP sender channel (with a dummy/blank payload as we're only calling the interface to allow settng of the filename to take place) which links to an inbound service interface on the SAP ECC receiver side.
I don't know whether chaining of service interfaces in this fashion (receiving interface also being a sender) is a viable approach or whether there are any alternatives.
Thanks in advance,
AlanHi Alan,
Are the specific file names that you are polling for going to be changing or will they be fixed? Are each of the unique names going to be processed using the same interface? If so then I would just create multiple SFTP sender channels that poll at different intervals but use the same mappings, etc.
Regards,
Ryan Crosby -
How to set file name and destination folder without user interaction
how can I set the file name and destination folder to generate a pdf file like "c:\myfolder\document.pdf" in this folder automatically.
Is there a tag in .joboptions ?
Goal: User click print button. In the background a pdf will be generated in e.g. "C:\myfolder\document.pdf".
that`s it.
I know that the query dialog for save as can be turned off. But the file name depends on the application.
Thanks for your help.
TKHello,
Please post this in PI forums
Regards, Anil -
Using TCS 5, RH11, FM12, all patched up, if I set a marker, such as "Filename" in FrameMaker, can RoboHelp use the contents of that marker to set the file name of the HTML file it creates? How? Thoughts?
Cheers,
SeanHi,
Thanks for working with me on this. I appreciate your help. The last time I used RoboHelp was when Blue Sky owned it, at the original version 6. I see it has aged logically.
Cheers,
Sean -
Setting File Name inside ABAP mapping
Hello All,
We have a requirement where we need to send the IDOC in a flat file format to the destination system which we are doing inside an ABAP mapping. Now we need to set the file name depending on a particular field in the IDOC. For this we need to use the DynamicConfigurationKey class inside our ABAP mapping.
Can anyone throw some light how to access these Adapter-Specific Attributes inside ABAP mapping?
Thanks
Abinashguess this is the one
Re: Abap mapping and variable substitution in File adapter -
Need help in setting file name with special characters in attachment
Hi
We have a requirement where we need to set the file name that contains special characters (like Russian) and send mauil using Java mail.
If we set the file name as such, the attachment in the email contains garbled filename
Can you pl let me know how to resolve this?
We should use the file name as attachment name and this will have say special characters. The receiver who gets the mail should get with the correct attachment name
One important point.. the attachments are opened from MS outlook.
Thanks and regards
Ram
Edited by: 884910 on 13 Sep, 2011 5:00 AMRead the FAQ carefully. You don't need to call encodeText unless you're using a really
old version of JavaMail.
And, it depends on whether the mail reader you're using is handling encoded parameters
according to the (new) MIME standard, or according to the (old) non-standard hack.
Sadly, without knowing what mail reader the recipient is using, it's impossible to use
encoded filenames that will work everywhere. -
Setting file name for a downloaded file
I've set up a file download using code I've gleaned from jsf forums. However, the file name is not being set correctly. When the user downloads File.doc, it shows up as downloadPage.jsf. Am I setting the header correctly?
public class VendorInfoBean extends AbstractViewController {
public VendorInfoBean() {
public String downloadVendorApp() {
ExternalContext context = getExternalContext();
String path = context.getInitParameter("externalFiles");
String filename = "Vendor_Application_e_Form.doc";
String fullFileName = path + filename;
File file = new File(fullFileName);
HttpServletResponse response = (HttpServletResponse) context.getResponse();
response.setHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");
response.setContentLength((int) file.length());
response.setContentType("application/msword");
try {
FileInputStream in = new FileInputStream(file);
OutputStream out = response.getOutputStream();
// Copy the contents of the file to the output stream
byte[] buf = new byte[1024];
int count;
while ((count = in.read(buf)) >= 0) {
out.write(buf, 0, count);
in.close();
//out.write(bytes);
out.flush();
out.close();
FacesContext.getCurrentInstance().responseComplete();
} catch (IOException ex) {
ex.printStackTrace();
return null;
}StringBuffer sbFilename = new StringBuffer();
sbFilename.append("adeem");
sbFilename.append(".doc");
StringBuffer sbContentDispValue = new StringBuffer();
sbContentDispValue.append("attachment");
sbContentDispValue.append("; filename=");
sbContentDispValue.append(sbFilename);
HttpServletResponse response = (HttpServletResponse) context.getResponse();
response.setHeader("Content-Disposition", sbContentDispValue.toString());
i think this will work .. if not let me know i will give some code that will work for u then ... -
How to get set file name for MessageFileUploadBean in Advanced Table
Hello Everyone.
I have a MessageFileUpload item in a advanced table. My requirement is to show file names instead of view when user uploads files. I know how to do this if the item is not inside advancedtable (by using uploadBean.setAttributeValue(DOWNLOAD_FILE_NAME,displayNameBoundValue).
But how to get the different ID's when inside a advanced table?
Thanks
Sunnytry setting a transient view attribute to this message file upload, if you iterate through vo, I hope you can just get the path user browses.
Regards
Shobht S -
How to set file name in a JFileChooser to be some default String?
Dear all,
I am tring to make my JFileChooser more user-friendly, so every time that a JFileChooser show up, I would like to fill the file name with some default String, instead of just leaving them blank.
Does anybody know how to do this?
Many Thanks!look up the set...() methods of the JFileChooser api docs
-
I'm trying to write a script to rename all of the files in a folder using regular expressions. I can tell when I run it that I am correctly changing the names of the files the way I want; the problem comes when I try to set the name. I get this error:
error "Finder got an error: Can’t set file \"[first file]\" to \"[new name]\"." number -10006 from file "[first file]"
I've tried looking on over a dozen forums and tutorial sites, and as far as I can tell, I'm doing the right thing! Can someone please help?
tell application "Finder"
set f to "Example:"
set fileNames to name of files of folder f
end tell
repeat with aFile in fileNames
tell application "System Events"
considering case
set episode to aFile
set episode to my switchText(episode, "[", "- ")
set episode to my switchText(episode, "]", " -")
set episode to my switchText(episode, "x0", "0")
set episode to my switchText(episode, "x1", "1")
set episode to my switchText(episode, "x2", "2")
end considering
end tell
tell application "Finder"
set fileName to (a reference to file aFile)
set name of fileName to episode <<------------------error
end tell
end repeat
to switchText(theText, SearchString, ReplaceString)
set OldDelims to AppleScript's AppleScript's text item delimiters
set AppleScript's AppleScript's text item delimiters to SearchString
set newText to text items of theText
set AppleScript's AppleScript's text item delimiters to ReplaceString
set newText to newText as text
set AppleScript's AppleScript's text item delimiters to OldDelims
return newText
end switchTextTry replacing
tell application "Finder"
set fileName to (a reference to file aFile)
set name of fileName to episode
end tell
with
tell application "Finder"
set name of file aFile of folder f to episode
end tell
Maybe you are looking for
-
Installation problem with SolMan on SUSE 9,0 / Oracle
Hi Experts, I have just started to work with SAP environment. My first challenge is to install Solution Manager on SUSE 9.0 Linux. I have faced quite lot of error messages and managed to solve them with help of support and forum pages. But the last m
-
How to get message status in addapter engine
Hello. I have a need to return to a client's request, the status of messages in the adapter engine(i.e. if failed in the jms or jdbc adapters). I would like to know if there is a STANDART way (i.e. RFC function or some kind of web service) to perform
-
How to determine allowed names?
Using Labview and an IVI-COM driver to talk to an oscilloscope. How can I determine the allowed names that I can use?
-
Intel Wireless Display not installing on W530
I noticed recently that Intel Wireless Display (WiDi) was not installed on my W530, despite my recollection of installing it via Lenovo Update. So I tried downloading the latest version both from Lenovo (3.5) and directly from Intel (4.0), but neith
-
How do I get full sleep mode back in Mavericks?
With the release of Mavericks full sleep has vanished. All "sleep" does now is turn the monitor(s) off. The external hard drive remains powered up, the external USB sound card's activity light remains on, the fan continues to blow hot air indicating