cancel
Showing results for 
Search instead for 
Did you mean: 

Insert image in pdf Document

Former Member
0 Kudos

Hi,

I've a model and this model, I show in pdf. I Know insert rows and columns and pdf document (PdfPtable, PdfPCell...),but I don't know insert a image in the pdf document. How can I do it?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi guillermo,

PdfPTable head = new PdfPTable(1);

head.getDefaultCell().setBorder(0);

Image image = Image.getInstance(logoUrl);

PdfPCell imageCell = new PdfPCell(image);

imageCell.setBorder(0);

imageCell.setHorizontalAlignment(PdfCell.ALIGN_RIGHT);

head.addCell(imageCell);

regards, jens

Former Member
0 Kudos

Hi, Jens.

How I insert the image if my image is in the same folder that the class?

I don't know how can I put the "logoUrl".

Thanks.

Former Member
0 Kudos

Hi Guillermo,

.

in your webdynpro application add all needed images to "src/mimes/Components/<component_name>".

try {

// determine the current portal and select the appropriate image

String logo = "xyz.gif";

String path =

WDURLGenerator.getAbsoluteWebResourceURL(

wdComponentAPI.getDeployableObjectPart(), logo);

} catch(WDURLException e1) {

}

Former Member
0 Kudos

Hi Jens,

I'm not developing a WebDynpro application. I'm developing a .par archive

Former Member
0 Kudos

hi guillermo,

than put your image in the dest-->images folder and use the following coding:

public static String getImageUrl(IPortalComponentRequest request, String imageName) {

StringBuffer buffer = new StringBuffer(1024);

HttpServletRequest httpRequest = request.getServletRequest();

String protocoll = (httpRequest.isSecure())? "https" : "http";

buffer.append(protocoll)

.append("://")

.append(httpRequest.getServerName())

.append(httpRequest.getServerPort())

.append(request.getWebResourcePath())

.append("/images/")

.append(imageName);

return buffer.toString();

}

regards, jens

Former Member
0 Kudos

Hi Jens,

I've tested that and It didn't function. My image is in .par dist/image. Is there anything way to show the image in pdf?

Thanks

Former Member
0 Kudos

Hi Guillermo,

the coding - I sent you - is from a project 2 years ago and currently runs productive. Therefore I can insure it works.

Why it is not working in your context, I can't tell you.

Find it out by debugging your app, check the image url by requesting the resource directly in the browser and so on...

or post the stacktrace or detailed error description. "It didn't finction" will not help to find out the reason.

regards, Jens

Former Member
0 Kudos

Hi Guillermo,

the coding - I sent you - is from a project 2 years ago and currently runs productive. Therefore I can insure it works.

Why it is not working in your context, I can't tell you.

Find it out by debugging your app, check the image url by requesting the resource directly in the browser and so on...

or post the stacktrace or detailed error description. "It didn't finction" will not help to find out the reason.

regards, Jens

Former Member
0 Kudos

Hi Jens,

I've solved the problem.

Thank you.

Answers (0)