This is needed for use cases where diagrams are transformed to SVG and
viewed through browsers.
These changes also fix PDF printing to force page border rendering off
when not fitting PDF pages to diagram content, but to diagram page size.
This avoids printing ugly black half-visible borders around diagrams
where page borders are enabled.
gitlab #563
Change-Id: I7f666dec34c650489264f3d23cbd72d5102b2f14
(cherry picked from commit
2ccc058ac6c303b64a70ad0f0c48ca501bf4aa6a)
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);
// 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(), new Runnable() {
- @Override
- public void run() {
- if (ctx != null) {
- setDiagramDesc(ctx, result);
- }
+ ThreadUtils.asyncExec(ctx.getThreadAccess(), () -> {
+ if (ctx != null) {
+ setDiagramDesc(ctx, result);
}
});
}
@Override
public boolean isDisposed() {
- return ctx == null;
+ return DiagramSceneGraphProvider.this.ctx == null;
}
-
});
} catch (DatabaseException e) {
ErrorLogger.defaultLogError(e);