InDesign Script for importing idml to indd document - adobe-indesign

I am using InDesign Server and a soap based application to communicate through the server.
I am able to get all fields of form used in indd document and also able to replace its text/value.
Now, I am looking to get all images used in indd doc and provide upload images options at my application and able to replace the images by user selected images. Can anyone provide script for identify and replace the images.
Secondly, for backward compatibility I have idml of an indd doc. Now how to import or open this idml and convert it to indd doc through script.
Thirdly, how to convert pdf into indd doc.
Please help me with these scripts.

To an IDML file into an .indd file, simply open it and save it
set theIDMLFile to "Macintosh HD:Users:me:Desktop:someidmlfile.idml"
tell application "InDesignServer"
set convertedIDMLDoc to open alias theIDMLFile
tell convertedIDMLDoc
save to ((characters 1 thru -6 of theIDMLFile) & ".indd") as string
end tell
end tell

Related

Applescript: pdf to pptx conversion

I'm trying to convert pdf to pptx invoking adobe acrobat using AppleScript.
Below code executes fine without any error but there isn't any output created.
--somecode--
save active doc to filePath using conversion "com.adobe.acrobat.pptx"
conversion using text class works fine.
save active doc to filePath using conversion "com.adobe.acrobat.plain-text"
I found this on adobe forum, and it remained unresolved(pdf to html).
https://community.adobe.com/t5/acrobat-sdk/pdf-to-html-conversion-with-interapplication-communication-api-in-mac-os/td-p/9294002
Just to add I'm using adobe acrobat pro dc trial version.
Thanks
I was able to make it work. Used AppleScript to invoke adobe javascript.
Going through posts in various forums, found a user following the same approach for rtf documents.
set myScript to "this.saveAs(\""& output_file_path && "\", \"com.adobe.acrobat.pptx\");"
do script myScript
instead of
save active doc to filePath using conversion "com.adobe.acrobat.pptx"

Original filetype of ashx file

I'm building a PHP application that uses data from a web service. I add an image to a desktop application which then saves it to the web. The web service provides image URLs using the .ashx file extension. If I put one of these in an <img src="file.ashx?pictureId=abc123">, it displays as an image.
I want to store these images. I know they'll generally be .jpg files and can run file_get_contents on this and save it as such. However, if one was a .png, for example, I'd still be saving it with a .jpg extension, so it's an assumption I don't wish to make.
I've had a look at the raw string of characters of the file and cannot see any identifying features to tell me that it's a .jpg, apart from perhaps the clue that it was created in Photoshop. Nowhere does it say what kind of file it was originally, either extension or original filename.
Is there a way of finding the original filetype of a file contained within .ashx URL?
The question doesn't make any sense. Maybe the .ashx script generates the image on the fly out of nothing and there is no "original".
The correct question is: how to find the type of the image retrieved from the .ashx URL?
Save the image into a (temporary) file then use getimagesize() to find its type (GIF, JPEG, PNG etc) and choose the correct termination for its final file name.

How to print a file in cocoa application depending upon its mime type?

I am working on file manager. I have stored their local urls in my core data. I have file and folder, but I want to print png, jpeg, docx and pdf from my application.
Let's suppose I have a print button in my application and every file, how can I print that?
use launch services LSOpenFromURLSpec as described in the reference. pass kLSLaunchAndPrint as launch option in the specs array.

Batch convert Mac iWork files to PDF on the command line

I'm trying to batch convert a bunch of assorted iWork files (Numbers, Pages, Keynote) to PDF on the command line.
I've been trying cups-filter but there's no MIME type filter for the iWork types. I then looked into using qlmanage to generate the preview image and use that, but this doesn't seem to work for multi file Keynote documents as they generate as HTML rather than PDF.
Any suggestions? I'd rather not resort to AppleScript.
I created an .applescript script that converts all .pages files within a folder to .docx. .pdf support can be easily added. In pages2docx.applescript you just need to replace Microsoft Word with PDF.
Here's what I ended up going with, since I really wanted to avoid, AppleScript.
When saving an iWork document there's a "Include Preview In Document" checkbox. Checking this creates a "QuickLook/Preview.pdf" inside the iWork document bundle (which is actually a zip file). Luckily I had this checked for most of the zip files, so it was simply a case of unzipping to NSTemporaryDirectory and grabbing that file.
For those that didn't I put together a script to run qlmanage to create the document preview. For some that creates the PDF, for others it creates an HTML file. You can then use http://code.google.com/p/wkhtmltopdf/ to convert this HTML to a PDF.
Well... you need something that
understand the iWork file formats,
can render the documents to then create the PDF.
Unless you want to re-invent the iWork suite... Sounds simpler to just tell the iWork apps what you want from them.
You would do that via the Scripting Bridge
I would use Applescript, but perhaps you can use Ruby and Python with the Scripting Bridge to accomplish what you need
With Scripting Bridge, RubyCocoa and PyObjC scripts can do what AppleScript scripts can do: control scriptable applications and exchange data with them.
I haven't used the Scripting Bridge in a while, but I believe you can tell applications to print documents. And any application that can print in OS X can send it to PDF instead.
Here are a couple of commands to help those who want to get this working without much thought. It worked for me with a ppt file.
Make sure to get wkhtmltopdf from here.
qlmanage -p -o /tmp /path/of/file.ppt
wkhtmltopdf /tmp/file.ppt.qlpreview/Preview.html /output/to/file.pdf
You may have to fiddle with sizes if you want the original pages to stay consistent, for the ppt I was using the following parameters did the job:
wkhtmltopdf --page-width 200 --page-height 145 Preview.html file.pdf
Edit: I have written a Python script to do a batch conversion. Hopefully people can contribute to make it more robust:
https://github.com/matthewfitch23/DocToPdf

Convert indesign output to html5

I want to write a viewer that convert in-design output format to html5 format and all the user design in adobe indesign can display in browser but i do not know which output is suitable for me, i think i can retrieve all info about the adobe indesign in idml export,but the problem is parsing such XML and display the tags in html5 format,i want to know is it possible the simple way to convert the output format into html5?
is it possible to download the adobe indesign SDK and use its method to this purpose?
You can use in5 to export HTML5 (layout intact) from InDesign.
Full disclosure: I am the creator of in5.
Exporting to EPUB would result in XHTML 1.1. The Epub file that InDesign generates is a zip file, in which you will find a number of files. (At least) one of them is an XHTML file.
XHTML 1.1 would surely be an easier source to use than the idml, however you will have to make sure that the ePub export is good enough to start with (the pages won't come out exactly the same as in InDesign).
Would that be a solution?
EPub export is supported from InDesign CS4 (JavaScript based export option, outside the object model, as I understand it and a built-in export option, part of the object model, from CS5).
You don't mention what version of InDesign you are using. CS5, CS5.5 and CS6 all allow you to export to HTML. The problem is that the HTML is version 4 and it create badly written CSS. What I like to do is to use XML to build my own HTML. Just create a set of HTML5 tags you want to use and then Map the existing Paragraph and Character styles to the XML tags.
When you're done you will have a basic content structure. Then I use the Structure pane to add different elements as needed. You can add Parents or children as you need to right there and then export to XML. When you save the file, just change its name to .HTML and edit the code to remove the one reference to "xml".
It takes a little time, but it is very doable.

Resources