Esempio n. 1
0
function Redact($input, $output, $vec)
{
    $doc = new PDFDoc($input);
    if ($doc->InitSecurityHandler()) {
        Redactor::Redact($doc, $vec);
        $doc->Save($output, SDFDoc::e_linearized);
    }
}
Esempio n. 2
0
$zoom_rect = new Rect(216.0, 522.0, 330.0, 600.0);
$page->SetCropBox($zoom_rect);
// Set the page crop box.
// Select the crop region to be used for drawing.
$draw->SetPageBox(Page::e_crop);
$draw->SetDPI(900);
// Set the output image resolution to 900 DPI.
$draw->Export($page, $output_path . "tiger_zoom_900dpi.png", "PNG");
echo nl2br("Example 5: " . $output_path . "tiger_zoom_900dpi.png. Done.\n");
$draw->SetImageSize(50, 50);
// Set the thumbnail to be 50x50 pixel image.
$draw->Export($page, $output_path . "tiger_zoom_50x50.png", "PNG");
echo nl2br("Example 5: " . $output_path . "tiger_zoom_50x50.png. Done.\n");
$cmyk_hint = $hint_set->CreateDict();
$cmyk_hint->PutName("ColorSpace", "CMYK");
//--------------------------------------------------------------------------------
// Example 6) Convert the first PDF page to CMYK TIFF at 92 DPI.
// A three step tutorial to convert PDF page to an image
echo nl2br("Example 6:\n");
// A) Open the PDF document.
$doc = new PDFDoc($input_path . "tiger.pdf");
// Initialize the security handler, in case the PDF is encrypted.
$doc->InitSecurityHandler();
// B) The output resolution is set to 92 DPI.
$draw->SetDPI(92);
// C) Rasterize the first page in the document and save the result as TIFF.
$pg = $doc->GetPage(1);
$draw->Export($pg, $output_path . "out1.tif", "TIFF", $cmyk_hint);
echo nl2br("Example 6: Result saved in " . $output_path . "out1.tif\n");
$doc->Close();
echo "Done.";
Esempio n. 3
0
<?php

//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2014 by PDFTron Systems Inc. All Rights Reserved.
// Consult LICENSE.txt regarding license information.
//---------------------------------------------------------------------------------------
include "../../../PDFNetC/Lib/PDFNetPHP.php";
PDFNet::Initialize();
// Relative path to the folder containing the test files.
$input_path = getcwd() . "/../../TestFiles/";
$output_path = $input_path . "Output/";
// Test - Adjust the position of content within the page.
echo nl2br("_______________________________________________\n");
echo nl2br("Opening the input pdf...\n");
$input_doc = new PDFDoc($input_path . "tiger.pdf");
$input_doc->InitSecurityHandler();
$pg_itr1 = $input_doc->GetPageIterator();
$media_box = new Rect($pg_itr1->Current()->GetMediaBox());
$media_box->x1 -= 200;
$media_box->x2 -= 200;
$media_box->Update();
$input_doc->Save($output_path . "tiger_shift.pdf", 0);
$input_doc->Close();
echo nl2br("Done. Result saved in tiger_shift...\n");
Esempio n. 4
0
$user_password = "******";
$new_handler->ChangeUserPassword($user_password);
// Set Permissions
$new_handler->SetPermission(SecurityHandler::e_print, true);
$new_handler->SetPermission(SecurityHandler::e_extract_content, false);
// Note: document takes the ownership of new_handler.
$doc->SetSecurityHandler($new_handler);
// Save the changes.
echo "Saving modified file...\n";
$doc->Save($output_path . "secured.pdf", 0);
$doc->Close();
// Example 2:
// Opens an encrypted PDF document and removes its security.
$doc = new PDFDoc($output_path . "secured.pdf");
//If the document is encrypted prompt for the password
if (!$doc->InitSecurityHandler()) {
    $success = false;
    echo "The password is: test\n";
    for ($count = 0; $count < 3; $count++) {
        echo "A password required to open the document.\n" . "Please enter the password:"******"The password is correct.\n";
            break;
        } else {
            if ($count < 3) {
                echo "The password is incorrect, please try again\n";
            }
        }
    }
Esempio n. 5
0
$s = new Stamper(Stamper::e_relative_scale, 0.05, 0.05);
$s->SetPosition(0.0, 0.0);
$s->SetOpacity(0.7);
$s->SetRotation(90);
$s->SetSize(Stamper::e_font_size, 80, -1);
$s->SetTextAlignment(Stamper::e_align_center);
$ps = new PageSet(1, 20, PageSet::e_even);
$s->StampText($doc, "Goodbye\nMoon", $ps);
$doc->Save($output_path . $input_filename . ".ex5.pdf", SDFDoc::e_linearized);
$doc->Close();
//--------------------------------------------------------------------------------
// Example 6) Add first page as stamp to all even pages
$doc = new PDFDoc($input_path . $input_filename);
$doc->InitSecurityHandler();
$fish_doc = new PDFDoc($input_path . "fish.pdf");
$fish_doc->InitSecurityHandler();
$s = new Stamper(Stamper::e_relative_scale, 0.3, 0.3);
$s->SetOpacity(1);
$s->SetRotation(270);
$s->SetAsBackground(true);
$s->SetPosition(0.5, 0.5, true);
$s->SetAlignment(Stamper::e_horizontal_left, Stamper::e_vertical_bottom);
$page_one = $fish_doc->GetPage(1);
$ps = new PageSet(1, $doc->GetPageCount(), PageSet::e_even);
$s->StampPage($doc, $page_one, $ps);
$doc->Save($output_path . $input_filename . ".ex6.pdf", SDFDoc::e_linearized);
$doc->Close();
//--------------------------------------------------------------------------------
// Example 7) Add image stamp at top right corner in every pages
$doc = new PDFDoc($input_path . $input_filename);
$doc->InitSecurityHandler();