Overlay one PDF to another programmatically

Question:I have two PDF or postscript files (I can work with either one). What I want to do is merge each page on top of the other so that page1 of document A will be combined with page 1 of document B to produce page 1 of the output document. This isn't something I necessarily want need to do programmatically, although that would be helpful. Any ideas on VeryPDF?

Answer:According to your needs, there are two options for you. You can use software VeryPDF PDF Toolbox Command Line by overlay one PDF file to another. Or you can use VeryPDF PDF Stamper Cloud API to overlay PDF. The first software is desktop command line application, which allows you to use the whole life but it is a little expensive. The second cloud API application is much cheaper but you need to pay for it per month or per year. Please check more related information of those two solutions on homepage, in the following part, I will show you how overlay PDF by the cheaper choice VeryPDF PDF Stamper Cloud API.

Step 1. Get an API code on VeryPDF Cloud Application

  • There are lots of cloud applications on VeryPDF, you can use them for file formats conversion, generation or others. Once you get an API code, you can free use all the cloud applications on VeryPDF.
  • When comes to registration, you need to prepare an email address, a user name then go to registration page. Once you register and pay for it, the API code will be sent to your email box at once.

Step 2. Overlay PDF programmatically

  • When you need to overlay PDF programmatically, please refer to the following code template. Here I will show you how to overlay PDF from PHP Code.

<?php
//The Code
/* gets the data from a URL */
function get_data($url)
{
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

//The Usage
$returned_content = get_data('http://online.verypdf.com/api/?apikey=XXXXXXXXXXXXX&app=pdftoolbox
&infile=http://online.verypdf.com/examples/cloud-api/multipage.pdf
&outfile=out.pdf&url_background=http://online.verypdf.com/examples/cloud-api/stamp/Faces.pdf'
);
echo $returned_content;
?>

The URL in the above code template is the necessary element to overlay PDF file.  When you overlay PDF, please change the apikey code to the real code in your email box or else there will be watermark on output file. Please input the background PDF URL to replace the mulitipage.pdf file. Replace the URL of Face.pdf by the overlay PDF file.

  Then run the conversion process, a few seconds later, you will find output URL of merged PDF file. By the URL you got, you can download the output PDF file successfully. During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

This entry was posted in PDF Toolbox Command Line and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!