cancel
Showing results for 
Search instead for 
Did you mean: 

Create Adobe PDF for user to download and print

Former Member
0 Kudos

Hi!

I'm tryng to create an Adobe PDF for user to download and print in Web Dynpro. I've all the information previously create into a dynamically form, but now I try to put a print button for print this form into a PDF. There are some documentation?

Thanks and sorry for my english

Accepted Solutions (1)

Accepted Solutions (1)

abhijeet_mukkawar
Active Contributor
0 Kudos

hi,

when you execute the application , the form will be opened in adobe reader services , there itself you will get the option of print button.

check this link

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e87f889e-0d01-0010-1786-83323609...

regards

Answers (1)

Answers (1)

kai_mattern2
Explorer
0 Kudos

Hi,

you can use iText (http://www.lowagie.com/iText/) to create your PDF.

As an example create a ActionButton in your view named ShowPDF and the related onActionShowPDF Method. You can Print/Save/Send via EMail etc..

(<b>Note: Part of the SourceCode posted is from the the Weblog of Prakash Singh

"Create a PDF file using JAVA which i used when i tried to solve my problem.

/people/prakash.singh4/blog/2005/04/05/create-a-pdf-file-using-java


  public void onActionShowPDF(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionShowPDF(ServerEvent)
    try
    {
        //create your document 
        Document document = new Document(PageSize.A4);
        //we need a buffer to where the PDF Content will be written into
        ByteArrayOutputStream aos = new ByteArrayOutputStream();
        //bind the pdf writer to your document and the output stream
        PdfWriter.getInstance(document, aos);
        //open the document to add your content
        document.open();
        //create a table with 3 columns
        PdfPTable table = new PdfPTable(3);
        //create a cell
        PdfPCell cell;
        //add the first row as header
        cell = new PdfPCell(new Paragraph("Rank"));
        cell.setBackgroundColor(new Color(34, 90, 141));
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("Name"));
        cell.setBackgroundColor(new Color(34, 90, 141));
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("Points"));
        cell.setBackgroundColor(new Color(34, 90, 141));
        table.addCell(cell);
        //add the data rows.
        int flag = 0;
        Color bg;
        for (int i = 0; i <= 10; i++)
        {
            //alternate colors
            if (flag == 0)
            {
                flag = 1;
                bg = new Color(204, 204, 255);
            } else
            {
                flag = 0;
                bg = new Color(255, 255, 255);
            }
            cell = new PdfPCell(new Paragraph("1"));
            cell.setBackgroundColor(bg);
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph("Prakash Singh: " + i));
            cell.setBackgroundColor(bg);
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph("" + (50000 - i * 10) + ""));
            cell.setBackgroundColor(bg);
            table.addCell(cell);
        }
        document.add(table);
        document.close();
        
        //ok we have now a filled bytearray with our PDF content and we want to display it 
        byte[] pdfContent=aos.toByteArray();
        IWDCachedWebResource pdfResource = WDWebResource.getWebResource(pdfContent,WDWebResourceType.PDF);
        wdComponentAPI.getWindowManager().createExternalWindow(pdfResource.getURL(),"Test View",true).open();


    } catch (Exception e)
    {
    }

Former Member
0 Kudos

Hi Kai,

I am to pass a image to PDF.

Can you please give me the code for that.

Regards

Anumit