02-13-2015 05:29 AM
02-16-2015 05:53 AM
02-16-2015 06:10 AM
02-16-2015 07:45 AM
ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
writer.putContent(inputStream);
02-16-2015 08:23 AM
Document document = new Document();
// step 2
PdfWriter.getInstance(document, new FileOutputStream(filename));
// step 3
document.open();
// step 4
document.add(createFirstTable());
// step 5
document.close();
public static final String RESULT = "results/part1/chapter04/first_table.pdf";
02-16-2015 08:35 AM
Document document = new Document();
// step 1
ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
// step 2
PdfWriter.getInstance(document, writer.getContentOutputStream());
// step 3
document.open();
// step 4
document.add(createFirstTable());
// step 5
document.close();
02-16-2015 08:46 AM
InputStream inputStream = new ByteArrayInputStream(content.getBytes(encoding));
02-16-2015 09:26 AM
02-17-2015 04:23 AM
package my.action.executer;
import java.util.List;
import my.model.myModel;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import com.itextpdf.text.Document;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
public class InsertArchiveStamp extends ActionExecuterAbstractBase
implements InitializingBean {
public static final String NAME = "watermark";
public static final String PARAM_TEXT = "watermark-text";
private ContentService contentService;
protected NodeService nodeService;
public void setContentService(ContentService contentService) {
this.contentService = contentService;
}
public void afterPropertiesSet() throws Exception {
Assert.notNull(contentService);
}
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
Document document = new Document();
// step 1
try{
ContentWriter writer = contentService.getWriter(actionedUponNodeRef, ContentModel.PROP_CONTENT, true);
// PdfContentByte canvas = ((PdfWriter) writer).getDirectContent();
// step 2
PdfWriter.getInstance(document, writer.getContentOutputStream());
// step 3
document.open();
//////////////////////////////////////////////////////
// a table with three columns
PdfPTable table = new PdfPTable(4);
// the cell object
PdfPCell cell;
// we add a cell with colspan 3
cell = new PdfPCell(new Phrase("Примено:"));
cell.setColspan(4);
table.addCell(cell);
cell = new PdfPCell(new Phrase("Орг.един."));
table.addCell(cell);
// we add the four remaining cells with addCell()
table.addCell("Број:");
table.addCell("Прилог:");
table.addCell("Вредност:");
cell = new PdfPCell(new Phrase(""));
cell.setRowspan(2);
table.addCell(cell);
cell = new PdfPCell(new Phrase(""));
cell.setRowspan(2);
table.addCell(cell);
cell = new PdfPCell(new Phrase(""));
cell.setRowspan(2);
table.addCell(cell);
cell = new PdfPCell(new Phrase(""));
cell.setRowspan(2);
table.addCell(cell);
//////////////////////////////////////////////
// step 4
document.add(table);
// step 5
document.close();
}
catch(Exception e){
}
}
/* I THOUGHT TO PUT THE CREATING OF THE TABLE AS IN THE EXAMPLE - IN FUNCTION
public static PdfPTable createTable() {
// a table with three columns
PdfPTable table = new PdfPTable(4);
// the cell object
PdfPCell cell;
////////////////////////////////////////////////////////////////////////////////////////////
THIS CODE IS FOR GETTING THE VALUES FROM MY CONTENT MODEL
//QName PROP_QNAME_NAME = QName.createQName(myModel.NAMESPACE_ALFRESCO_MODEL, "name");
//String fileName = (String) nodeService.getProperty(actionedUponNodeRef, PROP_QNAME_NAME);
///////////////////////////////////////////////////////////////////////////////////////////
// we add a cell with colspan 3
cell = new PdfPCell(new Phrase("Примено:"));
cell.setColspan(4);
table.addCell(cell);
cell = new PdfPCell(new Phrase("Орг.един."));
table.addCell(cell);
// we add the four remaining cells with addCell()
table.addCell("Број:");
table.addCell("Прилог:");
table.addCell("Вредност:");
cell = new PdfPCell(new Phrase(""));
cell.setRowspan(2);
table.addCell(cell);
cell = new PdfPCell(new Phrase(""));
cell.setRowspan(2);
table.addCell(cell);
cell = new PdfPCell(new Phrase(""));
cell.setRowspan(2);
table.addCell(cell);
cell = new PdfPCell(new Phrase(""));
cell.setRowspan(2);
table.addCell(cell);
//table.setTotalWidth(104);
//table.completeRow();
// write the table to an absolute position
// table.writeSelectedRows(0, -1, 169, table.getTotalHeight() + 20, canvas);
return table;
}
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
paramList
.add(new ParameterDefinitionImpl(PARAM_TEXT,
DataTypeDefinition.TEXT,
false,
getParamDisplayLabel(PARAM_TEXT)));
return;
}
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
}
02-17-2015 04:24 AM
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.