08-25-2010 12:15 PM
08-27-2010 08:03 AM
09-02-2010 12:06 PM
public void actionBoutonImprimer(NodeRef pNodeRef, String pCategory)
throws IOException, COSVisitorException, InterruptedException {
String lFileName = (String) nodeService.getProperty( pNodeRef,
ContentModel.PROP_NAME );
ContentReader lContentReader = contentService.getReader( pNodeRef,
ContentModel.PROP_CONTENT );
File file1 = File.createTempFile( "TempFile", ".pdf" );
lContentReader.getContent( file1 );
File file2 = null;
file2 = createMetaFile( pNodeRef, pCategory );
File file3 = File.createTempFile( "TempFile3", ".pdf" );
PDFMergerUtility pdfmerge = new PDFMergerUtility();
pdfmerge.setDestinationFileName( file3.getPath() );
pdfmerge.addSource( file1 );
pdfmerge.addSource( file2 );
pdfmerge.mergeDocuments();
FacesContext fc = FacesContext.getCurrentInstance();
HttpServletResponse resp = (HttpServletResponse) fc
.getExternalContext().getResponse();
int length = 0;
ServletOutputStream op = resp.getOutputStream();
resp.setContentType( "application/pdf" );
resp.setContentLength( (int) file3.length() );
resp.setHeader( "Content-Disposition", "inline; filename=\""
+ lFileName + "\"" );
byte[] bbuf = new byte[1];
DataInputStream in = new DataInputStream( new FileInputStream( file3 ) );
while ((in != null) && ((length = in.read( bbuf )) != -1))
{
op.write( bbuf, 0, length );
}
in.close();
op.flush();
op.close();
file1.delete();
file2.delete();
file3.delete();
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.