cancel
Showing results for 
Search instead for 
Did you mean: 

Generating PDF using toolbar script

Former Member
0 Kudos

Hi All,

I am trying to create a PDF using a toolbar script and iText libraries.

I need to convert an MSA to a PDF.

What I want to know is that after the PDF is created, how can I auto open it in IE without human intervention.

Any pointers shall be highly appreciated.

Regards,

Himanshu

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello,Expert,

we tried creating the PDF using the following script, and got an error. Could you please give me some adviece about it!!

Many thinks..

the Script is:

para = new Paragraph("asdsadsdsadsadas");

Document doc1 = new Document();

ByteArrayOutputStream bos = new ByteArrayOutputStream();

PdfWriter.getInstance(doc1,bos);

doc1.open();

doc1.add(para );

doc1.close();

FileInputStream nos = new FileInputStream(bos);

//newAttachment = TypeFactory.createAttachment();

//newAttachment.setFileData("Vendor Admit Certificate",nos,doc,session);

The Error Message is:

Typed variable declaration : Constructor error: Can't find constructor:

java.io.FileInputStream( java.io.ByteArrayOutputStream ) in class: java.io.FileInputStream

Former Member
0 Kudos

Hi Himanshu,

Were you able to make this work?

We are trying to either attach the PDF into the document or open it in IE, when the toolbar script is clicked.

Do you have any suggestions?

Thanks & Regards,

Reshma

Former Member
0 Kudos

For your reference, we tried creating the PDF using the following script, and got an error :

import java.io.*;

import com.itestpackage.text.*;

import com.itextpackage.text.pdf.*;

static String para = "test data";

Document doc = new Document ();

PdfWriter.getInstance (doc, new FileOutputStream ("descent.pdf"));

doc.open ();

Paragraph p = new Paragraph (para);

p.setAlignment (Element.ALIGN_JUSTIFIED);

doc.add (p);

doc.close ();

But we get an error on the new Document();

Could you help us with this?

Thanks & Regards,

Reshma

Former Member
0 Kudos

Hi,

Replace doc by document.Doc is the generic name used by the script to refer to the current document.

Regards,

Himanshu

Former Member
0 Kudos

Hi Himanshu,

That was a typo by me.

The script is:

Document doc1 = new Document();

The error is still there.

Regards,

Reshma

Former Member
0 Kudos

Hi,

I got a hint from another expert consultant that I should write to a ByteOutputstream rather than file output stream and then add this as an attachment to the document.

I am working on this approach now.

Regards,

Reshma

Former Member
0 Kudos

Ya...if you want to add as an attachmet then you have to use ByteOutputstream

Former Member
0 Kudos

Hi HImanshu,

We corrected the problem we were facing earlier. It was because we were using a version of IText not compatible with our system. We used a lower version and it is now able to recognise the type 'Document'.

The error we now face is in converting the PDF into a Bytestream recognised by the attachment type of E-Sourcing.

I would really appreciate it if you could help with this.

Thanks & Regards,

Reshma

Former Member
0 Kudos

Hi,

Were you able to solve the problem?

Regards,

Himanshu

Former Member
0 Kudos

Hi Himanshu,

We are still facing the error and unable to attach the PDF.

Would really appreciate your help.

Regards,

Reshma

Former Member
0 Kudos

Hi Experts,

How to import Itext library jar file in sap sourcing.can any one give suggestion on this


Regards,

Eswar