捕获和转换Web的工具

如何创建具有自定义页面大小的DOCX和PDF文档?

默认情况下,DOCX和PDF文档都使用A4页面大小,同时还支持其他标准页面大小,例如A3和B4。 但是GrabzIt还允许开发人员使用完全自定义的页面大小。 要创建自定义页面尺寸,只需指定页面宽度和高度的尺寸(以毫米(mm)为单位),最小页面尺寸为15 mm。

PDF自定义页面大小

下面的示例说明如何为我们当前支持的每种编程语言创建150mm x 150mm的自定义PDF页面大小。

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
PDFOptions options = new PDFOptions();
options.PageWidth = 150;
options.PageHeight = 150;
grabzIt.URLToPDF("http://www.spacex.com", options);
grabzIt.Save("http://www.mywebsite.com/Home/Handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
PDFOptions options = new PDFOptions();
options.setPageWidth(150);
options.setPageHeight(150);
grabzIt.URLToPDF("http://www.spacex.com", options);
grabzIt.Save("http://www.mywebsite.com/handler");
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@3.3.7/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertURL("http://www.spacex.com", 
{"format": "pdf", "download": 1, "height": 150, "width": 150}).Create();
</script>
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");
var options = {"pageWidth":150,"pageHeight":150};
client.url_to_pdf("http://www.spacex.com", options);
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");
$options = GrabzItPDFOptions->new();
$options->pageWidth(150);
$options->pageHeight(150);
$grabzIt->URLToPDF("http://www.spacex.com", $options);
$grabzIt->Save("http://www.mywebsite.com/handler.pl");
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
$options = new \GrabzIt\GrabzItPDFOptions();
$options->setPageWidth(150);
$options->setPageHeight(150);
$grabzIt->URLToPDF("http://www.spacex.com", $options);
$grabzIt->Save("http://www.mywebsite.com/handler.php");
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzItPDFOptions.GrabzItPDFOptions()
options.pageWidth = 150
options.pageHeight = 150
grabzIt.URLToPDF("http://www.spacex.com", options)
grabzIt.Save("http://www.mywebsite.com/handler.py")
grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzIt::PDFOptions.new()
options.pageWidth = 150
options.pageHeigh = 150
grabzIt.url_to_pdf("http://www.spacex.com", options)
grabzIt.save("http://www.mywebsite.com/handler/index")

DOCX自定义页面大小

可以通过与上述示例中的PDF类似的方式来生成DOCX的自定义页面大小。 再次使用150mm x 150mm的自定义页面大小。

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
DOCXOptions options = new DOCXOptions();
options.PageWidth = 150;
options.PageHeight = 150;
grabzIt.URLToDOCX("http://www.spacex.com", options);
grabzIt.Save("http://www.mywebsite.com/Home/Handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
DOCXOptions options = new DOCXOptions();
options.setPageWidth(150);
options.setPageHeight(150);
grabzIt.URLToDOCX("http://www.spacex.com", options);
grabzIt.Save("http://www.mywebsite.com/handler");
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@3.3.7/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertURL("http://www.spacex.com", 
{"format": "docx", "download": 1, "height": 150, "width": 150}).Create();
</script>
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");
var options = {"pageWidth":150,"pageHeight":150};
client.url_to_docx("http://www.spacex.com", options);
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");
$options = GrabzItDOCXOptions->new();
$options->pageWidth(150);
$options->pageHeight(150);
$grabzIt->URLToDOCX("http://www.spacex.com", $options);
$grabzIt->Save("http://www.mywebsite.com/handler.pl");
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
$options = new \GrabzIt\GrabzItDOCXOptions();
$options->setPageWidth(150);
$options->setPageHeight(150);
$grabzIt->URLToDOCX("http://www.spacex.com", $options);
$grabzIt->Save("http://www.mywebsite.com/handler.php");
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.pageWidth = 150
options.pageHeight = 150
grabzIt.URLToDOCX("http://www.spacex.com", options)
grabzIt.Save("http://www.mywebsite.com/handler.py")
grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzIt::DOCXOptions.new()
options.pageWidth = 150
options.pageHeigh = 150
grabzIt.url_to_docx("http://www.spacex.com", options)
grabzIt.save("http://www.mywebsite.com/handler/index")