Skip to Content
avatar image
Former Member

Creating PDF using ITEXT API's - error

Hi,

In my WebDynpro Application I want to generate a PDF (using ITEXT API's) out of the data retrieved from back end system .

I used this source code.

Document document = new Document(PageSize.A4);
document.open();
PdfPTable table = new PdfPTable(1);
PdfPCell cell;
cell = new PdfPCell(new Paragraph("ONE"));
table.addCell(cell);
cell = new PdfPCell(new Paragraph("TWO")); 	
table.addCell(cell);
 
document.add(table);
document.close();
 
byte[] b = new byte[100 * 1024];
b =  document.toString().getBytes("UTF-8");
		
IWDCachedWebResource pdfRes = WDWebResource.getPublicCachedWebResource(b, WDWebResourceType.PDF, WDScopeType.CLIENTSESSION_SCOPE, 	wdThis.wdGetAPI().getComponent().getDeployableObjectPart(),"FileNameHelloText"));

I have used Window Manager to create a external window with the URL from pdfRes.getUrl() method.

After execution i get a pop up window with out PDF document.

Please let me know your thoughts & solutions to the above mentioned problem.

Thanks

Senthil

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jan 30, 2007 at 07:46 AM

    Hi,

    There was some issues related to URL generation. I fixed it. It works now.

    Thanks

    Senthil

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 16, 2007 at 08:47 PM

    Hello Folks,

    Use the following snippet of the code to generate PDF using ITEXT API.

    Document document = new Document(PageSize.A4);

    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    PdfWriter.getInstance(document, bos);

    document.open();

    PdfPTable table = new PdfPTable(1);

    PdfPCell cell;

    cell = new PdfPCell(new Paragraph("ONE"));

    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("TWO"));

    table.addCell(cell);

    document.add(table);

    document.close();

    byte [] byteContent = bos.toByteArray();

    IWDCachedWebResource cachedResource =

    WDWebResource.getPublicCachedWebResource(

    byteContent,

    WDWebResourceType.PDF,

    WDScopeType.CLIENTSESSION_SCOPE,

    wdThis

    .wdGetAPI()

    .getComponent()

    .getDeployableObjectPart(),

    "TestPDF");

    IWDWindow externalWindow =

    wdComponentAPI

    .getWindowManager()

    .createExternalWindow(cachedResource.getURL(), "PDF Window",true);

    externalWindow.open();

    // .....

    Thanks and Regards,

    Gopi

    Add comment
    10|10000 characters needed characters exceeded