@@ -128,13 +128,13 @@ QgsPaperItem::QgsPaperItem( QgsComposition* c ): QgsComposerItem( c, false ),
128
128
}
129
129
130
130
QgsPaperItem::QgsPaperItem ( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition ): QgsComposerItem( x, y, width, height, composition, false ),
131
- mPageGrid( 0 )
131
+ mPageGrid( 0 ), mPageMargin( 0 )
132
132
{
133
133
initialize ();
134
134
}
135
135
136
136
QgsPaperItem::QgsPaperItem (): QgsComposerItem( 0 , false ),
137
- mPageGrid( 0 )
137
+ mPageGrid( 0 ), mPageMargin( 0 )
138
138
{
139
139
initialize ();
140
140
}
@@ -167,15 +167,28 @@ void QgsPaperItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* ite
167
167
168
168
painter->save ();
169
169
painter->setRenderHint ( QPainter::Antialiasing );
170
- QPolygonF pagePolygon = QPolygonF ( QRectF ( 0 , 0 , rect ().width (), rect ().height () ) );
171
170
mComposition ->pageStyleSymbol ()->startRender ( context );
171
+
172
+ calculatePageMargin ();
173
+ QPolygonF pagePolygon = QPolygonF ( QRectF ( mPageMargin , mPageMargin , rect ().width () - 2 * mPageMargin , rect ().height () - 2 * mPageMargin ) );
172
174
QList<QPolygonF> rings; // empty list
173
175
mComposition ->pageStyleSymbol ()->renderPolygon ( pagePolygon, &rings, 0 , context );
174
176
mComposition ->pageStyleSymbol ()->stopRender ( context );
175
177
painter->restore ();
176
178
177
179
}
178
180
181
+ void QgsPaperItem::calculatePageMargin ()
182
+ {
183
+ // get max bleed from symbol
184
+ double maxBleed = QgsSymbolLayerV2Utils::estimateMaxSymbolBleed ( mComposition ->pageStyleSymbol () );
185
+
186
+ // Now subtract 1 pixel to prevent semi-transparent borders at edge of solid page caused by
187
+ // anti-aliased painting. This may cause a pixel to be cropped from certain edge lines/symbols,
188
+ // but that can be counteracted by adding a dummy transparent line symbol layer with a wider line width
189
+ mPageMargin = maxBleed - ( 25.4 / mComposition ->printResolution () );
190
+ }
191
+
179
192
bool QgsPaperItem::writeXML ( QDomElement& elem, QDomDocument & doc ) const
180
193
{
181
194
Q_UNUSED ( elem );
0 commit comments