API Documentation > Sample Codes > Sample Code: Create a Full Page Screenshot of One URL

Sample Code: Create a Full Page Screenshot of One URL

In most of the cases, we only can see part of the page on one screen. Like this:

With full page option, we can allow you to take the full screen shot of one page instead of just one screen.

Full Page with Custom Image Size

If you set p2i_size = 300x300, we will scale the screenshot to fix the rectangle. Here are some possible situation.

If the screenshot result is a square.

If the screenshot result is rectangle.

If you set p2i_size = 300x0, we will scale the width of screenshot to 300 and scale the height accordingly. For example a 600x1200 screenshot will be resize to 300x600.

1200

300

600
600

If you set p2i_size = 0x300, we will scale the height of screenshot to 300 and scale the width accordingly. For example a 600x1200 screenshot will be resize to 150x300.

1200
300

150

600

Generate a Small Website screenshot

Rest API

http://api.page2images.com/restfullink?p2i_url=TARGET_URL&p2i_key=YOUR_API_KEY&p2i_size=150x150

IMG API

<img src='http://api.page2images.com/directlink?p2i_url=TARGET_URL&p2i_key=YOUR_API_KEY&p2i_size=150x150'>

JS API

<img src='http://api.page2images.com/directlink?p2i_url=TARGET_URL&p2i_key=YOUR_API_KEY& p2i_size=150x150'>
<script src="http://www.page2images.com/js/p2i.js"></script> <script> var p2i=new page2images(); p2i.thumbnail('demo');</script>
Click this here to see the demo image

Generate a Full Page Website screenshot with Fixed Width

Rest API

http://api.page2images.com/restfullink?p2i_url=TARGET_URL&p2i_key=YOUR_API_KEY&p2i_size=300x0&p2i_fullpage=1

IMG API

<img src='http://api.page2images.com/directlink?p2i_url=TARGET_URL&p2i_size=300x0&p2i_fullpage=1' >

JS API

<img src='http://api.page2images.com/directlink?p2i_url=TARGET_URL&p2i_size=300x0&p2i_fullpage=1'> 
<script src="http://www.page2images.com/js/p2i.js"></script> <script> var p2i=new page2images(); p2i.thumbnail('demo');</script>
Click this here to see the demo image

Generate a Full Page Website screenshot with Fixed Height

Rest API

http://api.page2images.com/restfullink?p2i_url=TARGET_URL&p2i_key=YOUR_API_KEY&p2i_size=0x300&p2i_fullpage=1

IMG API

<img src='http://api.page2images.com/directlink?p2i_url=TARGET_URL&p2i_size=0x300&p2i_fullpage=1' >

JS API

<img src='http://api.page2images.com/directlink?p2i_url=TARGET_URL&p2i_size=300x0&p2i_fullpage=1'> 
<script src="http://www.page2images.com/js/p2i.js"></script> <script> var p2i=new page2images(); p2i.thumbnail('demo');</script>
Click this here to see the demo image

Generate a Full Page Website screenshot with Fixed Width and Height

Rest API

http://api.page2images.com/restfullink?p2i_url=TARGET_URL&p2i_key=YOUR_API_KEY&p2i_size=300x300&p2i_fullpage=1

IMG API

<img src='http://api.page2images.com/directlink?p2i_url=TARGET_URL&p2i_size=300x300&p2i_fullpage=1' >

JS API

<img src='http://api.page2images.com/directlink?p2i_url=TARGET_URL&p2i_size=300x300&p2i_fullpage=1'> 
<script src="http://www.page2images.com/js/p2i.js"></script> <script> var p2i=new page2images(); p2i.thumbnail('demo');</script>
Click this here to see the demo image
Sample Codes
Download Java sample source code for website screenshot
Download PHP sample source code for website screenshot
Download Python sample source code for website screenshot
Download PHP sample source code for convert HTML to image
Use Code Generator to Build the Code

Using our Code Generator, you can quickly generate the source code for IMG Tags. Use page2images code generator for website screenshot.

Free Engineering Service

Premium and XLarge rate plan users get free help with writing and testing code. Please contact us if you need help.

version:1.7