JasperReports - how to save as PDF from Print Preview page?

Hi all!
How can I save reports created with JasperReperts (with iReport tool) as PDF?
On print preview, when I select it is as PDF, and click on "save", nothing is saved. Also, I get NoClassDefFoundError despite I included all nessesry classes (did I?). Here are list of included classes
jasperreports-1.2.7.jar;
jasperreports-1.2.7-javaflow.jar;
commons-beanutils-1.5.jar;
commons-collections-2.1.jar;
commons-logging-1.0.2.jar;
commons-digester-1.7.jar;Here is my code:
void printWithPreview() {
    try {
      JasperPrint print = JasperFillManager.fillReport(report, reportParam, conn);
      JasperViewer.viewReport(print, false);
      //byte[] pdfasbytes = JasperExportManager.exportReportToPdf(print); // can I use it somehow?
      JasperExportManager.exportReportToPdf(print);
    } catch (JRException e) {
      e.printStackTrace();
  }Can you help me with this?
Also, I need to know, how to limit options "save as" only to PFD (on same Print Preview page)?
Thank you in advance!

Right!
I was missing iText.jar.
So, you need only this code to get report preview and feature to export to pdf, html and other formats:
void printWithPreview() {
    try {
      JasperPrint print = JasperFillManager.fillReport(report, reportParam, conn);
      JasperViewer.viewReport(print, false);
      JasperExportManager.exportReportToPdf(print);
    } catch (JRException e) {
      e.printStackTrace();
  }You do not need to save it specificly to c: or other "hard coded" directory.
Thanx 1000 times!!!

Similar Messages

  • Save as PDF from Print - corrupted file ?

    I have been saving to PDF copies of the same web page since 2010.  I've only just realised that all the files saved since December 2012 have been corrupted in some way.  They are all viewable and will print normally but, the Find function in Preview cannot find any text within those files (not even a single letter).  Similarly, Spotlight cannot find any text in those files.
    If I double-click on a word in one of those files, only the nearest letter is selected.  I can copy text from these files but, when I paste that text into another application, I get unprintable characters.  They are all ASCII 252.  If I copy and paste from the web page (instead of the saved PDF), I get normal text.
    It looks to me that the Quartz renderer is corrupting all text in the print to PDF function.  The change occurred between 22/12/12 and 5/1/13 when I upgraded from OS X 10.6.8 to 10.8.2.  So, I think the bug was introduced in either 10.7, 10.8.1 or 10.8.2.  I'm now using 10.10.1.
    Has anyone encountered this issue ?
    Thanks.

    YES!!!!!!!
    I was pulling my hair out last night over this. I noticed the Find function was not working properly. I KNEW there was something in the PDF and Preview was not showing it. I spent 2 hours trying to find someone with a similar Find function problem, but could not find much. Also, it could not copy and paste text. I KNOW it worked before because I had taken notes on this particular PDF and had copy and pasted whole paragraphs for myself into Pages. Which is what got me searching online tonight.
    I re-downloaded the same PDF. When first opened in Preview, the Find and copy/paste functions worked. Same thing in Acrobat reader and Acrobat Pro. After confirming this, I re-opened it in Preview, highlighted some text and closed. It asked to Save Changes and I did. I immediately re-opened it, and guess what? Find no longer works and neither does copy/paste. Just to be sure, I tried re-opening in Acrobat reader and Pro; same thing. No copy/paste, corrupted Find feature. Well, copy/paste sort of functions, its just that it pastes a square with an alien head in it that says "Private Use 100000 Plane 16".
    And finally, on some PDFs that have not even been saved in Preview, the Find function is not working properly also. It happened on the re-downloaded PDF I just talked about. It finds many instances of the word, bit the left and right arrows next to "Found on X# Pages are greyed out and do not move through the document. Once I go to the left pane that displays page thumbnails and click on a few different ones, THEN it starts working.
    So yes, Apple, Preview is corrupting PDF files upon save, AND it is not working properly on other files. Please fix this. PLEASE.
    And my specs are the same as Gary; iMac 27 inch Late 2009, Yosemite 10.10.1. Is ANYONE else having this issue with a different Mac?

  • Save as PDF from printer dialog requires two tries

    When trying to save a file as a PDF from the printer dialog it takes two tries. When the save dialog appears I hit return and it immediately returns with nothing saved. The second time the file is saved normally. According to Adobe this is being caused by Apple PDF Creator; however my selected printer is Adobe PDF 9.0. I have retried resetting the printer using the System Preferences panel with no change. This is really annoying, any suggestions?

    Thank you. I would go back to Adobe and reiterate that this doesn't happen when a non-Adobe printer is active. They are probably not setting something up correctly the first time through. Also, unless AdobePDF offers something crucial when creating PDFs, you could switch the printer as a workaround.

  • How to save an image from an web page?

    Hello everybody!
    I have a problem and I hope someone can help me :).
    I am trying to save/download an image from an web page to my computer. So given an URL which contains the image, I want to save this/write this image to disk. Here is my code:
    import java.net.*;
    import java.io.*;
    public class Test{
        public static void main(String[] args) throws Exception{
            Test test = new Test();
            test.readFile();
        public void readFile() throws Exception{
            InputStream inputStream = new URL("http://www.google.se/images/hp1.gif").openStream();
            InputStreamReader reader = new InputStreamReader(inputStream);
            BufferedReader buffReader = new BufferedReader(reader);
            BufferedWriter bw = new BufferedWriter(new FileWriter("savedImage.gif"));
            int x=0;
            while((x = buffReader.read()) != -1) {
                bw.write(x);
            bw.flush();
    }The code saves the image to disk, but unfortunately the image is distorted. Can anyone help me to solve this problem.
    Thanx in advance
    Best regards
    /TheMan

    thanx guys for your quick answers. I got i to work with the following code
    InputStream inputStream = new URL("http://www.google.se/images/hp1.gif").openStream();
            FileOutputStream fos = new FileOutputStream(new File("savedImage.gif"));
            int x=0;
            while((x = inputStream.read()) != -1) {
                fos.write(x);
            fos.flush();Again, thanx guys!

  • How to activate "Send mail" from print preview in ME23N

    In ME23N there is a "print preview"-button that shows a preview of the PO. In the preview-windows there is a Text-menu with a "Send mail"-command, but that command is not active. How can I activate this command so that it is possible to send the PO to an email-recepient?
    I have configured the smtp-functionality (SCOT++) and sending PO's as email to suppliers in ME9F works fine by choosing "Send external". But still the Send mail-option is inactive in preview-mode. Any tips?
    Regards,
    Thor-Egil

    please maintain output condition record (MN04) as "external send"
    Also make sure that you have maintained the proper email ID in vendor master

  • How do I save a pdf from Gmail to my adobe reader?

    How do I save a pdf from Gmail to my adobe reader?
    how can i solve this?

    fats vee,
    Please take a look at my replies and screenshots in the following forum post to transfer a PDF email attachment from the Gmail app for iOS to Adobe Reader for iOS.
    How do I save a PDF attachment from Gmail to Adobe reader?
    As I mentioned in the forum post, it requires many extra steps to transfer a PDF document from the Gmail app.  This is because the Gmail app for iOS does not support "Open In..." as many other iOS apps do.
    Please let us know if you have additional questions.

  • How to remove "Save as PDF" from context menu

    The item "Save as PDF" leads to a commercial site called NITRO. I am trying to eliminate it from the context menu. I installed the add-on Menu Edit and changed the item Save as PDF from visible to hidden on my Windows 8.1 PC with Firefox 30. However, the item did not disappear from the context menu. Yet on my PC with Linux Mint 17 with Firefox 30 for Linux Mint the item is gone from the context menu. My PC s linked with Firefox Synch.
    How can I remove this?

    Such an entry in the context menu is likely added by a PDF related extension, so check your extensions.
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem.
    *Switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance
    *Do NOT click the Reset button on the Safe Mode start window
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • When I save a PDF from Illustrator the art board is cropped or has moved. How can i stop this from h

    When I save a PDF from Illustrator the art board is cropped or has moved. How can i stop this from happening?

    What is your operating system?
    Can you open that PDF with a text editor and check that the first four characters are '%PDF'.

  • Hi there, i've just finish our schools year book (voluntarily) and it has 155 pages incl. front/backcover. This file has 1800 links a lot of photos and a few reports. everytime i go to save as PDF it freezers on page 66. i need the book printed in hi-res?

    hi there, i've just finish our schools year book (voluntarily) and it has 155 pages incl. front/backcover. This file has 1800 links a lot of photos and a few reports. everytime i go to save as PDF it freezers on page 66. i need the book printed in hi-res? im running out of "printing time" as we need it back to school by 10th december for 12th December distribution.
    what do i do? if i save it in low res pdf everything will be a blur...can someone please come to my rescue. i have a
    OS X version 10.8.2,
    Processor: 3.06 GHz Intel Core 13,
    Memory 4 GB 1333 MHz RAM
    Startup Disk is Moutain Lion
    my file is about 24 GB I Purchased a 32 GB USBA stik to save and send to printers.
    PDF made easy assistance please anyone out there....?

    I do not have InDesign so I can't help you there.
    Here is an article from Adobe:
    http://helpx.adobe.com/indesign/using/exporting-publishing-pdf.html
    Export an open document to PDF for printing
    Choose File > Export. 
    Specify a name and location for the file.
    For Save As Type (Windows) or Format (Mac OS), choose Adobe PDF (Print), and then click Save.
    When you select the Adobe PDF (Print) option, you cannot include interactive elements in the PDF. To export an interactive document to PDF, see Create interactive documents for PDF.
    Do one of the following:
    To use a predefined set of job options, choose a preset from the Adobe PDF Preset menu.To create a PDF/X file, either choose a PDF/X preset from the Adobe PDF Preset menu, or choose a predefined PDF/X format from the Standard menu.To customize options, select a category from the list on the left and then set the options.
    For Compatibility, choose the lowest PDF version necessary to open the files you create.
    Click Export (Windows) or Save (Mac OS).
    To reset options to the default, in the Export Adobe PDF dialog box, hold down Alt (Windows) or Option (Mac OS) and click Reset. (The Cancel button changes to Reset.)

  • How can I convert Pdf from RGB to CMYK, keeping font color 100% K while working in Illustrator?

    How can I convert Pdf from RGB to CMYK, keeping font color 100% K while working in Illustrator?
    When I try to open the document in Illustrator and I convert to CMYK the black font converts to rich black, but to set up for Offset printintg I need the text to be only in Black (100%K).
    The original source of the document is a Microsoft Word file, I have converted the Word file to Pdf in order to setup for OFfset Printing.
    Thanks

    I have tried that way, but the downside is that the fonts are set in gray not in a 100%K, also I have to deal with other fonts that are composites and meant to stay Full Color. I could select text by text and convert to gray but, its a 64 page document and I wouldn't want to make a expensive mistake.

  • How to save downloaded files from safari for offline use?

    Need help how to save downloaded PDF or images from Safari for offline use. On Mac or PC, we "save as" the files. How do you do it on safari on iPhone?

    You can't detach email attachments as separate files, though you can view supported formats as attachments. If you're viewing webmail with Safari, the attachments aren't saved on the iPhone.
    Apple hasn't made any announcements about new feature for the iPhone and rarely does. The other iPhone users in this user-to-user forum have no access to unannounced Apple plans, and speculation about them is prohibited by the forum Terms of Use.
    If you want to make a suggestion to Apple, post it on the iPhone Feedback page:
    http://www.apple.com/feedback/iphone.html
    Message was edited by: modular747

  • How to save as PDF a webpage in iPad safari?

    How to save as PDF a webpage in iPad safari? Thanks!

    I use the app Save2PDF. It allows you to "print" to a PDF.

  • Silent print a PDF from a web page using Flex. We are targeting Windows and Mac with Arcobat reader installed

    We are planning to Silent print a PDF from a web page using Flex. We are targeting Windows and Mac with Arcobat reader installed. I have tried using the AIR appliaction and it worked, But our requirement is NO INSTALL to the user machine for the silent printing. It is just from web page and silent printing to the default printer to the desktop/Laptop. Can anyone share your thoughts and experience with us. It will be very helpful..
    For AIR : I tried the thread Re: AIR and PDF showing/silent printing

    Hey CodeMonkey & Ross,
    Did you either of you ever find a solution? I'm stuck too, it seems I can get remote printing on all these PDFs to work but it just prints a blank page since I've been using Javascript in the browser, not Adobe's (they are Engineering drawings that I do not have permission to edit so I can't just insert code into them but I need to make work instructions). I've been scouring the internet for hours now, it seems that this thread is the only relevant/useful one at this point. No one else was trying to achieve this for similar reasons to mine.
    Thanks guys,
    Lox

  • How to save a datas from serial port?

    How to save a datas from serial port?

    Hi
    I need some help about rs-232 communication. I want to make a vi witch can do this things:
    -read a txt file (to simulate a serial port like when the datas are coming)
    i will get 3 different data in serial port (like this: 121 213 135)
    i want to save in a txt file what datas get my vi
    so
    -write in a txt file or draw in a diagram (or both)
    so my problem is: read in serial port and save in a file and draw a diagram.
    if anybody can help pls HELP ME because im a beginner in this problem.
    I already do something but Im not sure that good.
    Thx for all.

  • How to save filled PDF in adobe reader 9.0

    Can you please tell me how to save filled PDF in adobe reader 9.0 with all the filled details

    You cannot buy 8 or 9.
    In X (10 - which you can't buy either), you can do File > Save as > Reader Extended PDF > Enable additional features.
    Important notes:
    1. KEEP THE ORIGINAL. Once rights are added many kinds of editing are permanently locked out.
    2. THERE ARE STRICT LIMITS on the number of people who can save a form. Details in the EULA: check it carefully (or have a lawyer check it).
    Also note that Reader XI can save forms with no special preparation.

Maybe you are looking for