function main()
{
    global $inputPath, $outputPath;
    PDFNet::Initialize();
    // Sample 1:
    // Directly convert from PDF to XOD.
    echo nl2br("Converting: " . $inputPath . "newsletter.pdf" . " to " . $outputPath . "from_pdf.xod" . "\n");
    Convert::ToXod($inputPath . "newsletter.pdf", $outputPath . "from_pdf.xod");
    // Sample 2:
    // Directly convert from generic XPS to XOD.
    echo nl2br("Converting: " . $inputPath . "simple-xps.xps" . " to " . $outputPath . "from_xps.xod" . "\n");
    Convert::ToXod($inputPath . "simple-xps.xps", $outputPath . "from_xps.xod");
    // Sample 3:
    // Directly convert from PNG to XOD.
    echo nl2br("Converting: " . $inputPath . "butterfly.png" . " to " . $outputPath . "butterfly.xod" . "\n");
    Convert::ToXod($inputPath . "butterfly.png", $outputPath . "butterfly.xod");
    // Sample 4:
    // Directly convert from JPG to XOD.
    echo nl2br("Converting: " . $inputPath . "dice.jpg" . " to " . $outputPath . "dice.xod" . "\n");
    Convert::ToXod($inputPath . "dice.jpg", $outputPath . "dice.xod");
    echo nl2br("Done.\n");
}
示例#2
0
// Copyright (c) 2001-2014 by PDFTron Systems Inc. All Rights Reserved.
// Consult LICENSE.txt regarding license information.
//---------------------------------------------------------------------------------------
include "../../../PDFNetC/Lib/PDFNetPHP.php";
// Relative path to the folder containing the test files.
$input_path = getcwd() . "/../../TestFiles/";
$output_path = $input_path . "Output/";
//---------------------------------------------------------------------------------------
// The following sample illustrates how to convert PDF documents to various raster image
// formats (such as PNG, JPEG, BMP, TIFF, etc), as well as how to convert a PDF page to
// GDI+ Bitmap for further manipulation and/or display in WinForms applications.
//---------------------------------------------------------------------------------------
// The first step in every application using PDFNet is to initialize the
// library and set the path to common PDF resources. The library is usually
// initialized only once, but calling Initialize() multiple times is also fine.
PDFNet::Initialize();
// Optional: Set ICC color profiles to fine tune color conversion
// for PDF 'device' color spaces...
// PDFNet::SetResourcesPath("../../../resources");
// PDFNet::SetColorManagement();
// PDFNet::SetDefaultDeviceCMYKProfile("D:/Misc/ICC/USWebCoatedSWOP.icc");
// PDFNet::SetDefaultDeviceRGBProfile("AdobeRGB1998.icc"); // will search in PDFNet resource folder.
// ----------------------------------------------------
// Optional: Set predefined font mappings to override default font
// substitution for documents with missing fonts...
// PDFNet::AddFontSubst("StoneSans-Semibold", "C:/WINDOWS/Fonts/comic.ttf");
// PDFNet::AddFontSubst("StoneSans", "comic.ttf");  // search for 'comic.ttf' in PDFNet resource folder.
// PDFNet::AddFontSubst(PDFNet::e_Identity, "C:/WINDOWS/Fonts/arialuni.ttf");
// PDFNet::AddFontSubst(PDFNet::e_Japan1, "C:/Program Files/Adobe/Acrobat 7.0/Resource/CIDFont/KozMinProVI-Regular.otf");
// PDFNet::AddFontSubst(PDFNet::e_Japan2, "c:/myfonts/KozMinProVI-Regular.otf");
// PDFNet::AddFontSubst(PDFNet::e_Korea1, "AdobeMyungjoStd-Medium.otf");
示例#3
0
                    echo nl2br("   Objects:\n");
                    for ($j = 0; $j < $num_refs; ++$j) {
                        echo $pdf_a->GetRefObj($c, $j);
                        if ($j < $num_refs - 1) {
                            echo ", ";
                        }
                    }
                    echo nl2br("\n");
                }
            }
        }
        echo nl2br("\n");
    }
}
PDFNet::Initialize();
PDFNet::SetColorManagement();
// Enable color management (required for PDFA validation).
//-----------------------------------------------------------
// Example 1: PDF/A Validation
//-----------------------------------------------------------
echo nl2br("Performing PDF/A validation on newsletter.pdf\n");
$input_filename = $input_path . "newsletter.pdf";
$pdf_a = new PDFACompliance(false, $input_filename, "0", PDFACompliance::e_Level1B, 0, 10);
PrintResults($pdf_a, "newsletter.pdf");
$pdf_a->Destroy();
//-----------------------------------------------------------
// Example 2: PDF/A Conversion
//-----------------------------------------------------------
echo nl2br("Performing PDF/A conversion on newsletter.pdf\n");
$input_filename = $input_path . "newsletter.pdf";
$converted_filename = $output_path . "newsletter_pdfa.pdf";
示例#4
0
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";
            }
        }
    }
    if (!$success) {
        echo "Document authentication error....\n";
        PDFNet::Terminate();
        return;
    }
    $hdlr = $doc->GetSecurityHandler();
    echo "Document Open Password: "******"\n";
    echo "Permissions Password: "******"\n";
    echo "Permissions: " . "\n\tHas 'owner' permissions: " . $hdlr->GetPermission(SecurityHandler::e_owner) . "\n\tOpen and decrypt the document: " . $hdlr->GetPermission(SecurityHandler::e_doc_open) . "\n\tAllow content extraction: " . $hdlr->GetPermission(SecurityHandler::e_extract_content) . "\n\tAllow full document editing: " . $hdlr->GetPermission(SecurityHandler::e_doc_modify) . "\n\tAllow printing: " . $hdlr->GetPermission(SecurityHandler::e_print) . "\n\tAllow high resolution printing: " . $hdlr->GetPermission(SecurityHandler::e_print_high) . "\n\tAllow annotation editing: " . $hdlr->GetPermission(SecurityHandler::e_mod_annot) . "\n\tAllow form fill: " . $hdlr->GetPermission(SecurityHandler::e_fill_forms) . "\n\tAllow content extraction for accessibility: " . $hdlr->GetPermission(SecurityHandler::e_access_support) . "\n\tAllow document assembly: " . $hdlr->GetPermission(SecurityHandler::e_assemble_doc) . "\n";
}
// remove all security on the document
$doc->RemoveSecurity();
$doc->Save($output_path . "not_secured.pdf", 0);
$doc->Close();
echo "Test Completed.\n";
示例#5
0
function main()
{
    // The first step in every application using PDFNet is to initialize the
    // library. The library is usually initialized only once, but calling
    // Initialize() multiple times is also fine.
    PDFNet::Initialize();
    // Demonstrate Convert::ToPdf and Convert::Printer
    ConvertToPdfFromFile();
    // Demonstrate Convert::[FromEmf, FromXps, ToEmf, ToSVG, ToXPS]
    ConvertSpecificFormats();
    echo nl2br("Done.\n");
}
function main()
{
    // Initialize PDFNetC
    PDFNet::Initialize();
    $result = true;
    if (!SignPDF()) {
        $result = false;
    }
    if (!CertifyPDF()) {
        $result = false;
    }
    if (!$result) {
        echo nl2br('Tests failed.' . PHP_EOL);
        return;
    }
    echo nl2br('All tests passed.' . PHP_EOL);
}
function main()
{
    global $input_path, $output_path;
    PDFNet::Initialize();
    $doc = new PDFDoc();
    $builder = new ElementBuilder();
    $writer = new ElementWriter();
    // Start a new page ------------------------------------
    $page = $doc->PageCreate(new Rect(0.0, 0.0, 612.0, 794.0));
    $writer->Begin($page);
    // begin writing to this page
    // Embed and subset the font
    $font_program = $input_path . "ARIALUNI.TTF";
    if (!file_exists($font_program)) {
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            $font_program = "C:/Windows/Fonts/ARIALUNI.TTF";
            echo nl2br("Note: Using ARIALUNI.TTF from C:/Windows/Fonts directory.\n");
        } else {
            echo nl2br("Error: Cannot find ARIALUNI.TTF.\n");
            exit(1);
        }
    }
    $fnt = Font::CreateCIDTrueTypeFont($doc->GetSDFDoc(), $font_program, true, true);
    $element = $builder->CreateTextBegin($fnt, 1.0);
    $element->SetTextMatrix(10.0, 0.0, 0.0, 10.0, 50.0, 600.0);
    $element->GetGState()->SetLeading(2);
    // Set the spacing between lines
    $writer->WriteElement($element);
    // Hello World!
    $hello = array('H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!');
    $writer->WriteElement($builder->CreateUnicodeTextRun($hello, count($hello)));
    $writer->WriteElement($builder->CreateTextNewLine());
    // Latin
    $latin = array('a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 0x45, 0x46, 0xc0, 0xc1, 0xc2, 0x143, 0x144, 0x145, 0x152, '1', '2');
    $writer->WriteElement($builder->CreateUnicodeTextRun($latin, count($latin)));
    $writer->WriteElement($builder->CreateTextNewLine());
    // Greek
    $greek = array(0x39e, 0x39f, 0x3a0, 0x3a1, 0x3a3, 0x3a6, 0x3a8, 0x3a9);
    $writer->WriteElement($builder->CreateUnicodeTextRun($greek, count($greek)));
    $writer->WriteElement($builder->CreateTextNewLine());
    // Cyrillic
    $cyrillic = array(0x409, 0x40a, 0x40b, 0x40c, 0x40e, 0x40f, 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417, 0x418, 0x419);
    $writer->WriteElement($builder->CreateUnicodeTextRun($cyrillic, count($cyrillic)));
    $writer->WriteElement($builder->CreateTextNewLine());
    // Hebrew
    $hebrew = array(0x5d0, 0x5d1, 0x5d3, 0x5d3, 0x5d4, 0x5d5, 0x5d6, 0x5d7, 0x5d8, 0x5d9, 0x5da, 0x5db, 0x5dc, 0x5dd, 0x5de, 0x5df, 0x5e0, 0x5e1);
    $writer->WriteElement($builder->CreateUnicodeTextRun($hebrew, count($hebrew)));
    $writer->WriteElement($builder->CreateTextNewLine());
    // Arabic
    $arabic = array(0x624, 0x625, 0x626, 0x627, 0x628, 0x629, 0x62a, 0x62b, 0x62c, 0x62d, 0x62e, 0x62f, 0x630, 0x631, 0x632, 0x633, 0x634, 0x635);
    $writer->WriteElement($builder->CreateUnicodeTextRun($arabic, count($arabic)));
    $writer->WriteElement($builder->CreateTextNewLine());
    // Thai
    $thai = array(0xe01, 0xe02, 0xe03, 0xe04, 0xe05, 0xe06, 0xe07, 0xe08, 0xe09, 0xe0a, 0xe0b, 0xe0c, 0xe0d, 0xe0e, 0xe0f, 0xe10, 0xe11, 0xe12);
    $writer->WriteElement($builder->CreateUnicodeTextRun($thai, count($thai)));
    $writer->WriteElement($builder->CreateTextNewLine());
    // Hiragana - Japanese
    $hiragana = array(0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046, 0x3047, 0x3048, 0x3049, 0x304a, 0x304b, 0x304c, 0x304d, 0x304e, 0x304f, 0x3051, 0x3051, 0x3052);
    $writer->WriteElement($builder->CreateUnicodeTextRun($hiragana, count($hiragana)));
    $writer->WriteElement($builder->CreateTextNewLine());
    // CJK Unified Ideographs
    $cjk_uni = array(0x5841, 0x5842, 0x5843, 0x5844, 0x5845, 0x5846, 0x5847, 0x5848, 0x5849, 0x584a, 0x584b, 0x584c, 0x584d, 0x584e, 0x584f, 0x5850, 0x5851, 0x5852);
    $writer->WriteElement($builder->CreateUnicodeTextRun($cjk_uni, count($cjk_uni)));
    $writer->WriteElement($builder->CreateTextNewLine());
    // Simplified Chinese
    $chinese_simplified = array(0x4e16, 0x754c, 0x60a8, 0x597d);
    $writer->WriteElement($builder->CreateUnicodeTextRun($chinese_simplified, count($chinese_simplified)));
    $writer->WriteElement($builder->CreateTextNewLine());
    // Finish the block of text
    $writer->WriteElement($builder->CreateTextEnd());
    $writer->End();
    // save changes to the current page
    $doc->PagePushBack($page);
    $doc->Save($output_path . "unicodewrite.pdf", SDFDoc::e_remove_unused | SDFDoc::e_hex_strings);
    echo "Done. Result saved in unicodewrite.pdf...\n";
}