웹 캡처 및 변환 도구

웹 페이지 및 HTML을 PDF로 변환

파이썬 API

웹 페이지 및 HTML을 PDF로 변환 할 때 GrabzIt은 Python API입니다 도움이되는 다음 기능을 제공합니다 int예를 들어 GrabzIt into 가능한 한 쉽게 시스템. 그러나 시작하기 전에 전화를 한 후 URLToPDF, HTMLToPDF or FileToPDF 방법 Save or SaveTo PDF 스크린 샷을 만들려면 메소드를 호출해야합니다.

기본 옵션

웹 페이지를 변환 할 때 종종 intoa PDF 문서 전체 웹 페이지를 나타 내기 위해 많은 페이지가 생성됩니다. 웹 페이지를 변환하려면 하나의 매개 변수 만 필요합니다 intoa PDF 문서 또는 HTML을 PDF로 변환 아래 예제와 같이.

grabzIt.URLToPDF("https://www.tesla.com")
# Then call the Save or SaveTo method
grabzIt.HTMLToPDF("<html><body><h1>Hello World!</h1></body></html>")
# Then call the Save or SaveTo method
grabzIt.FileToPDF("example.html")
# Then call the Save or SaveTo method

맞춤식 식별자

사용자 지정 식별자를 PDF 아래 표시된대로 메소드를 사용하면이 값이 GrabzIt Python 핸들러로 리턴됩니다. 예를 들어이 사용자 지정 식별자는 데이터베이스 식별자 일 수 있으며 스크린 샷을 특정 데이터베이스 레코드와 연결할 수 있습니다.

from GrabzIt import GrabzItPDFOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItPDFOptions.GrabzItPDFOptions()
options.customId = "123456"

grabzIt.URLToPDF("https://www.tesla.com", options)
# Then call the Save method
grabzIt.Save("http://www.example.com/handler.py")
from GrabzIt import GrabzItPDFOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItPDFOptions.GrabzItPDFOptions()
options.customId = "123456"

grabzIt.HTMLToPDF("<html><body><h1>Hello World!</h1></body></html>", options)
# Then call the Save method
grabzIt.Save("http://www.example.com/handler.py")
from GrabzIt import GrabzItPDFOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItPDFOptions.GrabzItPDFOptions()
options.customId = "123456"

grabzIt.FileToPDF("example.html", options)
# Then call the Save method
grabzIt.Save("http://www.example.com/handler.py")

머리글과 바닥 글

PDF 스크린 샷을 만들 때 특정 사항을 적용하도록 요청할 수 있습니다 이 템플릿 생성 된 PDF로. 이 템플릿은 saved를 미리 지정하고 특수 변수와 함께 머리글과 바닥 글의 내용을 지정합니다. 아래 예제 코드에서 사용자는 "my template"이라는 템플릿을 사용하고 있습니다.

머리글 또는 바닥 글에 대해 각각 위쪽 또는 아래쪽 여백이 충분히 크지 않으면 PDF에 나타나지 않습니다. 아래 예제에서는 충분한 공간을 제공하기 위해 위쪽 및 아래쪽 여백을 20로 설정했습니다.

from GrabzIt import GrabzItPDFOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItPDFOptions.GrabzItPDFOptions()
options.marginTop = 20
options.marginBottom = 20
options.templateId = "my template"

grabzIt.FileToPDF("example.html", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.pdf")

HTML 요소를 PDF로 변환

div 또는 span과 같은 HTML 요소를 직접 변환하려는 경우 into GrabzIt의 Python 라이브러리로 PDF 문서를 작성할 수 있습니다. 당신은 통과해야합니다 CSS 선택기 로 변환하려는 HTML 요소의 targetElement 매개 변수입니다.

...
<span id="Article">
<p>This is the content I am interested in.</p>
<img src="myimage.jpg">
</span>
...

이 예에서는 ID가 Article따라서 아래와 같이 GrabzIt에 전달합니다.

from GrabzIt import GrabzItPDFOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItPDFOptions.GrabzItPDFOptions()
options.targetElement = "#Article"

grabzIt.URLToPDF("http://www.bbc.co.uk/news", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.pdf")

HTML 요소를 타겟팅 할 때 PDF가 잘리는 방법 이 기술을 사용하여 제어.