• wondering if a plugin exists, and if so, what would it be that would accomplish the following. I was hoping to create a web page application in which there is a pdf document consisting of many layers. the user-selected options from either radio buttons or drop down selections would determine which of the pdf layers are shown or hidden for the final copy. there will be be 2 different sets of options for the user to select in all. this essentially means that the user can create their own custom version of this document to print. i have briefly explored some print on demand options out there but have not yet taken the time to investigate if they can accomplish this task.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi
    Do you any live example for that.
    Yes it’s possible by custom code.

    Thanks

    Here’s an example of how you could create a simple PDF with layers using PHP and the FPDF library:

    1. Frontend:
      • Create a web page with radio buttons or drop-down selections for the user to choose the layers they want to include in the PDF.
      • Use JavaScript to collect the user’s selections and send them to the server as a JSON object (using AJAX or by submitting a form).
    2. Backend (PHP):
      • Receive the user’s selections.
      • Use the FPDF library to create a new PDF document.
      • Add the selected layers to the PDF document based on the user’s selections. Each layer could be a separate image or PDF file that you overlay on the main PDF document.
      • Output the PDF to the user’s browser as a downloadable file or display it in an embedded PDF viewer on the web page.

    Here is an example of a PHP script using the FPDF library to create a simple PDF with layers:

    require('fpdf.php');
    
    // Define the layers
    $layer1 = "Layer 1 content";
    $layer2 = "Layer 2 content";
    $layer3 = "Layer 3 content";
    
    // Get user's selections (for example, from a JSON object)
    $user_selections = array(
        "layer1" => true,
        "layer2" => false,
        "layer3" => true
    );
    
    // Create a new PDF
    $pdf = new FPDF();
    $pdf->AddPage();
    
    // Add the selected layers to the PDF
    if ($user_selections["layer1"]) {
        $pdf->SetFont('Arial', 'B', 16);
        $pdf->Cell(40, 10, $layer1);
        $pdf->Ln();
    }
    
    if ($user_selections["layer2"]) {
        $pdf->SetFont('Arial', 'B', 16);
        $pdf->Cell(40, 10, $layer2);
        $pdf->Ln();
    }
    
    if ($user_selections["layer3"]) {
        $pdf->SetFont('Arial', 'B', 16);
        $pdf->Cell(40, 10, $layer3);
        $pdf->Ln();
    }
    
    // Output the PDF to the browser
    $pdf->Output();
    

    In this example, we define three layers as strings and get the user’s selections in an associative array. We then create a new PDF using the FPDF library and add the selected layers to the PDF based on the user’s selections. Finally, we output the PDF to the browser. You can then send this file to the user’s browser for download or display it in an embedded PDF viewer on the web page.

    Note that this is just a simple example to give you an idea of how you could implement this functionality using PHP. In a real-world scenario, you would need to handle more complex layers (e.g., images or other PDF files), error handling, and user input validation.

    Use a form for your input:

    https://www.gravityforms.com

    and use a PDF generator for your output:

    https://gravitypdf.com

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘plugin to create dynamic generated pdf printables’ is closed to new replies.