Opening PDF's while specifying dimensions for convert (jsx)

Dear people who know a lot about scripting =),
I recently wrote a small javascript file that opens a dialog that lets me browse for a folder and subsequently open all the .pdf files that are in that folder. I use a script because the documents need to be resized and opened to a maximum width of 1024 px while the height stays below or is equal to 768 px at a resolution of 150. After the script I then usually slightly edit the document and save them as JPEG/PNG.
Since PDFOpenOption no longer allows (CS3+) to specify height/width I cheated a bit. Though this cheat makes the script almost as slow as doing it by hand (e.g. File >> Open, and then set width x height by hand).
The cheat is that I;
1. open the (single page, single image) PDF as a smart object (which adds 'as a Smart Object' the document name)
open(fileList[i], pdfOpenOptions, true)
2. conditionally resize it
     if (
                    (docRef.height < docRef.width) && //based on width or height
                    ( (refWidth/docRef.width)*docRef.height<refHeight ) //make sure that when resizing on width the maximum of refHeight is not overshot
//base on width
                              docRef.resizeImage(refWidth,null,null,ResampleMethod.BICUBIC);
//etc...
3. rasterize the Smart Object layer
docRef.rasterizeAllLayers();
4. duplicate the document, to a new document while omitting the 'as a Smart Object' (No other way to rename the document).
     docRef.duplicate(fileList[i].name);
5. close the original import document
     docRef.close(SaveOptions.DONOTSAVECHANGES);
                              docRef = null;  
All because I can't find out how to set (or retreive) height/width when importing a PDF file.
I'm using Photoshop CS 3 and I was wondering if someone would be as kind to help me adjust the script and speed things up. Hope it's not that complex...
Kind regards,
Chris

You can also use scriptlistener to create an openPDF function that will allow you to specify the dimensions in pixels. Something like this...
function ftn1(docName, ppi, w, h, file) {
  function cTID(s) { return app.charIDToTypeID(s); };
  function sTID(s) { return app.stringIDToTypeID(s); };
    var desc11 = new ActionDescriptor();
        var desc12 = new ActionDescriptor();
        desc12.putString( charIDToTypeID('Nm  '), docName);
        desc12.putEnumerated( charIDToTypeID('Crop'), stringIDToTypeID('cropTo'), stringIDToTypeID('boundingBox') );
        desc12.putUnitDouble( charIDToTypeID('Rslt'), charIDToTypeID('#Rsl'), ppi );
        desc12.putEnumerated( charIDToTypeID('Md  '), charIDToTypeID('ClrS'), charIDToTypeID('RGBC') );
        desc12.putInteger( charIDToTypeID('Dpth'), 8 );
        desc12.putBoolean( charIDToTypeID('AntA'), true );
        desc12.putUnitDouble( charIDToTypeID('Wdth'), charIDToTypeID('#Pxl'), w );
        desc12.putUnitDouble( charIDToTypeID('Hght'), charIDToTypeID('#Pxl'), h );
        desc12.putBoolean( charIDToTypeID('CnsP'), true );
        desc12.putBoolean( stringIDToTypeID('suppressWarnings'), false );
        desc12.putEnumerated( charIDToTypeID('fsel'), stringIDToTypeID('pdfSelection'), stringIDToTypeID('page') );
        desc12.putInteger( charIDToTypeID('PgNm'), 1 );
    desc11.putObject( charIDToTypeID('As  '), charIDToTypeID('PDFG'), desc12 );
    desc11.putPath( charIDToTypeID('null'), file );
    executeAction( charIDToTypeID('Opn '), desc11, DialogModes.NO );
ftn1('docName', 300, 771, 690, new File( "~/Desktop/BlueMirror_HowTo.pdf" ));
Note that because 'Cnsp'( constrain proportions ) is true the w and h arguments work similar to fit image. That is in the example pdf in the code above because of the proportions of the pdf 771 sets with h to 604 instead of the supplied 690. With h set to 590 the w value is changed to 753. You can change 'Cnsp' to false and force the dimensions but that may distort the image.
Also Photoshop will add '-1' to the docName argument so in the example above the doc name is 'docName-1'. It is also set to boundingBox. Use scriptlistener to find the stringIDs for the other crop types.

Similar Messages

  • Error in LSMW while specifying file for Material Cassification and Info Rec

    Hi Friends,
    I'm getting an error in LSMW while specifying file for Material Cassification and Info Record using batch input method.
    The error message i'm getting is:
    "Length of physical file name 'R2R_33_PURCH_INFR_1_PIR_CREATE.lsmw.conv' cannot be longer than 30 characters
    Message no. /SAPDMC/LSMW_OBJ_060049"
    I tried changing the file name but that is not working out. Please help.
    Thanks,
    Amit

    Hi,
    Just try this,
    Go to LSMW, Specify file option, use display/change (Ctrl+F1)
    Select the converted data and double click, change the file name there,
    You will be getting it as "'R2R_33_PURCH_INFR_1_PIR_CREATE"
    Just trim this to "'R2R_33_PUR_INF_1_PIR_CRE"  and try...
    Regards
    Merwyn

  • Cannot open pdf files while the Reader instance is running

    Today I suddenly noticed that if I try to open pdf file while the Reader instance is already running (even if it has no pdf files open), the cursor just blinks one or two times without any further activities. So the only way to open files now is by closing the previous instance and starting the new one. I think this problem started to appear after upgrading to 11.0.3. I am using Windows 7 32 bit.

    I narrowed the problem: it happens if the file is in a directory which is a join point on the NTFS file system (i.e. a link to another directory), where the link source is in turn a join point itself (i.e. we have a two-level NTFS directory link). As this is rare, it could be not a problem of the particular version of the Reader, it just probably happened by coincidence that after upgrading the first directory I accessed was of this kind.

  • I cannot open pdf file while browsing on my galaxy tab 10.1, I must download fisrt, why?

    I am wanting to view pdf files while I am browsing on my galaxy tab 10.1. The browser will not open the pdf. I always get the download screen asking what to name the file and where to put it.

    Adobe does not have a pdf plugin for Android. All pdf files will need to be saved and opened with a pdf reader external to the browser.

  • Error while enabling dimension for OLAP API and BI Beans

    Hi, I've created some dimensions in OLAP Catalog using CWM2 packages. These dimensions have only one hierarchy and one or two levels.
    I also have an Analytic Workspace, and I've created these dimensions in this A.W. using CREATE_AWDIMENSION method from DBMS_AWM package.
    Everything ok at this point.
    Next, I've tried to enable these aw dimensions for the OLAP Api and BI Beans, using CREATE_AWDIMENSION_ACCESS_FULL/CREATE_AWDIMENSION_access methods from DBMS_AWM. Strangely, dimensions whith two levels are enabled ok, but dimensions with only one level can't be enabled. If I use CREATE_AWDIMENSION_ACCESS and I execute generated script, an error appears when trying VALIDATE_DIMENSION, with a text like this:
    .ENTITY TYPE ENTITY NAME STATUS COMMENT
    . Dimension AW1.DIM1      INVALID ERROR: Component entity.
    - Default Display Hierarchy: "J0".
    . Hierarchy J0 INVALID ERROR: Hierarchy Top Level not found.
    My database ir 9.2.0.6. What is failing ? Some idea ? Thanks by your help.

    Not sure if it's valid to have a dimension with 1 hierarchy and 1 level in that hierarchy. The hierarchy may have to have at least 2 levels. If you want the configuration of a dimension with 1 hierarchy and 1 level, CWM2 may want you to omit the hierarchy, thus creating the dimension with only 1 level.

  • PDF problem while using Safari for e-mail

    I'm not sure where to put this question, so it ended up here.
    Sometimes I receive a PDF file as an attachment to e-mail. I save it on the desktop and click it to open it. What happens is that for some reason "TextEdit" automatically tries to open it, with the result that all I get is a bunch of code--not the translated contents of the file at all.
    Why doesn't it automatically open it in Acrobat Reader? That's what happens when I open a PDF file I download from the internet. I can't figure out any way to connect attached e-mail files to Acrobat Reader so it will open them translated. My MacLlinkPlus translator doesn't recognize PDF files as needing to be translated.

    I woudl need to see the form and data file to debug this ...can you send the assets to [email protected]? Please include a description of the issue you are facing with your email.
    Paul

  • Open pdf from an Air application for Android

    Hi at all,
    i'm developing an AIR Application for Android devices.
    Into the app there is a button which should open a pdf file with the default pdf reader (multitasking), but doesn't work!
    I've an Android Emulator (2.2).
    This is the code
    protected function openClickHandler():void
            f.openWithDefaultApplication();
    f is a File object which points to pdf into the storage folder.
    Any suggest! Help!!
    Thanks.
    F.

    Specific use cases from developers is one way Adobe prioritizes feature development. That's why whenever you request a feature, the response will often include a request for a use case -- even if the use of the feature seems self-evident. Your use case could add more value to a potential feature beyond the self-evident.
    Thanks!

  • How [Insert|Add] Image into Opening PDF file with Acrobat SDK.

    Hi Guys,
    I'm trying to insert|add image file into opening PDF file with specified location (X|Y) and scale (Width|Hight) but got many of troubles
    If use third party like iTextSharp or something else thing become simple but i want to use Acrobat SDK to do this
    Any suggestion or idea?
    Any help appreciated.

    Thank for your interested.
    I use VB.NET and Acrobat
    Here is some my code:
    Try
       If File.Exists(T(0)) Then
       Dim AcroAVDoc As AcroAVDoc = Ap.GetActiveDoc
       Dim AcroPDDoc As AcroPDDoc = AcroAVDoc.GetPDDoc
       Dim AcroPDPage As Acrobat.AcroPDPage = AcroPDDoc.AcquirePage(Integer.Parse(T(3)))
       Dim data() As String = T(1).Split("^")
       Dim imgX = data(0)
       Dim imgY = data(1)
       Dim imgWidth = data(3)
       Dim imgHight = data(4)
       'TODO: insert into opening PDF file
       Return 1
       End If
       Catch ex As Exception
       End Try
    I don not know what to do next to insert an image (JPEG, PNG, ..) into PDF file.
    Can you show me or suggest some solution, idea?
    Thank in advance.

  • I cannot open PDF files when I am using Firefox, how can I fix this?

    I cannot open PDF files while I am using Firefox. This is true for opening PDF pages in Firefox and outside of Firefox.

    I ran into the same problem, and here is what I have done to fix it.
    Go to Tools/Add-ons
    You might have to get the latest Adobe Acrobat Reader (Likely 10.x.....)
    On any exiting Adobe Acrobat Reader select disable (to disable the plug-in)
    If you have already gotten the latest Adobe Acrobat Reader just disable any earlier version.
    There is no official way to uninstall a plug-in so this it the workaround.
    If you do need to uninstall the plugin you need to type about:config ....about:plugins search for the article to do it.

  • Need a password to open pdf

    I downloaded Reader X on my Windows XP and now when I open PDF files Reader is asking for a password. I've tried all known passwords I've used on Adobe and nothing works. Talked to an Adobe tech and he doesn't know why it's asking for a password to open file. Adobe never asked for a password before to open pdf files. Help

    What is the exact message you get?
    I've never heard of it asking for a password either unless one is required for the actual PDF itself.

  • How can I open pdf attachments in email? Adobe reader used to do this, and does not.

    About 3 weeks ago, I suddenly could not open pdf attahments while reading my email. I now must down load them and save, in order to open them. Can someone help me to fix this? They open on my desk top, but not in Internet explorer. I would like to see them before down loading. What can I do to fix this problem?

    Enable the Adobe Reader plugin in browser : http://helpx.adobe.com/acrobat/kb/pdf-browser-plugin-configuration.html
    Thanks
    Wasil

  • I have an iMac and cannot open PDF files in Firefox now. How do I fix this please?

    I have an iMac and cannot open PDF files while working in my university site in Firefox now. How do I fix this please?

    I have a similar problem - not mac related and sometimes I find if I download the pdf file I can open it then.

  • Open PDF in a specific location

    I want to open a PDF file from a chm file generated in RoboHELP in a specific location.

    Timothy,
    Plz read the thread on named destinations,
    Gloria Mc, "Linking to within a PDF using named destinations" #1, 24 Aug 2007 1:08 pm. This thread contains info on how to create named destinations in your PDF file, and then link to them with a hyperlink (or from a command line). Also various issues w/named destinations are discussed.
    You don't say what version of software you have; that would be helpful, as named destinations work in some versions and not others. Also operating system that this will be expected to work on would be good to know.
    In addition to the forum thread, read one of the documents "Parameters for Opening PDF Files." The one for 8.1 is located at http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf.
    If you have the correct version of Acrobat, the PDF is on a Web server, and the issues in the forum thread are addressed, you should be able to include a hyperlink to the PDF in your .chm file (which resides on someone's computer, not the Web server).
    HTH. --GMc

  • Unable to open PDFs in received e-mail (Outlook)?

    Unable to open PDFs received in Outlook (Office for Mac 2011).  Adobe XI message displayed says "There was an error opening this document. The file is damaged and could not be repaired."  Same PDFs attached to same mail messages open fine on iPad or iPhone. What could be the problem?

    ivone dos santos,
    Do you see a message like this when you open one of your PDF documents?
    Your PDF document is a special type of form called a "dynamic XFA form".  The message is displayed when a dynamic content is not supported by a PDF viewer.
    As far as I know, no PDF viewers for iOS and Android mobile devices support dynamic XFA forms.  Here are the examples of the iOS apps that do not support dynamic XFA forms.
    Adobe Reader for iOS
    Mail
    Safari
    iBooks
    The PDF preview feature in Dropbox and other apps
    The message is trying to tell you to use the latest desktop version of Adobe Reader, not the mobile version of Adobe Reader.  I agree that the sentence, "You can upgrade to the latest version of Adobe Reader...", is somewhat misleading.  The message is baked into the dynamic XFA form that was authored by Adobe LiveCycle (desktop app) without regard for non-desktop apps (i.e. mobile apps).  Upgrading to the latest version of Adobe Reader for iOS would not help in this case.
    Currently, the only option to view and fill out dynamic XFA forms is to use the desktop version of Adobe Reader.
    Sorry for the confusion.

  • Why AAReader  does not open PDF with bitmap img

    good evening
    Do you know why Adobe Acrobat Reader (Android2.3.4 Nexus S)
    does not open  PDF containing bitmap image ?
    For example, I cannot read this file http://driveinx.free.fr/image.pdf
    thank you in advance for your help
    Best regards
    Benoit

    Hello,
    thanks
    I am available if needed,
    I only have this type of PDF and I wish you to do
    Br

Maybe you are looking for