Skip to Content
0
Former Member
May 18, 2011 at 10:07 PM

creating pdf typed resource from InputStream

53 Views

Hi,

I red mail attachment (.pdf typed) into InputStream.

I tryed to create pdf typed resource from InputStream.

But it does not act as pdf document (wdContext.currentContextElement().setResource(res))

My aim is to parse pdf (adobe form) into fields.

Regards.

public void ReadFile( java.lang.String filename, java.io.InputStream input )
  {
    //@@begin ReadFile()

		try {			
			BufferedInputStream bis1 = new BufferedInputStream(input);
			BufferedInputStream bis2 = new BufferedInputStream(input);

			int aByte;
			int size = 0;
			while ((aByte = bis1.read()) != -1) {
				size++;
			}
			bis1.close();

			byte[] b = new byte[size];

			bis2.read(b, 0, size);
			bis2.close();

			IWDResource res =
				WDResourceFactory.createCachedResource(
					b,
					filename,
					WDWebResourceType.PDF);
			wdContext.currentContextElement().setResource(res);