diff --git a/src/html/htmprint.cpp b/src/html/htmprint.cpp
index ae29a67390..cc804e27d3 100644
--- a/src/html/htmprint.cpp
+++ b/src/html/htmprint.cpp
@@ -251,7 +251,7 @@ bool wxHtmlPrintout::OnBeginDocument(int startPage, int endPage)
bool wxHtmlPrintout::OnPrintPage(int page)
{
wxDC *dc = GetDC();
- if (dc)
+ if (dc && dc->Ok())
{
if (HasPage(page))
RenderPage(dc, page);