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