Display a PDF file from local drive

Hi,
I would like to display a pdf file that is actually stored on the portal server hard drive.
What I have tried to do is link an iFrame element to the url of the file: "D:
MyFolder
myFile.pdf"
But it doesn't work. I have the following error when trying to do that:
com.sap.tc.webdynpro.services.exceptions.InvalidUrlRuntimeException: Invalid URL=D:/MyFolder/myFile.pdf
Does this means that iFrame can only display http URLs ? What are the other ways to easily display pdf files ?? I'am stuck with that problem and can't find any other solution.
I also tried with "servletResponse.getOutputStream().write(fileByteContent);" but the problem is that I am not in a PAR application, and I don't have the servletResponse element and don't know how to get it.
Thanks for your help.
Thibault Schalck

Hi,
   You can not access the .pdf file using the nornal path (c:
), use the following code to open the pdf in ur iframe, this will work i used it in my application.
String sFileName =
strCampCodeVal"_"nReqIdVal+".pdf";
String sFile =
"C:
SBLI
BCP
barcode_files
"+sFileName;
File fFile = new File(sFile);
     if ( fFile == null )
         System.out.println("System can not download the
                                 file at this time. Please try again later.");
              return;
//Checking the file for existence
     if ( !fFile.exists() || !fFile.canRead() )
         System.out.println("You have specified an
                   invalid file to download. Please check and try
                    again.");
         return;
//set the content type its important , try with applicatio/pdf also
     res.setContentType("application/force-download");
//seting the header
     res.setHeader("Content-disposition",
"attachment;filename=" + sFileName);
     res.setHeader("Cache-control", "must-revalidate");
     ServletOutputStream sosCur = res.getOutputStream();;
//reading the in and writing the stream
     BufferedInputStream bisFile = null;
          try
               byte [] bBuffer = new byte[4096];
               bisFile = new BufferedInputStream(new
                                                FileInputStream(fFile));
               int nBytes = -1;
                          while( (nBytes = bisFile.read(bBuffer, 0, 4096))!=-1 )
                   sosCur.write(bBuffer, 0, nBytes);
          catch(Exception ex){
This will resove your issue.All the best..
Regards..
krishna..

Similar Messages

  • SQL 2012 Cluster- How to or Steps to Move Tempdb Files from Local drive to Shared volume

    Hi..
     I did Installation of SQL Server 2012 Cluster. During this setup I installed Tempdb Files on Local drive. Now I want to move this tempdb files from local drive to Shared Drive . When I am trying to move I am getting below error.
    Does any one can help me or provide the steps to move this tempdb files from local drive to Shared Drive ?
    Msg 5184, Level 16, State 1, Line 1
    Cannot use file 'Z:\Tempdb\tempdb.mdf' for clustered server. Only formatted files on which the cluster resource of the server has a dependency can be used. Either the disk resource containing the file is not present in the cluster group or the cluster resource
    of the Sql Server does not have a dependency on it.
    Thanks 
    Regards..
    Please Mark As Answer if it is helpful. \\Aim To Inspire Rather to Teach

    Hi,
    The error message may be thrown out when you attempt to create a database on another shared cluster drive when the SQL Server resource is not dependent on that disk.
    Check if you are in the scenario which mentioned in the following article:
    How to create databases or change disk file locations on a shared cluster drive on which SQL Server was not originally installed
    http://support.microsoft.com/kb/295732/en-nz
    Here is a thread with similar issue:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/c9f80af7-5b51-4c43-a2a0-f9c7d97aa41d/sql-disk-dependency-problem-on-sql-2008-cluster-including-errors
    Hope it helps.
    Tracy Cai
    TechNet Community Support

  • Unable to save PDF file to local drive from sap after Above reader XI update.(Not as sap issue ,this is related to Adobe)

    Hi All,
    Users are unable to download/save file from sap after a adobe XI update.(no pop comes to save/open)
    Surprisingly,i am able to do so on my system without any adobe plug ins disabled or any registry editing.
    This is a strange behaviour and need to be resolved Asap....
    I contacted sap..this is not sap issue..this is a pure adobe reader bug.
    Please need help on this experts
    Feel free to comment for further details
    kind Regards,
    Sumit
    Mail me at [email protected]

    Hi ,
    Please tell us a lot more.
    - Is SAP running a local process, or something in a web browser?
       sap is running via SAPGUI ,no java system
    - What system?
      Users facing issue in all system
    - What browser?
    IE 9.0.28
    - Can PDFs from other sources be downloaded?
    Yes,they are downloaded.
    More Details-I did some tricks below which resulted in open/save popup......tht is not recomended by IT team...i need a permanent solution
    In IE, goto menu Options -> "Manage
    Addons", select in box "Show:" "Run without
    permission", then you see the Adobe PDF plugin
      Ichanged status to "Disabled
    Also, if i change the registry key settings for users as
    HKEY_CLASSES_ROOT\AcroExch.Document.11
    Value: EditFlags
    Changed: 0x00000100
    to 0x00000000
    (Remove the "Open always with this
    program" option)
    ITS WORKING.....
    But,in my system i need not to do all this settings and surprisingly it is working  only for me,rest all users are facing this issue.....
    If any one using Lync ,communicator ..do let me know..i wil show  the actual scnerio.
    Kind Regards,
    Sumit

  • BSP to display an HTML file in local drive

    Hi,
       I am developing a BSP application, where after accepting the some parameters from users in the initial screen, I have to open a document in KPRO based on the values entered by the user and take the HTML file attachmet from KPRO document and store it in Local drive then display that HTML file in the BSP screen. Is it possible to do?If yes, how to do this. It is not compulsory to store the HTML locally, I have to display the html page in BSP.
       This BSP will be called from Enterprise Portal.
    Regards,
    Sathish

    sathish,
    so you want to display a html page in BSP. If i understood your requirement correctly,
    you will be having the path of the file so just use the below code to display it in the bsp.
    <a href=" http://w3.hr.xxxxxxxxxxxxcom/people/asp/globalCompetencies.asp"
      target="_blank" STYLE="color:blue;font-size:11; font-face:arial;"
      OnClick="window.open(this.href,'_blank',
                    'width=500,height=500,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1');
                return false;"
      ><%=otr(YP_HRPA/GLOBAL_COM)%></a><
    regards,
    manasa

  • Copy a file from local drive to network drive!

    The subject says it all but I'll explain. I have a web application that runs on a tomcat and mysql. I have a bunch of clients in a local network that uses the application.
    Server is running Windows 2003 server and clients are running windows XP.
    On a client request a file is created on the server in "temp" folder. The file name is "justAFile.txt".
    On the client pc a folder "temp" is shared for reading/writing.
    What I want is the server to take the IP address of the client, and then based on that address to copy the file "justAFile.txt" to it (for example "\\192.168.0.20\temp\" - that is the client address).
    I have the address of the client:
    String userAddress = request.getRemoteAddr();I use this code:
    FileOutputStream outFile;
    PrintStream p;
    String bonFileName = (justAFile.txt");
    String destinationFileWithPath = ("\\\\192.168.0.20\temp\\skladPrint\\"+bonFileName);
    try {
        outFile = new FileOutputStream(destinationFileWithPath);
        p = new PrintStream( outFile );
        p.println ("a textto be written on a file");
        p.close();
    } catch (Exception e) {
         %>Error writing to file<br><%
    }This code can create a file on a local drive with no problems, but when I try on a network drive it fails. Even for testing purposes I set the shared folder to a maped drive "Z:", and again no luck.
    I've spend all my day till now in reading articles in inet, but haven't found one that will solve the problem.
    I also tried creating a batch file (exec.bat) that has in it:
    move \temp\*.txt \\192.168.0.20\temp
    and then executing it with:
    String[] executeCommand1 = { "cmd.exe", "/c", "\\temp\\exec.bat" };
    Process p1 = Runtime.getRuntime().exec(executeCommand1);
    p1.waitFor();But again no luck. When I execute the file from command prompt, it moves the file to the shared folder, but when I start it from the java application with the posted code, it DOES NOT move the file...
    Any help will be appreciated...

    Try using the jCIFS project. This package allows you to access shared folders on a PC if you have a good username/password.

  • Unable to copy file from local drive to external drive

    I'm attempting to copy a 7gb file from my local drive on my iMac to an external firewire drive. Whenever I try to do this I get the following message: Sorry, the operation could not be completed because an unexpected error occurred.
    I've rebooted, checked permissions on local and external drive. I'm the only person that uses this iMac. It only has one profile on it. Any suggestions?

    Hello Sikwidityo
    If that External HD is formatted MS-DOS FAT32, then there is a 4GB file size limit that the iMac's can write to it.
    See > http://www.macworld.com/article/51972/2006/07/ww_drives.html
    In order to copy large files to it you from your Intel iMac's, you will need to set the Partition Map Scheme to GUID Partition Table and Format it Mac OS Extended (Journaled)
    See > http://www.kenstone.net/fcphomepage/partitioningtiger.html
    Keep in mind that repartitioning and reformatting will erase the current data on the External drive. So if you do, you'll need to copy it's contents to one of your iMac's and then back when your done.
    Dennis

  • How to send pdf files from local dir through emails attachments

    I have some pdf documents in some directory, I want to send those pdf's as an attachment throu emails to the concerned person.
    Please let me know how to attach the files and send through email.
    Thanks.

    You are using Forms 4.5, which is a client/server configuration. When you create a pdf file, the file has to be written to a directory that is accessible from your PC. D:\ is acessible, /tmp/ not (that is a directory on some Unix server). If you want to write files to a Unix server, you have to set up Samba and map a drive from your PC to he Unix directory.
    Since you are creating multiple pdf files, you will have to wait until all reports are finished and mail them afterwards. You can create a batch script to mail the files.

  • FireFox 33.1 will not display the PDF file from Bank online site after 33.1

    I asked this question in an unrelated support ticket so I want to give more detail here. I have tried uninstalling Adobe reader and reinstalling it and it did not help. This was working before with all the exact same addins I had before. I called the Bank and asked if they had any problems and they say no. I can go to the Firefox PDF display for this file and click on download the PDF then double click it in Windows explorer and Adobe reader comes up and displays the file just fine. Don't mind doing that for now. What happens is the bank loads the file then Adobe reader displays with a white screen and a little circle going round and round, like a video is trying to play, and it just sits there forever. I never see the file contents. Anyway I hope your have a good of a day as I am and I know it get better. Thanks Firefox programmers for such a wonderful program.
    Update: While I was writing this I remembered to go into Firefox options, then Applications, and wouldn't you know it, a PDF document was set to "Preview in Firefox". I changed that to Adobe reader and now it works just fine. Guess there's something wrong with the Preview code in Firefox. So I'm happy now. Hope this helps someone.

    Yes, the built-in PDF viewer is a work in progress. Glad you found a workaround, or got back to your preferred configuration, depending on how you look at it.

  • How do I load PDF files from my flash drive to my iPad

    just go an iPad and need to transfer several PDF files from flash drive to the iPad.   I get an error message,not enough power

    You can't! If you have a computer you can send them bij email to your iPad or use the free Dropbox; http://db.tt/VCNzkXr

  • Want to open a new browser window and display the html file in locale disk.

    Hi,
    I want to open a new browser window and display the html file in local drive. The below html applet work in local system successfully. But i deploy the same in web server (Tomcat) and try the same in client machine it does not work. Please help.
    Note:
    The class below fileopen.FileOpen.class i make it as a jar and put it in jre\ext folder at the client machine.
    ------------------------------------FileOpen.html(Tomcat)-----------------------------------------------------
    <html>
    <body >
    <applet code="OpenFile.class" archive="loadfile.jar" width="100" height="100">
    <param name="path" value="file://c:/open.html" />
    </applet>
    </body>
    </html>
    -------------OpenFile.java in server(Tomcat)--------------------------------------------
    public class OpenFile extends Applet implements ActionListener{
    String path = "";
    fileopen.FileOpen open = null;
    Button b = null;
    public void init(){
    path = getParameter("path");
    b = new Button("Open");
    b.addActionListener(this);
    add(b);
    public void actionPerformed(ActionEvent ae){
    try
    open = new fileopen.FileOpen(this,path);
    catch (Exception e){
    e.printStackTrace();
    -------------------------------------------FileOpen.java /Client JRE/ext----------------------------------------------------
    package fileopen;
    public class FileOpen
    AppletContext context = null;
    URL url = null;
    public FileOpen(Applet applet,String path)
    try
    if(null != applet){
    context = applet.getAppletContext();
    if (null != path)
    url = new URL(path);
    context.showDocument(url, "_blank");
    }catch(Exception ex)
    ex.printStackTrace();
    Please help to solve this issue very urgent.
    Thanks in advance.
    By,
    Saravanan.K.

    zzsara wrote:
    I want to open a new browser window and display the html file in local drive. ...Did you ever pause to consider how ridiculous that is?
    The best audience for applets is people off the internet. 'People off the internet' might be using a computer that has no (what was it?) 'open.html' in the root of the C: drive. In fact (shock horror) they may not even be running Windows, and would therefore probably have no 'C:' drive at all.
    If you do not intend to distribute this to people off the web, an application makes a lot more sense, but even then, you cannot rely on the document being there unless you 'put it there' (during installation, for instance).
    As the other poster intimated, applets can load documents off the local disk as long as they are trusted. Here is an example*, but note that it is not so rash as to presume any particular path or file, and instead leaves it to the user to choose the document to display.
    * The short code can be seen at SDNShare on the [Defensive Loading of Trusted Applets|http://sdnshare.sun.com/view.jsp?id=2315] post.
    On the other hand, a sandboxed applet can load any document coming from its own server via URL, or get showDocument(URL) to work. In that case, the JRE must recognize that the URL is from its own server, so the best way to form URLs for applet use is via the URL constructor
    new URL(getDocumentBase(), "path/to/open.html");That is how I form the URL in this [ sandboxed example of formatting source|http://pscode.org/fmt/sbx.html?url=/jh%2FHelpSetter.java&col=2&fnt=2&tab=2&ln=0]. Of course, in this case the applet loads the document, then parses the text to draw the formatted version, but the point is that an URL produced this way will work with showDocument(URL).
    I am pretty sure showDocument() in an applet off the internet will work with an URL pointing to a foreign (not its own) server, but it will not be able to load documents off the end user's local disks.
    I suggest a couple of things.
    - Try to express this problem in terms of what feature it is that you want to offer the end user. Your question jumps directly to a bad strategy for achieving ..who knows what? An example of a feature is "Shows the applet 'help' files on pressing F1".
    - A good way to indicate interest in a solution is to offer [Duke stars|http://wikis.sun.com/display/SunForums/Duke+Stars+Program+Overview] to match that interest.
    Edit 1:
    ..and please figure out how to use the CODE tags.
    Edited by: AndrewThompson64 on Sep 12, 2008 11:14 PM

  • Pulling a PDF file from the database

    How would I display a pdf file from the database, or should I convert it to an image and if so how do I convert it into an image?

    Hi Phil_Kenya,
    Some samples here:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/db1556be-0f71-41cb-92de-b95f1e1ca3a3/how-can-i-load-a-pdf-file-in-my-database-filemdf-in-aspnet-web-project?forum=csharpgeneral
    http://stackoverflow.com/questions/7747796/displaying-pdf-files-in-a-web-page-from-a-sql-database-directly-without-needing
    I suggest you post this issue to the language development forum like above case, I think you would get more dedicated support.
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Loading PDF from local drive and sending it to Agent Inbox

    Hello experts,
    I have a question regarding to sending e-mails to inbox agent (so that it will appeared in the Inbox in the transaction SBWP). Sending e-mail is not a problem and I use FM called SO_NEW_DOCUMENT_ATT_SEND_API1 to do it.
    The problem starts when I want to attach a PDF file. I can not find information how to load a pdf file from a local drive and add it as an attachment to an email. I will be grateful for your help and peace of code.
    Best regards
    Andrew

    Hi,
    Using cl_bcs much simpler
    Based on BCS_EXAMPLE_3 .
    See attached program Y_R_EITAN_TEST_10_07 .
    Regards.

  • Lately pdf files from the Web do not display properly; what is wrong and how can I fix it so I don't have to use IE?

    I am a professor and frequently need to open pdfs of academic journal articles from electronic databases. Within the last two or three weeks, when I try to do this using Firefox, only the first page of the pdf displays and the rest are blank. In addition, a bar appears across the top with the message "This pdf file may not display properly." So I have had to switch to Internet Explorer to open the files and do my research. What is going on and how can I fix it so I can open pdf files from the Web in Firefox and have them display properly?

    My question is simple - why would you put an application in production that has a lot of bugs? To replace a good and steady Adobe product? My customers will believe that I put a pathetic fallible form online. They are not sophisticated on computers so I just tell them to use IE. Ugh
    I must agree with pgwebgirl!

  • Download Text file to Local drive from BSP Application

    Hi Guys,
    I am new to BSP, and I am doing a BSP application in which i want to download a text file to local drive C: on click of button. For that I am having a data in Internal table and Onclick event, in model class method DO_HANDLE_EVENT i want to download text file to local machine drive.
    Can anybody provide me full code with all data declaration and all?
    Your help would be appriciable. Thanks in Advance.

    Hi Jessy ,
    You can download the file from BSP pages using the method
    CL_BSP_UTILITY=>download.
    Please follow the below mentioned steps.
    1.Convert the text to a text table ie Internal table with a line type char255 or some others.
    2.Convert the text table into a string.
    3.Convert the string to XSTRING.
    4.Download that XSTRING as text file using the method
       CL_BSP_UTILITY=>download.
    Parameters:
    OBJECT_S    - XSTRING data
    CONTENT_TYPE  =  ' application/download'
    CONTENT_DISPOSITION = 'attachment; file=test.txt'
    RESPONSE                   = runtime->server->response
    NAVIGATION                   = navigation
    OBJECT_T
    I dont have system to give a programatical explanation to u.
    If you have any doubt kindly post.
    Reward for every useful solutions..
    Best Regards
    Renga

  • I cannot view PDF in Firefox at the first time but once I manually open the PDF file from my local computer, I can view other PDF files via Firefox webbrowser

    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.

Maybe you are looking for