PDF creation with images

Hi there,

I am trying to create a PDF inside webMethods and found the helpful package PDFCreator (and it’s samples).

I am required to have images inside the PDF document.

In the PDFCreator sample ‘basicParagraph’ it references a getImage service, however this does not exist in the downloadable PDFCreator package on here (or the old wmusers for that matter).

Does anybody know where a version of the PDFCreator package is that contains this service?

The package version I have is 1.0 however the author (David Vilaverde) may not have versioned the package.

Regards,

David.

we want to creation of pdf page by using pub.flow:setRespose in this we give the contentype is applicaiton/pdf then it shows the pdf file.

we want to creation of pdf page by using pub.flow:setRespose in this we give the contentype is applicaiton/pdf then it shows the pdf file.

@David,

Please explore Apache PDFBox, which seems to have that functionality.

Ref: java - Can't add an image to a pdf using PDFBox - Stack Overflow

HTH.

Thanks,
Rankesh

1 Like

HI there
I have ever tried to create the PDF with image source files using this code:
///


/// create PDF Document object from image source
///

///
///
public PDFDocument CreateImageOnlyPDFDocumentDemo(List images)
{
return new PDFDocumentt(images);
}
YOu can also have a try.Or just google one of the PDF creater to help you out.

Hi All

This is the code which I used

package CodeAnalysis.utils.others;

import com.wm.data.;
import com.wm.util.Values;
import com.wm.app.b2b.server.Service;
import com.wm.app.b2b.server.ServiceException;
import com.itextpdf.text.Document;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.html.simpleparser.HTMLWorker;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.tool.xml.XMLWorkerHelper;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.FileWriter;
import java.io.ByteArrayInputStream;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.StringBufferInputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.
;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.awt.;
import javax.swing.JFrame;
import javax.swing.text.html.StyleSheet;
import java.io.
;
import java.net.;
import javax.net.ssl.
;

public final class createitextPdf_SVC

{

/** 
 * The primary method for the Java service
 *
 * @param pipeline
 *            The IData pipeline
 * @throws ServiceException
 */
public static final void createitextPdf(IData pipeline) throws ServiceException {
	 
	try {
		
	
		// pipeline
		IDataCursor pipelineCursor = pipeline.getCursor();
			String	Report = IDataUtil.getString( pipelineCursor, "Report" );
			String	AbsoluteFileName = IDataUtil.getString( pipelineCursor, "AbsoluteFileName" );
		pipelineCursor.destroy();
	 
	Document document = new Document();
	PdfWriter writer = PdfWriter.getInstance(document,new FileOutputStream(AbsoluteFileName));
	document.open();
	XMLWorkerHelper.getInstance().parseXHtml(writer, document,new StringReader(Report));
	document.close();
	         }
	    catch (Exception e) {
	    	System.out.println("**********************Error Occured from here ***************************************************");
	      e.printStackTrace();
	      System.out.println("**************************************************Error Ends Here **********************************************");
	    }
		
}

// --- <<IS-BEGIN-SHARED-SOURCE-AREA>> ---


	

// --- <<IS-END-SHARED-SOURCE-AREA>> ---

}

Give the input Report as html string which contains all your texts and images(images with relative path of the server)
and AbsoluteFilename as a “location\filename.pdf” in your server .
Do download itextpdf-5.5.0 and place in <IS\lib\jars>