I need to create page size dynamically based on a datafield (e.g.: 25x30), instead of creating multiple medias and sections manually in the Connect Designer. I have to do that because there are too much different media sizes (minimum 55 different sizes).
If that doesn`t work, is there a way to resize a generated pdf document via script in the workflow (maybe with alambic)?
Not sure about creating page sizes dynamically (I will leave that part to Design experts), but in Workflow you can script a method that scales and centers a page onto a different media. The following code does that, but be advised that it’s just something I had in my collection of scripts and that it may not do exactly what you want. In this example, it maps the current job file (which is presumed to be a PDF) onto a newly created A3 page. It only handles single page PDFs.
Still, it should help get you started if you want to implement this with Workflow:
var newPDF = Watch.GetPDFEditObject();
var jobPDF = Watch.GetPDFEditObject();
var newRect = new ActiveXObject("AlambicEdit.PdfRect")
var jobRect = new ActiveXObject("AlambicEdit.PdfRect")
jobPDF.Open(Watch.GetJobFileName(),false);
// Current job page size
jobRect = jobPDF.Pages(0).Size();
newPDF.Create("C:\\test\\newFile.pdf");
// A3 size
newRect.left = 0;
newRect.top = 1190;
newRect.right = 842;
newRect.bottom = 0;
newPDF.Pages().Insert(0,newRect);
var widthScaling = newRect.right/jobRect.right;
var heightScaling = newRect.top/jobRect.top;
var scaling = Math.min(widthScaling, heightScaling);
// Merge existing page onto new page, scaling and offsetting accordingly
newPDF.Pages(0).Merge2(jobPDF.Pages(0),(newRect.right-(jobRect.right*scaling))/2,(newRect.top-(jobRect.top*scaling))/2,0,scaling)
newPDF.Save(false);
Phil’s script can still work. It has to be slightly modified so that the source page is not scaled (scaling = 1) and positioned correctly onto the destination.
I have a job which is a mix of landscape and portrait pages and variable number of pages per document, I need to extract text from the pages and the documents are multipage so I can’t treat each page as a different document.
Is there a way to set the section used for each page via control script rather than on a document level?