cancel
Showing results for 
Search instead for 
Did you mean: 

UpLoad Data to PDF

srinivas_sistu
Active Contributor
0 Kudos

Hi All,

I am tring to upload the data from WD Java to PDF using iText API, which I saw in an article by Ayyappa Raj . Below is the code i am using. it is opening a poup and then starting the adobe reader after that I am getting an empty screen. No data is getting displayed.

Document document = null;

PdfWriter writer = null;

//IWDResource resource = null;

ByteArrayOutputStream outputStream = null;

try

{

document = new Document(PageSize. A4, 50, 50, 50, 50);

outputStream = new ByteArrayOutputStream();

writer = PdfWriter. getInstance(document, outputStream);

PdfWriter.getInstance(document, outputStream);

document.open();

document.add(new Paragraph("Hello We Created a PDF File"));

document.add(new Paragraph(new Date(System.currentTimeMillis()).toString()));

byte[] html=new byte[4096];

html=outputStream.toByteArray();

document.close();

writer.close();

IWDWindow win =wdThis.wdGetAPI().getComponent().getWindowManager()

.createNonModalExternalWindow(WDResourceFactory.createCachedResource(html,"PDF File", WDWebResourceType.PDF)

.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal()),"PDF File");

win.setWindowSize(600,600);

win.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);

win.removeWindowFeature(WDWindowFeature.TOOL_BAR);

win.removeWindowFeature(WDWindowFeature.MENU_BAR);

win.show();

outputStream.close();

} catch (Exception e) {

wdComponentAPI.getMessageManager().reportException("Exception::"+e,false);

}

Please help, where I am doing the mistake?

Regards,

SrinivaS

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I am not sure though,but I would ask you try writing the following close statements after showing the pop up window

document.close();

writer.close();

srinivas_sistu
Active Contributor
0 Kudos

Hi,

I tried that, still no luck....

Regards,

SrinivaS

Former Member
0 Kudos

Hi,

I think there in no problem with your code, but the problem is with the lib folder which you are using for iTextAPI guess..at runtime it is not picking the API..

Try to have a look at this link you can get some idea on this, he also faced same kind of issue

Hope this helps you..

Regards,

Saleem

srinivas_sistu
Active Contributor
0 Kudos

Hi All,

Any help???

Regards,

SrinivaS