How to open a PDF File from a ByteArray
Hi, Fellows,
I'm having the following problem:
I have put a PDF file inside a BLOB field in a table in my SQLite database.
And I can retrieve it from this database without any problem, receiving a ByteArray data type as result.
What I want to know is what I should do to render this file in my HTML flex object without saving it to a file…
I used the mx.controls.HTML.data property, but what I see is the TEXT of my PDF file. The mx.controls.HTML.location needs a STRING with the link to a URL site or file.
Thanks in advance for your help.
Here, my code:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="810" height="620"
creationComplete="creationCompleteHandler();">
<mx:Script>
<![CDATA[
import flash.data.*;
import flash.filesystem.*;
private var _connection:SQLConnection;
private var _statement:SQLStatement;
private function creationCompleteHandler():void {
var file:File = File.applicationStorageDirectory.resolvePath("arq.db");
_connection = new SQLConnection();
_connection.addEventListener(SQLEvent.OPEN, openHandler);
_connection.openAsync(file, SQLMode.CREATE);
private function openHandler(event:SQLEvent):void {
var sql:SQLStatement = new SQLStatement();
sql.sqlConnection = _connection;
sql.text = "CREATE TABLE IF NOT EXISTS arq(" +
"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"nome TEXT, " +
"arquivo BLOB)";
sql.execute();
private function insertFile(identificacao:String, caminho:String):void {
var sql:SQLStatement = new SQLStatement();
sql.sqlConnection = _connection;
var arquivo:File = new File(caminho);
var arqStream:FileStream = new FileStream();
arqStream.open(arquivo,SQLMode.READ);
var arqBlob:ByteArray = new ByteArray();
arqStream.readBytes(arqBlob);
arqStream.close();
sql.text = "INSERT INTO arq(nome, arquivo)" +
"VALUES(@nome, @arquivo)";
sql.parameters["@nome"] = identificacao;
sql.parameters["@arquivo"] = arqBlob;
sql.execute();
trace("Arquivo inserido com Sucesso!!!");
lb1.text = "Arquivo inserido com Sucesso!!!";
private function selectFile(identificacao:String):void {
var sql:SQLStatement = new SQLStatement();
sql.sqlConnection = _connection;
sql.text = "SELECT id, arquivo FROM arq WHERE nome=@nome";
sql.parameters["@nome"] = identificacao;
trace(sql.text);
sql.addEventListener(SQLEvent.RESULT, apresentarDados);
sql.execute();
private function apresentarDados(event:SQLEvent):void {
var statement:SQLStatement = event.target as SQLStatement;
var result:SQLResult = statement.getResult();
if(result != null && result.data != null) {
var dataset:Array = result.data;
trace(dataset.length);
var arqBlob:ByteArray = dataset[0].arquivo;
var xx:HTMLLoader = new HTMLLoader();
var ur:URLRequest = new URLRequest();
var ul:URLLoader = new URLLoader();
//Right now, it's doing nothing
ur.contentType = "application/pdf";
ul.dataFormat = URLLoaderDataFormat.BINARY;
ul.data = arqBlob;
//Here is my problem - WHAT SHOULD I DO?
pdfFile.data = arqBlob;
trace("Cheguei!!!");
lb1.text = "Cheguei!!!";
} else {
trace("Não funcionou!!!")
private function sair():void {
this.exit();
]]>
</mx:Script>
<mx:TextInput x="99" y="10" id="arq"/>
<mx:Label x="10" y="12" text="Identificação:" width="81"/>
<mx:Button x="168" y="40" label="Apresentar" click="selectFile(arq.text)"/>
<mx:Button x="728" y="10" label="Sair" width="60" click="sair()"/>
<mx:TextInput x="417" y="10" id="id1"/>
<mx:TextInput x="417" y="40" id="cm1"/>
<mx:Button x="585" y="12" label="Gravar" click="insertFile(id1.text, cm1.text)"/>
<mx:Label x="291" y="12" text="Identificação:" width="105"/>
<mx:Label x="291" y="42" text="Caminho Completo:" width="118"/>
<mx:Label x="615" y="42" width="173" id="lb1"/>
<mx:HTML id="pdfFile" width="800" height="520" y="79"/>
</mx:WindowedApplication>
Bob, Here's some ActionScript code for saving the byte array data to temporary file. (In this code, pdfData is a ByteArray object containing the PDF data.)
var tempFile:File = File.createTempFile();
var stream:FileStream = new FileStream();
stream.open(tempFile, FileMode.WRITE);
stream.writeBytes(pdfData);
stream.close();
Next you can load the file into your Flex HTML control (represented as html in the following code):
html.location = tempFile.url;
Here's more information on reading and writing files:
http://help.adobe.com/en_US/AIR/1.5/devappsflex/WS5b3ccc516d4fbf351e63e3d118666ade46-7dc2. html (for Flex developers)
http://help.adobe.com/en_US/AIR/1.5/devappsflash/WS5b3ccc516d4fbf351e63e3d118666ade46-7dc2 .html (for Flash developers)
http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7dc2. html (for Ajax developers)
Similar Messages
-
How to open an PDF file from Java Application
Hi
I am developing a GUI application in java swing.
on clicking one button, I want to open PDF file from my swing application.
Is there any API through which I can achieve this?
Tapan Maru
Sun Certified Java ProgrammerHere's a way to do it (if I understand you
correctly). Just let explorer.exe do it for you.
import java.awt.*;
public class openPDF
Desktop desktop = Desktop.getDesktop();
public openPDF()
open("test.pdf");
public void open(String path)
try
Runtime.getRuntime().exec("explorer.exe "+path);
} catch(Exception e) { System.out.println("NAI!
I! ERROR!\n"+e); }
public static void main(String[] args)
openPDF myApplication = new openPDF();
Why do you have a Desktop object as a member but instead of using it, you execute a command with Runtime (which is not platform independent!)???
-Puce -
Open the pdf file from forms6i
Hi,
how to open the pdf file from forms6i.
can anyone help me regarding this.
Thanks,
Ansaf.Hi,
The HOST built-in does not return any error or message back to the Form.
You will have to use some other means to first find out whether the file exists or not. E.g. you could use TEXT_IO.FOPEN to open the file in Read mode. If the files is not found the handle returned will be null, and that will be condition you have to process to show a message or pop an alert.
Make sure you close the file with FCLOSE, irrespective of whether the file is found or not, before you open the File for viewing.
Regards, -
I have a customer that is using Adobe Acrobat pro version 10.1. When they try and open a .pdf file from a SharePoint site, the user is prompted to check out and open the file or open the file. Is there a way to get Adobe Acrobat to open the .pdf file without prompting to check out or open?
Thanks
JimThis is mostly a lion thing, rather than a PSE thing. To disable applications opening where they left off last time for all the programs on your computer, go to system preferences>general and untick this box:
You can also do on a per-program basis, but it's more complicated and the best thing to do is to search around for directions on the web and see which way is least uncomfortable for you.
There's an odd little glitch in PSE that it opens the last image you had open, even if you closed it before quitting last time. Adobe says this is correct behavior, but of course it isn't. -
Unable to open large PDF file from the Attachment list.
Hi Gurus,
Users had attached 10 PDF file in the work order attachment list and his supervisor is trying to open the PDF file from the work order attachment list and he is able to open 9 PDF files without any issue, but 1 PDF file is giving the error message as "Database error for <GET DATA FROM KPRO>" and then select ok, we are getting the below message.
Window cannot find u201CC/Documents and Settings/b2m/SaoworkDir/5015851 Vendor data sheets B&P 2010 SDown XXX .PDFu2019. Make sure you typed the name correctly, and then try again. To search for a file, click the start button, and then click serch.
Looks like this particular file is not transferring to the SAP work directory.
Could you please check and suggest us as to how to fix it.
Thanks & Regards,
SrivasHi,
Thanks for your reply.
We verified your OSS notes it's not relevant to us Because our issue is while opening the PDF aatchement it is not transferring to my SAP Work Directory because of that reason we are getting the KPRO error. When I'm opening the other PDF files it's transferring to my SAP Work Directory and it's automatically open without any issue.
Please check and suggest.
Thanks,
Srivas -
How can I read pdf files from LabVIEW with different versions of Acrobat reader?
How can I read pdf files from LabVIEW with different versions of Acrobat reader?
I have made a LabVIEW program where I have possibility to read a PDF document. When I made this LabVIEW program it was Acrobat Reader 5.0.5 that was installed on the PC. Lather when the Acrobat Reader was upgraded to version 6.0, there was an error when VI tries to launch the LabVIEW program. And Later again when we upgraded to Acrobat Reader 7.0.5 I must again do some changes and rebuild the EXE files again
It isn't so very big job to do the changes in one single LabVIEW program, but we have built a lot of LabVIEW programs so this take time to due changes every time vi update Acrobat Reader. (We have build EXE files.)
The job is to right click the ActiveX container and Click "Insert ActiveX Object", then I can brows the computer for the new version of acrobat Reader. After this I must rebuild all the "methods" in the Activex call to make the VI executable again.
Is there a way to build LabVIEW program so I don't have to do this job every time we update Acrobat Reader?
This LabVIEW program is written in LabVIEW 6.1, but I se the problem is the same in LabVIEW 8.2.
Jan Inge Gustavsen
Attachments:
Show PDF-file - Adobe Reader 7-0-5 - LV61.vi 43 KB
Read PDF file.jpg 201 KB
Show PDF-file - Adobe Reader 5-0-5 - LV61.vi 42 KBhi there
try the vi
..vi.lib\platform\browser.llb\Open Acrobat Document.vi
it uses DDE or the command line to run an external application (e.g. Adobe Acrobat)
Best regards
chris
CL(A)Dly bending G-Force with LabVIEW
famous last words: "oh my god, it is full of stars!" -
How to open a pdf file only in one computer
I would like to sell pdf publications by allowing the user to open them only in one computer. I learnt that this has been done the past when I bought some publications but I don't know the way to do it. Could you help me?
thank you
Marcothank you for your support
Best Regards
Marco
Da: Mylenium <[email protected]>
Per: MARCO1 <[email protected]>,
Data: 09/10/2013 11:09
Oggetto: How to open a pdf
file only in one computer
Re: How to open a pdf file only in one computer
created by Mylenium in Downloading, Installing, Setting Up - View the full
discussion
You will havwe to sign up for some service that supports rights
management, use protected PDFs via LiveCyle/ Acrobat Connect or learn how
to create your own ePub stuff using Digital Publishing Suite. In any case,
it will probably cost you money upfront before you make any revenue.
Mylenium
Please note that the Adobe Forums do not accept email attachments. If you
want to embed a screen image in your message please visit the thread in
the forum to embed the image at
http://forums.adobe.com/message/5746873#5746873
Replies to this message go to everyone subscribed to this thread, not
directly to the person who posted the message. To post a reply, either
reply to this email or visit the message page: [
http://forums.adobe.com/message/5746873#5746873]
To unsubscribe from this thread, please visit the message page at [
http://forums.adobe.com/message/5746873#5746873]. In the Actions box on
the right, click the Stop Email Notifications link.
Start a new discussion in Downloading, Installing, Setting Up at Adobe
Community
For more information about maintaining your forum email notifications
please go to http://forums.adobe.com/message/2936746#2936746.
Il messaggio trasmesso può contenere informazioni di carattere
confidenziale rivolte esclusivamente al destinatario. Ne è vietato l'uso,
la diffusione, la distribuzione o la riproduzione da parte di altre
persone e/o entità diverse da quelle specificate. Nel caso aveste ricevuto
questo messaggio per errore, siete pregati di segnalarlo immediatamente al
mittente e cancellare quanto ricevuto.
This electronic mail transmission may contain confidential information
addressed only to the person(s) named. Any use, distribution, copying or
disclosure by any other person and/or entities other than the intended
recipient is prohibited. If you received this transmission in error,
please inform the sender immediately and delete the material -
I install Adobe Acrobat 9 in my laptop which runs on windows 7. I use Firefox 3.6.8 and have the problem with the PDF file. The problem is I cannot open the PDF file in Firefox web browser at the first time I launch firefox. It shows a warning box without any message. Only OK button is shown so I can close it. However, if I manage to open the PDF file from my local computer by just using adobe acrobat itself then the PDF can be opened in the Firefox web browser. I followed the instruction on the mozilla help but nothing works for me. The problem still exists. I wonder if anyone have the same problem like me and know how to solve this. Thank you so much
Hi there!
I cannot help you, but I think we have a common problem: We got a system here running Vista SP1 with Acrobat 9 standard on it. When we open a pdf file it works normally, but when we open another pdf file, we see the first one in that second window.
Think that missing option to watch several files within a single window-thing messed up more than meets the eye ... but as we just purchased the 15 licenses, we have to use version 9.
I didn't find any clues on this problem, but I will post any new hints I get. -
How to open Adobe Reader file from another native IOS application?
There is an existing thread, but I want to re-open it because I think this is an important feature that we need badly. I was wondering if there is any plan to add this feature so we can open PDFs directly into Adobe from the web / other apps.
How to open Adobe Reader file from another native IOS application?
Basically, we just want to use a custom URL scheme to open a specific document in the App. Currently, this only opens the app but does not load the file.
APBNot to hijack the conversation but I can explain why this would be useful for both the above case and another.
What I believe Pavel is talking about is setting up a "URL Scheme" for the Adobe Acrobat iOS application so that you can easily open a PDF specifically in Adobe Acrobat iOS from other native applications and even from web applications opened within Safari. This is particularly useful if your application requires some of the specific features in Adobe Reader iOS to grant them the best experience possible and you want to encourage this.
Another case: If you're using Adobe Livecycle's document security modules (that encrypts PDF files so that Adobe Acrobat must "phone home" to decrypt and view the document), these PDF's can only be viewed inside the Adobe Acrobat application and appear as blank in most other PDF readers. Having a URL scheme allows your application utilising this functionality to have a 1 click step to view the PDF rather than the current non-user friendly process:
- Within Safari, touch the PDF link (appears as blank in the default Safari PDF reader, which in itself is confusing)
- Touch "Open in..."
- Touch "Adobe Acrobat"
We have an immediate need for this functionality for the example above. I can resubmit it in a separate post if necessary. -
How to transfer my PDF files from computer to iphone 5s
How to transfer my PDF files from my laptop to my iPhones 5 s and how to make folder to store those files?
The iphone does not have a file system to create a folder in, instead apps themselves are responsible for storing their files,
Use an app like ibooks or acrobat reader.
You can then transfer the files via itunes or email them and then use the open in... option and select your chosen app.
They will then be stored within that app. -
Can't open web pdf files from my newly installed Reader DC because my IMac wants a completed license to use agreement to Reader, and I never saw that page during installation. How do I get past this?
You need to accept the EULA on first launch of the Reader DC application.
Go to the Applications folder and launch Adobe Acrobat Reader DC.
This will bring up the EULA.
Select the "Agree" button if you agree with the terms
Assuming you selected the "Agree" button, Reader DC should open.
You should now be able to open PDF files in your web browser. -
How can I delete PDF files from my iMac desktop?
How can I delete PDF files from my iMac desktop?
Not on my system,When I try to dump if off in the trash it will not go. I get a message that says this file cannot be removed. I also tried going to File and clicking on Move to Trash. No dice.
-
How can I transmit PDF files from my Mac to my iPad, How can I transmit PDF files from my Mac to my iPad
Yes you can definitely do this. You'll need an app on the iPad that handles PDF viewing and editing. There are many around - two of the best I've seen are GoodReader and PDF Expert.
In iTunes when you iPad is connected to your PC, go to the Apps tab and scroll down and you'll see the File Sharing section. You can drag files to there to share them to your iPad.
You could also look at online file sync services like PDF to ePub Maker if you prefer not to have to connect your iPad to a PC -
How to open a pdf file in JFrame
hi to all,
i need to know how to open a pdf file in JFrame. Help is needed with this would grateful, and i used the code state below..
InputStream in=this.getClass().getResourceAsStream("/images/help1.pdf");
Process p = Runtime.getRuntime().exec(in);Thanks in Advance...this is the error which i'm getting while executing the code
init:
deps-jar:
Compiling 1 source file to /home/VEL AREA/SampleApplication/build/classes
/home/VEL AREA/SampleApplication/src/sampleapplication/Main.java:3: package com.sun.pdfview does not exist
import com.sun.pdfview.PDFFile;
/home/VEL AREA/SampleApplication/src/sampleapplication/Main.java:4: package com.sun.pdfview does not exist
import com.sun.pdfview.PDFPage;
/home/VEL AREA/SampleApplication/src/sampleapplication/Main.java:5: package com.sun.pdfview does not exist
import com.sun.pdfview.PagePanel;
/home/VEL AREA/SampleApplication/src/sampleapplication/Main.java:25: cannot find symbol
symbol : class PagePanel
location: class sampleapplication.Main
PagePanel panel = new PagePanel();
/home/VEL AREA/SampleApplication/src/sampleapplication/Main.java:25: cannot find symbol
symbol : class PagePanel
location: class sampleapplication.Main
PagePanel panel = new PagePanel();
/home/VEL AREA/SampleApplication/src/sampleapplication/Main.java:36: cannot find symbol
symbol : class PDFFile
location: class sampleapplication.Main
PDFFile pdffile = new PDFFile(buf);
/home/VEL AREA/SampleApplication/src/sampleapplication/Main.java:36: cannot find symbol
symbol : class PDFFile
location: class sampleapplication.Main
PDFFile pdffile = new PDFFile(buf);
/home/VEL AREA/SampleApplication/src/sampleapplication/Main.java:39: cannot find symbol
symbol : class PDFPage
location: class sampleapplication.Main
PDFPage page = pdffile.getPage(0);
8 errors
BUILD FAILED (total time: 2 seconds)
for the reply #4.. -
How do I transfer PDF files from PC (Windows 7) to IPAD using Itunes 12.1.2. I would like to do files manually rather then auto synch. Previous versions let me drag file in Itunes to Ipad and files appeared under Ibook and then I could move them to an appropriate collection title. The interface appears to have changed in the latest ITunes version and I am not sure what the proper procedure is.
King_Penguin - Thanks it worked perfectly. I had my pdf files copied into ITunes on my PC but when I clicked on a pdf file to copy it I thought the sidebar would appear with my IPAD name and then I would drag it over. I didn't realize that I needed to click-and start dragging it towards the left-hand side for the sidebar to appear. It worked like a charm - THANKYOU!!!
Maybe you are looking for
-
Safari doesnt download video files anymore
Downloading from "Activity" window doesnt work anymore for me. Before, i would just open Activity window and double-click on file I want to download, but it doesnt work anymore. When i double-click it just open the same video in a new window but no d
-
Object ID for PO long text for BDC of material master
Hi all, we are working on BDC of material master: I have given some technical specifications in the P O text view of Material Master, i want to assign an object id for this long text , how to assign an object id for the long text? regards, urendra
-
Loss of sound, trouble sharing
i have a macbook and am running imovie 4. never had problems before. actually used it very recently to do some videos. now i'm working with video clips and imported still photos and i have extracted the audio. suddenly the audio is absent in the cont
-
Changing SID using Sysprep without starting from scratch
Long story short, we have a vmware environment with several vm's set up by an outside vendor. The vm's were set up and put into production just in a workgroup. A domain was set up on another physical server but never implimented. Had to work on se
-
Why when I try to update certain app it require an old email address and password I have not used for years and I do I get to update them on my new details