A working method to load local PDF and HTML files on iOS

I had a lot of trouble getting this to work, and I'm hoping this post saves someone time. Some of the information that's been posted in other locations is either wrong, incomplete, or might only work on Android. By the time you read this message the information here may no longer be accurate, so here's the testing environment:
Window 7
Flash CS 5.5.0
AIR 2.7.0.19530, which was compiled on June 28, 2011
iPad 1, version 4.3.5 of iOS
Let's get started.
On iOS, you load external PDF and HTML files using the StageWebView class.
On Windows, StageWebView works but the HTMLLoader class is a better choice if you're creating a desktop app.
You can also load HTML files by reading in the file's text. The information in this post is only for loading external HTML files.
StageWebView will not load a file that's in File.applicationDirectory. All files bundled in your app are placed in File.applicationDirectory, which means you'll have to copy any external file you wish to load with StageWebView to another directory.
So where can you copy your file? File.applicationStorageDirectory won't work. File.documentsDirectory does work.
Several people have recommended copying to a temporary file using File.createTempFile(). This works, but there's a catch: it seems that, like Windows, StageWebView relies on a file's extension when determining how to load it. When you create a temporary file on iOS using File.createTempFile(), the file will have no extension (and on Windows, File.createTempFile() creates a file with the extension .tmp, which is equally problematic).
The solution to the file extension problem is to rename the temporary file by appending the original file's extension. AIR currently does not have a <file>.rename() function, so you'll have to do it using <tempFile>.moveTo().
Here's some code I've successfully tested several times on both iOS and Windows. The file is copied to the temp directory. The file's extension is restored by just slapping the original file name to the end of the temp file.
        private function loadExternalFile():void
            var webView = new StageWebView();
            webView.stage = this.stage;
            webView.viewPort = new Rectangle( 0, 0, 1024, 555 );
            // Works with either html or pdf files.
            // These are stored in the root of the application directory.
            var fileName:String = "euei.pdf";
            //var fileName:String = "euei.htm";
            var sourceFile = File.applicationDirectory.resolvePath( fileName );
            var workingFile = File.createTempFile();
            try
                sourceFile.copyTo( workingFile, true );
                // You have to rename the temp file
                var renamedTempFile:File = workingFile.resolvePath(workingFile.nativePath + fileName);
                workingFile.moveTo(renamedTempFile, true);
                webView.loadURL( renamedTempFile.url );
            catch (err:Error) { }

I tried this with Flash CS5.5 and AIR 4.0 SDK. Any pdf loaded simply fills the viewPort with black. Also tested with a png version of the pdf and that displayed just fine.
What's the purpose of copying to a temp work file? I found that webView.loadURL( sourceFile.url ); gave me the exact same results.
Any ideas?
Thanks!

Similar Messages

  • How to read data from PDF and HTML  file

    I have got solution to read text form .txt file but did'nt get code for PDF and HTML.
    I dont want to convert PDF to txt.
    Please help me ...

    ah crap i could have guessed there would be a crosspost only the forum in where the crosspost is made is abit funny
    To OP: DO NOT CROSSPOST
    http://forum.java.sun.com/thread.jspa?threadID=5267875&tstart=0

  • Attach .pdf and .doc files to Reply emails.

    I am desperately trying to figure out how to attach .pdf and .doc files to Reply emails in the Mail app. I have downloaded GoodReader, but when I go into "Manage Files" and choose "Open in...", Mail is not one of the apps listed for me to choose from (only Quickoffice and iBooks are listed, that's it). My Gmail account is pushed to the Mail app, if that's relevant at all.
    I'm hoping to be able to attach documents to Reply emails in the Mail app, but if I have to do it using my web-based email, that's better than nothing. I just really need to be able to attach them to Replies, and not compose a new email from scratch.
    I'd REALLY appreciate any help with this!
    Thanks.

    I thought I might be able to figure out a clever work-around by using cut and paste from a new message but this did not work as expected. I have been using the MobileMe iDisk app to store pdf files and then just mailing out the links.  I believe my cut and paste method would have worked with this, however I've got about a year now to figure out another way to do this if it is not included in Apple's new cloud service. This has actually been a better as I need to worry less about file size and don't need to have the files stored on the device.
    You may want to look into what on-line file storage solutions are out there and if they have the ability to send links to files to colleagues, possibly with password protection.

  • Pdf and epub files

    I loaded pdf and epub files from my local library and dragged and dropped into itunes and then sync'd. The issue is that the epub book won't open in ibooks and the pdf's are blank. Can someone help. Just got the ipad and not sure if I've missed a step.

    Electronic material from the library usually has DRM and isn't compatible with the iPad yet.

  • Performance, minimum bandwidth, thumbnail previews for PDF and InDesign Files with web content viewer

    Hi,
    We are considering using DPS with a web content viewer for large PDFs and/or InDesign files. The client using a web viewer might have very limited bandwidth (some as low as 256Kbps). We ask:
    1 - How well does the web viewer perform with very large PDFs and InDesign files  (500 MB+) with limited bandwidth? Does the file stream in chunks and the PDF shows as soon as the first page or two are available, with the rest loading in the background, or does the entire file come down in one part and then shown?
    2 - Can PDF and InDesign files support thumbnail previews? For example, one image per PDF page and user can scroll forward and back.
    Your thoughts and comments are greatly appreciated.
    Thanks!
    -Stephen

    Hi Stephen,
    The way the web viewer works is that it converts the PDF/InDesign files to PNGs along with additional HTML assets. Assets are downloaded as they’re ready for a given page (e.g. first, page 1 is filled with its assets as they become available, then page 2, etc), so a reader wouldn’t need to wait for the entire article to load. The next few pages are also loaded in the background, so the reader wouldn’t be likely to notice lag as they flipped through pages to the next page after reading the current one. So the lag will depend on the size of an individual page.
    For your question around thumbnails, the web viewer does not load a preview image so the reader would need to wait for the assets I described above to load.
    Hope this helps...
    Brian

  • Saving report as PDF and text file

    Currently, I saved my report as PDF. It opens in Acrobat reader automatically when the report is executed. Is there a way for me to save it as PDF and as a text file at the same time? (without having to open the file in Acrobat reader and saving it)

    You can add your PDF and TEXT file formats to a distribution list (Instead of GENERATE REPORT TO A FILE). To do this:
    1. Go to your Object Navigator and highlight your report.
    2. Right click on your report. Select Property Palette.
    3. Select Distribution
    4. You can add of of the formats that you want to print or save to the report to.
    5. You will have to add Distribution Id (any number starting with 1) where you want the file to be saved (c:\my_reports\inventory.pdf), the type of file: PDF and how many copies you want: 2
    6. Click OK after finishing...
    To make it work ... You would highlight your report from your Object Navigator and then choose FILE-DISTRIBUTE and this will save it to all the files your specified and/or printer.
    null

  • Generate pdf and html(urgent)

    can anybody tell how to generate pdf and html from a single report,
    thanks in adv

    From a single report, you can generate outputs to html, htmlcss, pdf, rtf, XML and text formats.
    If you use rwclient, rwrun or rwservlet methods, specify desformat=pdf/html and the destination file name in desname command line parameters.
    If you use Reports Builder, open a report, select File->Generate to file and select html/pdf. Then give the file name.
    For more details, Refer to Reports Tutorial / Publishing Reports document from this site.
    http://otn.oracle.com/docs/products/reports/content.html
    Thanks,
    The Oracle Reports team

  • Pdf and vector files will not open in Adobe Illustrator after Yosemite Update

    I updated my OS on recommendation from apple. Pdf and vector files will not open in adobe illustrator now. Am i using the latest OS?

    Linda Feltner wrote:
    > I cannot import or open vector files in Freehand 10. I
    just get large
    > Xs instead of the image. I have a MAC OS 10.3.9,
    Freehand 10. I'm
    > trying to import some small files that are either .ai or
    .eps files
    > (all are vector) that open fine in Illustrator 10 (so I
    know they
    > work), but I can't use them in that program. I've tried
    adjusting in
    > Freehand Preferences the 'convert editable EPS files" ,
    on and off. I
    > tried adjusting the 'Embed...." selection on and off.
    Can anyone tell
    > me what thing I'm doing wrong. I have two files, they
    are map
    > boundaries, that need to scale and adjust their color
    and line width
    > over an aerial map. This can't be difficult, but I must
    be
    > overlooking something. Many thanks in advance. Linda
    >
    Freehand can't convert EPS files into editable vectors. I
    usually run
    EPS files through Illustrator and then into Frehand. If you
    don't have
    Illustrator you can convert the EPS into a PDF and that
    Freehand will
    sometimes convert into editable vectors (though it does
    involve a lot
    more clean up than going through Illustrator.)

  • PDFs and Word Files open on iMac but not Macbook Pro

    I own an iMac and a MacBook Pro. Recently, I've been having an issue with some PDFs and Word files that have been emailed to me from different contacts. All open—and can be seen using Quick Look—on the iMac. However, on the MacBook Pro it's a different story. When I try Quick Look all I see are the icons. When I try to open the PDFs in Preview (default app for me) I get an error message saying the file could not be opened and might be damaged. When I try to open the Word doc in Word, Pages or Bean I see all of the extraneous header information etc and the text is all mixed up in that formatting junk. I have repaired permissions, cleared out my user cache, restarted—pretty much everything I can think of. But no luck. Thought?

    Brilliant suggestion! I checked all the display settings on my iMac 27" and confirmed they were the same settings as my MacBook -- until I checked the Window 7 screen resolution. Because of its size, I had expanded the screen across most of the monitor. When I changed the resolution to one suggested or configured by Windows, Approach worked fine. I've now tested it on quite a few of the settings, and as long as I let Windows determine the best resolution (on my iMac 27" it seems to be 2043 x 1276), Approach works like it should. Thank you!

  • Where does workspace store the pdf and excel file ?

    Hi,
    I'm working on a Web Analysis project and I have created a dynamic web menu based on the workspace repository to improve the poor capacities of WA in terms of menu. I use the javascript API to control the WA applet from the menu.
    Now my problem is that my customer created a folder in workspace (which is translated into a sub menu of my dynamic menu), and that folder contains pdf and excel files. The function openFile which I use to open report in the applet doesn't work on pdf and excel files. So I've been looking for the files on the server, to know where they are stored, so that I could just modify the java class that generates the menu.
    I couldn't find those files on the server. Where are they ? Are they stored in the database as an xml string like the report s ? If yes then I might have a problem.
    Has anyone already done this ?
    Thanks for your help.
    Cyril

    Tomcat stores it in the work dir under $TOMCAT_HOME.
    There'll be directories like localhost%2f<urcontext>..
    As for as JSP changes being recognized, try refreshing ur browser....

  • Import .pdf and ai file in indesign cc

    Hi,
    I'd like to know if there's a way to import pdf and ai files in indesign cc 2014?
    Thanks

    If you're asking how to use a PDF or ai as a graphic in InDesign, File>Place is what you want. If you're asking how to manipulate the elements of a PDF or ai after it has been placed in InDesign, that's not how it works, although you can turn layers on or off in a placed ai file if you go to Object>Object Layer Options.

  • How do I generate PDF and CHM files from the a command line in windows?

    I am trying to set up a PC to build some documents during the night. I was looking for a way to get framemaker to generate PDF and CHM files via a command line in windows? How is this done with FrameMaker 12
    Thanks for the help
    Alex

    Hi,
    The part with generate a PDF via a jsx seems to work OK, except when FrameMaker decides that it will not work anymore. I must say I am not impressed with the stabillity of FrameMaker 12, there is room for a lot of improvement!.
    I have given up on how to figure out how to get FrameMaker 12 to generate chm files via jsx scripts, any pointes are still very welcome.
    The route I have taken is I make a RoboHelp project for each chm files I need to generate. The only thing this RoboHelp project contains is a link to the actual FrameMaker project I want to generate a chm file.
    To make the chm I start RoboHelp with a script that
    1) Opens the desired project
    2) Sets the desired output chm files name
    3) Generates the chm file
    4) And finally quits RoboHelp
    Below is a copy of the jsx in case anyone can reuse anything.  And yes parameters are transfered via enviroments variable. I have later learned there is some way to read the parameters given at a command line but this seems to work so I stick to this for now.
    // Get parameters
    var RhProjName = $.getenv("RH_PROJ_NAME");
    var RhChmName = $.getenv("RH_CHM_NAME");
    var RhLogFileName = $.getenv("RH_LOGFILE_NAME");
    var RhLogFile = new File(RhLogFileName);
    RhLogFile.open("w", "TEXT");
    RhLogFile.writeln("RH_PROJ_NAME : ", RhProjName);
    RhLogFile.writeln("RH_CHM_NAME : ", RhChmName);
    doc = RoboHelp.openProject (RhProjName, 1);
    var sslmngr = RoboHelp.project.SSLManager;
    for(var i = 1; i<=sslmngr.count; i++){
      var ssl = sslmngr.item(i);
      if(ssl.name == 'Microsoft HTML Help') {
        // Set the output location and file name
        ssl.setSpecificProperty("DestinationProjectName", RhChmName);
        if (doc.saveAll(true) ) {
          RhLogFile.writeln("saveAll returned TRUE");
        } else {
          RhLogFile.writeln("saveAll returned FALSE");
        if ( ssl.generate() ) {
          RhLogFile.writeln("ssl.generate returned TRUE");
        } else {
          RhLogFile.writeln("ssl.generate returned FALSE");
      } else {
        // alert ("Found " + ssl.name + " dont do anything");
    doc.saveAll(true);
    RhLogFile.close();
    RoboHelp.closeProject();
    RoboHelp.quit();

  • Opening PDF and PPT files without using BuddyApi

    Hi, please excuse my newness.
    I'm wanting to open pdf and ppt files through Director (I'm using 11.5) but I'm struggling with finding the right code to make it work. I saw that a lot of people are recommending Buddy Api. However I'm cheap and was hoping that there would be a way to open files without having to resort to using/paying for this xtra. Is there a reason why opening files in Director seems to be such a hassle?
    Thanks in advance.

    I'll also add that from my understanding, an unregistered version of Buddy API can be used in commercial applications.
    Buddy API is a great Xtra and if you're going to be developing applications with Director, this Xtra will be a valuable purchase. Buddy Xtra is recommended a lot in the Director forums for a good reason.
    Dean
    Director Lecturer / Consultant / Director Enthusiast
    http://www.deansdirectortutorials.com/
    http://www.multimediacreative.com.au

  • How to read text from PDF and HTML

    I have got solution to read text form .txt file but did'nt get code for PDF and HTML.
    I dont want to convert PDF to txt.
    Please help me ...

    reading from a file is always the same. using the same strategy used for a .txt will allow you to read a .pdf file.
    Offcourse in itself it will be useless becuase pdf files have a special internal structure.
    html files are identical to txt files.
    What are you trying to accomplisch with the files you are reading ?

  • I am in the process of expanding a database of chemistry journal articles.  These materials are ideally acquired in two formats when both are available-- PDF and HTML.  To oversimplify, PDFs are for the user to read, and derivatives of the HTML versions a

    I am in the process of expanding a database of chemistry journal articles.  These materials are ideally acquired in two formats when both are available-- PDF and HTML.  To oversimplify, PDFs are for the user to read, and derivatives of the HTML versions are for the computer to read.  Both formats are, of course, readily recognized and indexed by Spotlight.  Journal articles have two essential components with regards to a database:  the topical content of the article itself, and the cited references to other scientific literature.  While a PDF merely lists these references, the HTML version has, in addition, links to the cited items.  Each link URL contains the digital object identifier (doi) for the item it points to. A doi is a unique string that points to one and only one object, and can be quite useful if rendered in a manner that enables indexing by Spotlight.  Embedded URL's are, of course, ignored by Spotlight.  As a result, HTML-formatted articles must be processed so that URL's are openly displayed as readable text before Spotlight will recognize them.  Conversion to DOC format using MS Word, followed by conversion to RTF using Text Edit accomplishes this, but is quite labor intensive.
      In the last few months, I have added about 3,500 articles to this collection, which means that any procedure for rendering URL's must be automated and able to process large batches of documents with minimal user oversight.  This procedure needs to generate a separate file for each HTML document processed. Trials using Automator's "Get Specified Finder Items" and "Get Selected Finder Items", as well as "Ask For Finder Items"  (along with "Get URLs From Web Pages") give unsatisfactory results.  When provided with multiple input documents, these three commands generate output in which the URLs from multiple input items are merged into a single block, which yields a single file using "Create New Word Document" as the subsequent step.  A one-to-one, input file to output file result can be obtained by processing one file at a time, but this requires manual selection of each item and one-at-a-time processing. What I need is a command that accepts multiple input documents, but processes them one at a time, generating a separate output for each file processed.  Is there a way for Automator to do this?

    Hi,
    With the project all done, i'm preparing for the presentation. Managed to get my hands on a HD beamer for the night (Epason TW2000) and planning to do the presentation in HD.
    That of course managed to bring up some problems. I posted a thread which i'll repost here . Sorry for the repost, i normally do not intend to do this, but since this thread is actually about the same thing, i'd like to ask the same question to you. The end version is in AfterEffects, but that actually doesn't alter the question. It's about export:
    "I want to export my AE project of approx 30 min containing several HD files to a Blu Ray disc. The end goal is to project the video in HD quality using the Epson  EMP-TW2000 projector. This projector is HD compatible.
    To project the video I need to connect the beamer to a computer capable of playing a heavy HD file (1), OR burn the project to a BRD (2) and play it using a BRplayer.
    I prefer option 2, so my question is: which would be the preferred export preset?
    Project specs:
                        - 1920x1080 sq pix  (16:9)
                        - 25 fps
                        - my imported video files (Prem.Pro sequences) are also 25 fps and are Progressive (!)
    To export to a BRD compatible format, do i not encounter a big problem: my projectfiles are 25 fps and progressive, and I believe that the only Bluray preset dispaying 1920x1080 with 25 fps requests an INTERLACED video  (I viewed the presets found on this forum, this thread)... There is also a Progr. format, BUT then you need 30 fps (29,...).
    So, is there one dimension that can be changed without changing the content of the video, and if yes which one (either the interlacing or the fps).
    I'm not very familiar with the whole Blu-ray thing, I hope that someone can help me out."
    Please give it a look.
    Thanks,
    Jef

Maybe you are looking for

  • Yosemite installed, Firefox no longer opens, even in Safe Mode

    This evening I upgraded to Yosemite. Now Firefox no longer opens, even in Safe Mode. If I try to open FF, I receive a Mozilla Crash Report. I uninstalled and reinstalled FF, made no difference. Can anyone help?

  • Double Click functionality

    Hi,    I have a report where material is one of the output field. When user double clicks on material number it should call MM03 from the report and it should directly take to Accounting 2 view. How can it be done. Do let me know. Regards, SP

  • IPhone 4s times out when trying to update software

    Every time I try to update the iOS 7.0.6 it times out.  How do I fix this? EKY

  • Lsmw - CL02

    when i tried to create legacy for batch input in tx CL02, im getting error as "No batch input data for screen SAPLCLMO 0100". I tried recording thrice, im getting the same error. all other fields are working fine. help me out resolving this error.

  • Virsa CC 5.2  Backend sync - No destination system

    I have installed Virsa CC 5.2, I am trying to complete the post installation steps as mentioned in the guide as: Config tab -> Backend Sync -> Rule Sync But no destination system exists in the drop down list. There is only one system configured. Also