简体   繁体   中英

How to include the aws s3 pdf in Php PDFLib block api

I am using Php PDFLIB to generate the pdf in my application I have gone through its block api by which we can define the block in pdf and we can populate that block values from db values Eg:: http://www.pdflib.com/en/pdflib-cookbook/block-handling-and-pps/business-cards/php-business-cards/

I wanted know is there way we use the pdf loaded from AWS s3 link instead of storing that in Searchpath

ie instead of the lines that says

$infile = "businesscard_blocks.pdf";

can we load something $infile = aws/s3/path/businesscard_blocks.pdf

you should check out the PVF feature of PDFlib. With the PVF you can load resources from memory. So you create a named mapping between a variable data and file name.

So in your case you might load the data from AWS via a PHP function

$PDFfiledata = file_get_contents('https://XYZ.AWS.com/aws/s3/path/businesscard_blocks.pdf');
$p->create_pvf("/pvf/input.pdf", $PDFfiledata, "");
$doc = $p->open_pdi_document("/pvf/input.pdf",  "");

then you can go ahead, as when you load the file from disc.

Please see the starter_pvf sample ( http://www.pdflib.com/de/pdflib-cookbook/general-programming/starter-pvf/php-starter-pvf/ ) and PDFlib 9 Tutorial, chapter 3.1.2 "The PDFlib Virtual File System (PVF)"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM