Resize the fig canvas after pdf.savefig()

Hi,
I plotted some data in my figure canvas and now I want to save the figure to pdf and in A4 size PDF. So I did the following:

	def handlePdfButton(self):
from matplotlib.backends.backend_pdf import PdfPages
fileName = "sample.pdf"
pdf = PdfPages(fileName)
self.fig.set_size_inches(8.267,11.692) # to make it A4 sizes
pdf.savefig(self.fig)
pdf.close()

Because I do self.fig.set_size_inches(8.267,11.692) the application window figure is also resized, I do not want this to happen. I need only A4 size pdf, so how do I resize the application figure? Or please suggest if there is any other way to save pdf in A4 size.
I do not want the figure to be resized after saving to PDF.
Please share your views. Thanks for your help in advance.
Sample application code to test:


import sys
import numpy as np
from matplotlib.figure import Figure
import matplotlib
matplotlib.use("Qt4Agg")
matplotlib.rcParams['backend.qt4']='PySide'
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas, NavigationToolbar2QTAgg as NavigationToolbar
from matplotlib.figure import Figure
import PySide
from PySide import QtGui, QtCore
class MyApp(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
self.widget = QtGui.QWidget()
self.fig = Figure((5.0, 4.0), dpi=100)
self.canvas = FigureCanvas(self.fig)
self.toolbar = NavigationToolbar(self.canvas, self)
self.PdfButton = QtGui.QPushButton("PDF")
self.PdfButton.clicked.connect(self.handlePdfButton)
vbox = QtGui.QVBoxLayout()
vbox.addWidget(self.canvas) # the matplotlib canvas
vbox.addWidget(self.toolbar)
vbox.addWidget(self.PdfButton)
self.widget.setLayout(vbox)
self.setCentralWidget(self.widget)
self.axes = self.fig.add_subplot(111)
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C, S = np.cos(X), np.sin(X)
self.axes.plot(X, C, linewidth=1.0, linestyle="-", label="cosine")
self.axes.plot(X, S, linewidth=1.0, linestyle="-", label="sine")
self.axes.legend()
self.canvas.draw()
def handlePdfButton(self):
from matplotlib.backends.backend_pdf import PdfPages
fileName = "sample.pdf"
pdf = PdfPages(fileName)
self.fig.set_size_inches(8.267,11.692)
pdf.savefig(self.fig)
#self.fig.set_size_inches(8.267,11.692)
#self.fig.canvas.resize(20,20)
pdf.close()
#self.canvas.draw()
def main():
app = QtGui.QApplication(sys.argv)
form = MyApp()
form.show()
app.exec_()
if __name__ == "__main__":
main()
ยทยทยท

View this message in context: Resize the fig canvas after pdf.savefig()

Sent from the matplotlib - users mailing list archive at Nabble.com.