Forums de discussion

TIF image type not displaying

thumbnail
Ramalingaiah. D, modifié il y a 7 années.

TIF image type not displaying

Expert Publications: 486 Date d'inscription: 16/08/14 Publications récentes
Hi,

New Version Liferay 7, It is possible or not

I need the solution for tif image displaying.


Can you give?????????


Regards,
Ram
thumbnail
David H Nebinger, modifié il y a 7 années.

RE: TIF image type not displaying

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
thumbnail
Ramalingaiah. D, modifié il y a 7 années.

RE: TIF image type not displaying

Expert Publications: 486 Date d'inscription: 16/08/14 Publications récentes
Hi David,
sorry David,
i am telugu medium

thank you for helping
Ram
thumbnail
David H Nebinger, modifié il y a 7 années.

RE: TIF image type not displaying

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
Hey, Ram, no problem.

Tiffs have long been supported by the printer world, but you've always needed special software just to display them on the desktop. I was actually surprised to see that any browser supported them.
thumbnail
Ramalingaiah. D, modifié il y a 7 années.

RE: TIF image type not displaying

Expert Publications: 486 Date d'inscription: 16/08/14 Publications récentes
Hi david
my tiff files to pdf files converter working fine,

package com.tiff.converter;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.im4java.core.ConvertCmd;
import org.im4java.core.IMOperation;

import com.itextpdf.text.Document;
import com.itextpdf.text.Image;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.text.pdf.RandomAccessFileOrArray;
import com.itextpdf.text.pdf.codec.TiffImage;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.repository.model.Folder;
import com.liferay.portal.kernel.util.MimeTypesUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.ServiceContextFactory;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.documentlibrary.model.DLFolder;
import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
import com.liferay.portlet.documentlibrary.service.DLAppServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;

public class TiffileConvert extends MVCPortlet {

@Override
public void render(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
// TODO Auto-generated method stub
ThemeDisplay themeDisplay = (ThemeDisplay) request
.getAttribute(WebKeys.THEME_DISPLAY);
super.render(request, response);
System.out.println("Render Request");
Long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
List<DLFileEntry> fileEntryService = null;

try {
DLFolder folder = DLFolderLocalServiceUtil.getFolder(
themeDisplay.getScopeGroupId(), parentFolderId, "document");

fileEntryService = DLFileEntryLocalServiceUtil.getFileEntries(
themeDisplay.getScopeGroupId(), folder.getFolderId(), -1,
-1, null); // 12345 is folderId
} catch (PortalException
| com.liferay.portal.kernel.exception.SystemException e) {
e.printStackTrace();
}
for (DLFileEntry fileEntryObj : fileEntryService) {

System.out
.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+ fileEntryObj.getTitle());
Document TifftoPDF = new Document();
try {
// Read the Tiff File
RandomAccessFileOrArray myTiffFile = new RandomAccessFileOrArray(
"http://localhost:8080/documents/10662/11204/tiff/6f3d85ff-d80a-4d77-ad51-db6b2cdf7e25?t=1469158931000");
// Find number of images in Tiff. file
int numberOfPages = TiffImage.getNumberOfPages(myTiffFile);
System.out.println("Number of Images in Tiff File::::"
+ numberOfPages);
PdfWriter.getInstance(TifftoPDF, new FileOutputStream(
"G:/OCR/pdf/"+fileEntryObj.getTitle()+".pdf"));
TifftoPDF.open();
// Run a for loop to extract images from Tiff file
// into a Image object and add to PDF recursively
for (int i = 1; i <= numberOfPages; i++) {
Image tempImage = TiffImage.getTiffImage(myTiffFile, i);
// tempImage.scaleToFit(pdfDoc.getPageSize());
TifftoPDF.add(tempImage);
}
TifftoPDF.close();
File file = new File("G:/OCR/pdf/"+fileEntryObj.getTitle()+".pdf");
uploadFile(themeDisplay ,request, file);
System.out.println("Tiff to PDF Conversion in Java Completed");
} catch (Exception i1) {
i1.printStackTrace();
}
}

}

public void uploadFile(ThemeDisplay themeDisplay,
RenderRequest renderRequest, File file) {
String folderName = "document";
System.out.println("Exist=>" + file.exists());
long repositoryId = themeDisplay.getScopeGroupId();
String mimeType = MimeTypesUtil.getContentType(file);
String title = file.getName();
String description = "png file";
String changeLog = "file";
Long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
try {
Folder folder = DLAppServiceUtil.getFolder(
themeDisplay.getScopeGroupId(), parentFolderId, folderName);
ServiceContext serviceContext = ServiceContextFactory.getInstance(
DLFileEntry.class.getName(), renderRequest);
InputStream is = new FileInputStream(file);
DLAppServiceUtil.addFileEntry(repositoryId, folder.getFolderId(),
file.getName(), mimeType, title, description, changeLog,
is, file.getTotalSpace(), serviceContext);
} catch (Exception e) {
System.out.println("Exception");
e.printStackTrace();
}
}
}
thumbnail
Ramalingaiah. D, modifié il y a 7 années.

RE: TIF image type not displaying

Expert Publications: 486 Date d'inscription: 16/08/14 Publications récentes
Hi,

my task is to display tif image....what i'm doing is converting tiff to pdf then displaying pdf.

i have done this conversion by using folders...now..i want this tiff image as in vesion 1.0 means then that converted pdf as in version 1.1
thumbnail
David H Nebinger, modifié il y a 7 années.

RE: TIF image type not displaying

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
Not really sure what you're asking here, Ram...






Come meet me at the LSNA!