How to upload a PDF file, zip it and download the zipped file?

Hi Experts,
I have a requirement to upload a PDF file, convert that to a ZIP file and download it. If anyone has worked on this requirement, can you please guide me on this? Thanks.
Avi

Here you go.  Hope it helps.
REPORT  zrich_0004.
DATA: lt_data TYPE TABLE OF x255.
DATA: ls_data LIKE LINE OF lt_data.
DATA: lv_zip_content TYPE xstring.
DATA: lv_size  TYPE i.
DATA: lv_filename TYPE string.
DATA: lv_path TYPE string.
DATA: lv_fullpath TYPE string.
DATA: lt_filetab TYPE TABLE OF file_table.
DATA: ls_filetab LIKE LINE OF lt_filetab.
DATA: lv_rc TYPE sy-subrc.
DATA: lv_content TYPE xstring.
DATA: lo_zip TYPE REF TO cl_abap_zip.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_up TYPE string DEFAULT 'C:\upload.pdf' .
PARAMETERS: p_down TYPE string DEFAULT 'C:\download.zip' .
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_up.
  REFRESH lt_filetab. CLEAR ls_filetab.
  cl_gui_frontend_services=>file_open_dialog(
      CHANGING
        file_table              = lt_filetab
        rc                      = lv_rc
    EXCEPTIONS
      OTHERS                  = 5 ).
  READ TABLE lt_filetab INTO ls_filetab INDEX 1.
  IF sy-subrc = 0.
    p_up = ls_filetab-filename.
  ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_down.
  CLEAR: lv_filename, lv_path, lv_fullpath.
  cl_gui_frontend_services=>file_save_dialog(
     CHANGING
       filename             = lv_filename
       path                 = lv_path
       fullpath             = lv_fullpath
     EXCEPTIONS
       OTHERS               = 4 ).
  p_down = lv_fullpath.
START-OF-SELECTION.
  CREATE OBJECT lo_zip.
* Read the data as a string
  cl_gui_frontend_services=>gui_upload(
    EXPORTING
      filename                = p_up
      filetype                = 'BIN'
    IMPORTING
      filelength = lv_size
    CHANGING
      data_tab                = lt_data
    EXCEPTIONS
      OTHERS                  = 19 ).
* convert binary to xstring
  CLEAR lv_content .
  CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
    EXPORTING
      input_length = lv_size
    IMPORTING
      buffer       = lv_content
    TABLES
      binary_tab   = lt_data
    EXCEPTIONS
      failed       = 1
      OTHERS       = 2.
* Get the file name of the uploaded file
  DATA: lv_upfilename TYPE string.
  DATA: lv_tmp TYPE char1024.
  DATA: lv_tmp_file TYPE char1024.
  lv_tmp = p_up.
  CALL FUNCTION 'STRING_REVERSE'
    EXPORTING
      string  = lv_tmp
      lang    = sy-langu
    IMPORTING
      rstring = lv_tmp.
  SPLIT lv_tmp AT '\' INTO lv_tmp_file lv_tmp.
  CALL FUNCTION 'STRING_REVERSE'
    EXPORTING
      string  = lv_tmp_file
      lang    = sy-langu
    IMPORTING
      rstring = lv_tmp_file.
  lv_upfilename = lv_tmp_file.
* add to zip file.
  lo_zip->add( name = lv_upfilename content = lv_content ).
  lv_zip_content   = lo_zip->save( ).
* Conver the xstring content to binary
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer        = lv_zip_content
    IMPORTING
      output_length = lv_size
    TABLES
      binary_tab    = lt_data.
* download
  cl_gui_frontend_services=>gui_download(
      EXPORTING
        bin_filesize = lv_size
        filename     = p_down
        filetype     = 'BIN'
      CHANGING
        data_tab     = lt_data
      EXCEPTIONS
        OTHERS       = 24 ).
Regards,
Rich Heilman

Similar Messages

  • HT3678 If I download a .mov file from gmail, I am not able to open the file. I reinstalled QuickTime 7.6.6, still unable to open the file. If I download the same file from another mail server I have no trouble. What is gmail doing to my file?

    If I download a .mov file from gmail, I am not able to open the file. I reinstalled QuickTime 7.6.6, still unable to open the file. If I download the same file from another mail server I have no trouble. What is gmail doing to my file?

    Also i have reinstalled the reader9 two  times and tried with reader8 also but in both the cases same problem.
    it would be gr8 help if someone can help.

  • How do you save changes made in iPhoto, and export the changed file.  It keeps reverting back to the original.

    How do you save changes made in iPhote, and export the changed picture file? When I select export, current format, it reverts to the original, wiping out all my work.

    Try trash the com.apple.iPhoto.plist file from the HD/Users/ Your Name / library / preferences folder.
    (On 10.7 or later: Hold the option (or alt) key while clicking on the Go menu in Finder to access the User Library)
    (Remember you'll need to reset your User options afterwards. These include minor settings like the window colour and so on. Note: If you've moved your library you'll need to point iPhoto at it again.)
    What's the plist file?
    For new users: Every application on your Mac has an accompanying plist file. It records certain User choices. For instance, in your favourite Word Processor it remembers your choice of Default Font, on your Web Browser is remembers things like your choice of Home Page. It even recalls what windows you had open last if your app allows you to pick up from where you left off last. The iPhoto plist file remembers things like the location of the Library, your choice of background colour, whether you are running a Referenced or Managed Library, what preferences you have for autosplitting events and so on. Trashing the plist file forces the app to generate a new one on the next launch, and this restores things to the Factory Defaults. Hence, if you've changed any of these things you'll need to reset them. If you haven't, then no bother. Trashing the plist file is Mac troubleshooting 101.

  • How can I auto export a PDF File using the "Smallest File Size" preset and set the Exported File Name based on information from an Imported PDF?

    Greetings all,
    I am trying to create a script to automate a PDF export process for my company for inDesign. I’m fairly new to inDesign itself and have no previous experience with javascript, although I did take C++ in high school and have found it helpful in putting this code together.
    We have an inDesign template file and then use the Multi-page PDF importer script to import PDF files. We then have to export two version of each file that we import, then delete the imported file and all of the pages to reset the template. This has to be done for nearly 1000 pdf files each month and is quite tedious. I’m working on automating the process as much as possible. I’ve managed to piece together code that will cleanup the file much quicker and am now trying to automate the PDF exports themselves.
    The files are sent to us as “TRUGLY#####_Client” and need to be exported as “POP#####_Client_Date-Range_North/South.pdf”
    For example, TRUGLY12345_Client needs to be exported as POP12345_Client_Mar01-Mar31_North and POP12345_Client_Mar01-Mar31_South.
    There are two templates built into the template file for the north and south file that are toggled easily via layer visibility switches. I need to get a code that can ideally read the #s from the imported Trugly file as well as the Client and input those into variables to use when exporting. The date range is found in the same place in the top right of each pdf file. I am not sure if this can be read somehow or if it will have to be input manually. I can put North or South into the file name based on which template layer is visible.
    I am not sure how to go about doing this. I did find the following code for exporting to PDF with preset but it requires me to select a preset and then type the full file name. How can I set it to automatically use the “Smallest File Size” preset without prompting me to choose and then automatically input some or preferably all of the file name automatically? (If the entire filename is possible then I don’t even want a prompt to appear so it will be fully automated!)
    PDF Export Code (Originally from here: Simple PDF Export with Preset selection | IndiSnip [InDesign® Snippets]):
    var myPresets = app.pdfExportPresets.everyItem().name;
    myPresets.unshift("- Select Preset -");
    var myWin = new Window('dialog', 'PDF Export Presets');
    myWin.orientation = 'row';
    with(myWin){
        myWin.sText = add('statictext', undefined, 'Select PDF Export preset:');
        myWin.myPDFExport = add('dropdownlist',undefined,undefined,{items:myPresets});
        myWin.myPDFExport.selection = 0;
        myWin.btnOK = add('button', undefined, 'OK');
    myWin.center();
    var myWindow = myWin.show();
    if(myWindow == true && myWin.myPDFExport.selection.index != 0){
        var myPreset = app.pdfExportPresets.item(String(myWin.myPDFExport.selection));
        myFile = File(File.saveDialog("Save file with preset: " + myPreset.name,"PDF files: *.pdf"));
        if(myFile != null){
            app.activeDocument.exportFile(ExportFormat.PDF_TYPE, myFile, false, myPreset);
        }else{
            alert("No File selected");
    }else{
        alert("No PDF Preset selected");
    So far my code does the following:
    1) Runs the Multi-Page PDF Import Script
    2) Runs PDF Export Script Above
    3) Toggles the Template
    4) Runs #2 Again
    5) Deletes the imported PDF and all pages and toggles template again.
    It’s close and much better than the original process which was almost 100% manual but I’d like to remove the Preset prompt from the PDF script and have it automatically select the “Smallest File Size” preset. and then if there’s a way to have it auto-fill in the file name so no user input is required at all other than selecting each file to import. (If there’s a way to setup a batch action for the multi-import script that would be even better!)
    Thanks in advance and if there’s anything else I can provide that would help please let me know! Even a nudge in the right direction will be a big help!

    If you hold down the option key, it will typically show the location. Or you can often hit option-return on the file and it will reveal the file in the Finder, instead of opening it.
    Final option is to open it, and just option-click the filename in the toolbar of Preview and it should show you the location.
    It's probably an attachment to an email you've received. If you have Mail set to cache emails and their attachments it'll be stashed in a subdirectory of ~/Library/Mail. Which is fine.

  • How to zip a folder containing subfolders with files and download the zip file in silverlght 4

    private void hbtnDownloadReceipt_Click(object sender, RoutedEventArgs e)
               try
                    string Docpath = "ClaimsDetails/" + "20tech" + "/" + PaymentAdviceUNo;
                    string dd = "ClaimsDetails/";
                    Uri uri = new Uri(Application.Current.Host.Source, "/" + Docpath);
                    Uri uri1 = new Uri(Application.Current.Host.Source, "/" + dd);
                    string path = uri.AbsoluteUri.ToString();
                    path1 = uri1.AbsoluteUri.ToString();
                    //HtmlPage.Window.Eval("window.open('" + path + "')");
                catch (Exception ex)
                    ex.Data.Clear();
    1) Here "path" is D:\\TL 24-12-2014 \\OfficeConnect_17_10\\OfficeConnect.Web\\ClaimsDetails\\20tech\\PaymentAdviceUNo.     
    2) In path "PaymentAdviceUNo" is the folder containing subfolders which i want to zip.
    Thanks in Advance.

    Hi,
    You can download a zip file like any files with the Webclient class, look at the details and examples in the msdn documentation for downloading content on demand it even talks about how to download and get a specific file from a zip archive.
    http://msdn.microsoft.com/en-us/library/cc189021(VS.95).aspx
    Besides,  if you want to list the files,you could check articles below:
    http://blogs.msdn.com/b/blemmon/archive/2009/11/25/reading-zip-files-from-silverlight.aspx
    Best Regards,
    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.

  • How to upload data using utl_file when you dont know the exact file name

    Hi
    i want to upload data from a flat file to a table.
    i dont know the exact file name. i want to make a search for filename. like i want to make a search on file (say test*) which will give me all the files with test.
    i want to upload data using these files.
    how can i do this by using UTL_FILE.
    Regards
    Manish

    Thank you very much.
    Thing is previously we are using sqlloader and shell script for loading the data.
    now i am creating a procedure (if possible without parameters).
    Is there any other way i can do that.
    can i make a wild card search using utl_file.
    Thanks n Regards
    Manish

  • How to upload Images to azure media services and show the image on on click on Link?

    Hi,
    I want to upload the image to the Azure media service asset and show the Link on the page. When use clicks on the Link I want to show it user. How can I implement this with C#? Now I am uploading the image to asset as in the normal way and getting the URL
    for that. But I am not able to show it user when he click on the image link.
    Thanks,
    Pavankuamr H K

    HI
    Azure media services has a RESTful service and a C# SDK that you can use to interact with the Azure Media Services.
    Here is the documentation and sample code for calling the Media services and using the SDK:
    https://msdn.microsoft.com/en-us/library/dn735908.aspx?f=255&MSPPError=-2147217396
    Aram Koukia | Blog: koukia.ca | Twitter:
    @aramkoukia

  • HT1657 My movie -- safe House -- froze/stopped with 57 minutes left to play. How can I get the rest of the movie to play or how can I delete it from my iPad and download the rental again?

    My rental movie -- Safe House -- stopped/froze with 57 minutes leftnto play. How can I watch the rest of the movie, or delete it to download it again?

    Welcome to the Apple community.
    Have you tried stopping the movie and trying to start it again.
    Unfortunately you cannot re-download rentals. If the problem continues, select the content which is causing a problem and use the 'Report a problem' button in Your Purchase History.

  • I have a pdf file attached to email inbox for ipad3.  I also have an neu.Annotate  app for pdf.  Can anyone tell me how to open my pdf through neu.Annotate and save the file?

    How do I save the pdf on ipad3?  How can I view the fiel from neu.Annotate so that I could do the editing from the app?

    If the PDF isn't already downloaded in the email then you should be able to do so by tapping on it.
    If the PDF is open within the body of the email then press and hold it and after a second or so you should get a 'Open In' pop-up; otherwise (e.g. the PDF opens into a separate screen) then tap the PDF and you should get an icon top right of a box with an arrow coming out of it - tap that and you'll get the 'Open In' option

  • How do I convert a keynote to flash and keep the video file

    I am trying to convert a keynote presentation into flash, but when I do I lose the videos. How do I stop this from happening?
    Thanks,
    Jeremy

    How would this help? Flash is not compatible Keynote. If you are saying I should export the keynote presentation as a quicktime, then convert to flash, well, then I lose all the keynote functionality like the viewer choosing when to go to the next slide.
    Am I missing something? I likely am, as I am new to all of this. Could you explain in more detail what you mean? Thanks.
    - Jeremy

  • How Do I create Windows Form file in VS and add the form to my VS project?

    C#, How Do I create Windows Form file in VS and add the form file to my VS project by using C# code?
    I like to create a Windows Form file into my VS Win Form project by using C#. I have the path and the file name.
    I need a Win Form with FileName.cs, FileName.Designer.cs, FileName.resx, and FileName (as you see it VS by adding a Win Form manually by using VS)
    Rune Brattas

    You cannot create a Form from code at run time. 
    For one thing, the user running your application will, almost certainly, not have  a copy of Visual Studio to hand with which to build anything.  (Not that you actually need 'Studio at all; Notepad and csc.exe are all you actually
    need), but that's another story).
    You can do this with an awful lot of pain, using the innards of the compiler from iside your own program, compiling the new Form's source code on the fly and then executing the resulting assembly within your application.  IMHO, that's a simply terrifying
    prospect especially as the code you will be compiling will be on someone else's machine and over which you will have absolutely no control.  If you're lucky, they'll spell something wrong and it won't compile.
    The "usual" way to do this sort of thing is to create additional, "plug-in" forms as library assemblies and have your program load and execute these at run-time. 
    Regards, Phill W.

  • How to Upload a PDF file into BLOB column in a table using Forms 9i

    Can anyone tell me how to upload a PDF file from client system using File dialog window and store its content in BLOB column in a table. The file to be uploaded will be in client side.

    Hi,
    please, search a bit on the forum before do a question:
    Just searching by "upload blob pdf" ...
    How to batch upload PDF files into database BLOB
    Regards,
    Jose.

  • How to Upload a PDF file into BLOB column in a table using Forms 6i

    Can anyone tell me how to upload a PDF file from client and store its content in BLOB column in a table. The file will be genered using reports and win be stored in db.The file to be uploaded will be in client side.
    Thank´s.

    If you are using version 9 or 10 use webutil.... Look in webutil.pll.
    Use either one these two fuctions...
    FUNCTION Client_To_DB( clientFile       in VARCHAR2,
                             tableName        in VARCHAR2,
                             columnName       in VARCHAR2,
                             whereClause      in VARCHAR2,
                             asynchronous     in BOOLEAN default FALSE,
                             callbackTrigger  in VARCHAR2 default NULL) return BOOLEAN;
      FUNCTION Client_To_DB_With_Progress
                         (   clientFile       in VARCHAR2,
                             tableName        in VARCHAR2,
                             columnName       in VARCHAR2,
                             whereClause      in VARCHAR2,
                             progressTitle    in VARCHAR2,
                             progressSubTitle in VARCHAR2,
                             asynchronous     in BOOLEAN default FALSE,
                             callbackTrigger  in VARCHAR2 default NULL) return BOOLEAN;

  • How to upload a PDF file in iCloud

    Hi everybody,
    I would like to know how to upload a PDF file in iCloud. I want to share some PDF files with my iPhone, MacBook and iMac.
    Thank you a lot!

    Yes, but the problem is will iBooks remember where I left off in that pdf file? Unlikely since it was deleted.  Also, what is handy about the kindle app is once you delete it an icon appears in the app to show that this file is in the cloud. I guess for reading pdfs the kindle app is better.  I am not saying that the kindle app would be that great for other things but at least with syncing and such it's much better.  Well, iCloud is meant for other things.  It's fine because I'll just use it for those other things and stick to the kindle app for reading pdfs.  Well I use endnote for reading technical pdfs, I'm just talking about novels and such on the kindle app. 

  • How to upload a PDF online, fill it, then save?

    Hi,
    I'm trying to figure out on how to upload a PDF to our own server (thru an FTP site) so users can fill it in, then save it to their computer's hard drive/desktop. i searched all over and cannot find a solution. Can someone please help?
    Thank you in-advance for any help you can provide.
    Current system:
    MacBook Pro
    Mac OS X 10.6
    Acrobat Pro 9.4.3
    Acrobat Reader 10.1

    You need to open the PDF and use File>Save as>Reader extended PDF.
    Keep in mind that there are strict limitations as to how many times you can collect data from an enabled PDF. It's basically a limit of 500 times. You'll want to read and understand section 15 of the end user license agreement before proceeding.

Maybe you are looking for

  • What's bloating my iphone iCloud backup?

    Last time I did an iCloud backup it took 2.6 gb but a few days later I tried again and it failed because it thinks the new backup needs 5.4gb to back it up. Where is this bloated figure coming from? I only added one app and it doesn't use much data a

  • Changing the Subject and Text of received mails?

    Before filing received important messages into folders, I would like to add the Sender's name into the Subject. Or I may want to add a comment to the received Text. Is it possible in Mail? (like in Entourage?) iMac G%   Mac OS X (10.4.3)  

  • Incorrect strings when importing Management Pack

    I have created a Management Pack for Operations Manager 2012 R2 using the Visual Studio Authoring Extensions. When I import my MP into Operations Manager, I see incorrect strings and my Group Views display incorrectly. I've tried completely uninstall

  • The latest upgrade notification mentioned some effect to logitech,what will it be?

    when the first notification of the latest upgrade popped up it said something about logitech equipment/add ons/settings being affected.I clicked on details but that was no help and have not been able to find anything since.I do not want to upgrade on

  • 1812 VPN dropped

    Hi, My VPN through Cisco 1812 dropped second time. In SDM Syslog there were in both time the next lines: Crypto engine: onboard 0 State changed to: Initialized Crypto Engine: onboard 0 State changed to: Enabled Interface FastEthernet1, changed state