             throw PDFGenerateError.invalidContext
         }
 
-        let renderFrame = CGRect(origin: .zero, size: CGSize(width: size.width * scaleFactor, height: size.height * scaleFactor))
+        let renderFrame = CGRect(origin: CGPoint(x: origin.x * scaleFactor, y: origin.y * scaleFactor),
+                                 size: CGSize(width: size.width * scaleFactor, height: size.height * scaleFactor))
         autoreleasepool {
             let superView = view.superview
             view.removeFromSuperview()
-            UIGraphicsBeginPDFPageWithInfo(renderFrame, nil)
+            UIGraphicsBeginPDFPageWithInfo(CGRect(origin: .zero, size: renderFrame.size), nil)
+            context.translateBy(x: -renderFrame.origin.x, y: -renderFrame.origin.y)
             view.layer.render(in: context)
             superView?.addSubview(view)
             superView?.layoutIfNeeded()

    
}

extension UIView: PDFPageRenderable {    
    fileprivate func _render<T: UIView>(_ view: T, scaleFactor: CGFloat, completion: (T) -> Void = { _ in }) throws {
        guard scaleFactor > 0.0 else {
            throw PDFGenerateError.invalidScaleFactor
        }
        
        let size = getPageSize()
        guard size.width > 0 && size.height > 0 else {
            throw PDFGenerateError.zeroSizeView(self)
        }

    }
    
    func renderPDFPage(scaleFactor: CGFloat) throws {
        try self.renderPDFPage(scaleFactor: scaleFactor, area: nil)
    }
    
    func renderPDFPage(scaleFactor: CGFloat, area: CGRect?) throws {
        func renderScrollView(_ scrollView: UIScrollView, area: CGRect?) throws {
            let tmp = scrollView.tempInfo
            scrollView.transformForRender()
            try _render(scrollView, scaleFactor: scaleFactor, area: area) { scrollView in
                scrollView.restore(tmp)
            }
        }
        
        if let webView = self as? UIWebView {
            try renderScrollView(webView.scrollView, area: area)
        } else if let webView = self as? WKWebView {
            try renderScrollView(webView.scrollView, area: area)
        } else if let scrollView = self as? UIScrollView {
            try renderScrollView(scrollView, area: area)
        } else {
            try _render(self, scaleFactor: scaleFactor, area: area)
        }
    }
    
