ThreadUtils.syncExec(workerThread, new Runnable() {
@Override
public void run() {
- try {
+ try {
cctx.getDefaultHintContext().setHint(Hints.KEY_PAGE_DESC, _marginaaliViiva);
+ if (!fitDiagramContentsToPageMargins) {
+ // Prevent PDF printing from drawing page borders if the
+ // print area is fitted directly to the page size.
+ // This avoids unwanted black half-visible edges.
+ cctx.getDefaultHintContext().setHint(Hints.KEY_DISPLAY_PAGE, false);
+ }
String bottomLabel = diagramName;
if ( drawingTemplate != null && activeProfileEntries.contains(TMPL.DrawingTemplate) ) bottomLabel = null;
ThreadUtils.asyncExec(thread, () -> {
try {
- PDFBuilder chassis = new PDFBuilder(writer, mapper, pageSize, pageDesc, fitDiagramContentsToPageMargins || isSymbol);
+ boolean fitToContent = fitDiagramContentsToPageMargins || isSymbol;
+ if (!fitToContent) {
+ // Prevent PDF printing from drawing page borders if the
+ // print area is fitted directly to the page size.
+ // This avoids unwanted black half-visible edges.
+ ctx.getDefaultHintContext().setHint(Hints.KEY_DISPLAY_PAGE, false);
+ }
+
+ PDFBuilder chassis = new PDFBuilder(writer, mapper, pageSize, pageDesc, fitToContent);
chassis.paint(ctx, true);
} catch (Throwable e) {
exception[0] = new DatabaseException(e);
import org.simantics.db.exception.NoSingleResultException;
import org.simantics.db.exception.ServiceException;
import org.simantics.db.management.ISessionContext;
+import org.simantics.db.procedure.Listener;
import org.simantics.db.request.Read;
import org.simantics.diagram.adapter.DefaultConnectionClassFactory;
import org.simantics.diagram.adapter.FlagClassFactory;
import org.simantics.utils.page.PageOrientation;
import org.simantics.utils.threads.AWTThread;
import org.simantics.utils.threads.IThreadWorkQueue;
+import org.simantics.utils.threads.ThreadUtils;
import org.simantics.utils.ui.ErrorLogger;
DiagramDesc diagramDesc = Simantics.getSession().syncRequest(DiagramRequests.getDiagramDesc(diagramResource));
if (diagramDesc != null)
setDiagramDesc(ctx, diagramDesc);
+
+ // Create a listener to react to page setting changes.
+ Simantics.getSession().asyncRequest(DiagramRequests.getDiagramDesc(diagramResource), new Listener<DiagramDesc>() {
+ @Override
+ public void execute(DiagramDesc result) {
+ if (result != null && ctx != null) {
+ ThreadUtils.asyncExec(ctx.getThreadAccess(), () -> {
+ if (ctx != null) {
+ setDiagramDesc(ctx, result);
+ }
+ });
+ }
+ }
+
+ @Override
+ public void exception(Throwable t) {
+ ErrorLogger.defaultLogError(t);
+ }
+
+ @Override
+ public boolean isDisposed() {
+ return DiagramSceneGraphProvider.this.ctx == null;
+ }
+ });
} catch (DatabaseException e) {
ErrorLogger.defaultLogError(e);
}
protected void setDiagramDesc(ICanvasContext ctx, DiagramDesc diagramDesc) {
IHintContext hints = ctx.getDefaultHintContext();
hints.setHint(Hints.KEY_PAGE_DESC, diagramDesc.getPageDesc());
- //hints.setHint(Hints.KEY_DISPLAY_PAGE, diagramDesc.isPageBordersVisible());
+ hints.setHint(Hints.KEY_DISPLAY_PAGE, diagramDesc.isPageBordersVisible());
hints.setHint(Hints.KEY_DISPLAY_MARGINS, diagramDesc.isMarginsVisible());
}