Skip to content

Aspose.Pdf Java for PHP #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Plugins/Aspose_Pdf_Java_for_PHP/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Aspose.Pdf Java for PHP
Aspose Pdf Java for PHP is a PHP project that demonstrates / provides the Aspose.Pdf for Java API usage examples in PHP by using PHP/JAVA Bridge.

You will need to configure PHP/Java Bridge before using any of the Aspose provided Java APIs in PHP e.g Aspose.Pdf, Aspose.Words, Aspose.Cells and Aspose.Slides etc.

For the configuration/setup of PHP/Java Bridge, please see:

http://php-java-bridge.sourceforge.net/pjb/index.php

To download Aspose.Pdf for Java API to be used with these examples through PHP/Java Bridge
Please navigate to:

http://www.aspose.com/community/files/72/java-components/aspose.pdf-for-java/

For most complete documentation of the project, check Aspose.Pdf Java for PHP confluence wiki link:

http://www.aspose.com/docs/display/pdfjava/2.+Aspose.Pdf+Java+For+Ruby


21 changes: 21 additions & 0 deletions Plugins/Aspose_Pdf_Java_for_PHP/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "asposepdf/aspose_pdf_java_for_php",
"description": "Aspose Pdf Java Examples for PHP Developers. Helps you understand how to use Aspose.Pdf Java classes in your PHP Projects.",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Fahad Adeel",
"email": "fahadadeel@gmail.com"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-4": {
"Aspose\\Pdf\\": "src/aspose/pdf"
}
}
}
19 changes: 19 additions & 0 deletions Plugins/Aspose_Pdf_Java_for_PHP/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Aspose\Pdf\WorkingWithDocumentConversion;

use com\aspose\pdf\Document as Document;

class PdfToDoc {

public static function run($dataDir=null)
{
# Open the target document
$pdf = new Document($dataDir . 'input1.pdf');

# Save the concatenated output file (the target document)
$pdf->save($dataDir . "output.doc");

print "Document has been converted successfully" . PHP_EOL;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Aspose\Pdf\WorkingWithDocumentConversion;

use com\aspose\pdf\Document as Document;
use com\aspose\pdf\ExcelSaveOptions as ExcelSaveOptions;

class PdfToExcel {

public static function run($dataDir=null)
{
# Open the target document
$pdf = new Document($dataDir . 'input1.pdf');

# Instantiate ExcelSave Option object
$excelsave = new ExcelSaveOptions();

# Save the output to XLS format
$pdf->save($dataDir . "Converted_Excel.xls", $excelsave);

print "Document has been converted successfully" . PHP_EOL;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Aspose\Pdf\WorkingWithDocumentConversion;

use com\aspose\pdf\Document as Document;
use com\aspose\pdf\SvgSaveOptions as SvgSaveOptions;


class PdfToSvg {

public static function run($dataDir=null)
{
# Open the target document
$pdf = new Document($dataDir . 'input1.pdf');

# instantiate an object of SvgSaveOptions
$save_options = new SvgSaveOptions();

# do not compress SVG image to Zip archive
$save_options->CompressOutputToZipArchive = false;

# Save the output to XLS format
$pdf->save($dataDir . "Output.svg", $save_options);

print "Document has been converted successfully" . PHP_EOL;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Aspose\Pdf\WorkingWithDocumentConversion;

use com\aspose\pdf\Document as Document;
use com\aspose\pdf\SvgLoadOptions as SvgLoadOptions;

class SvgToPdf {

public static function run($dataDir=null)
{
# Instantiate LoadOption object using SVG load option
$options = new SvgLoadOptions();

# Create document object
$pdf = new Document($dataDir . 'Example.svg', $options);

# Save the output to XLS format
$pdf->save($dataDir . "SVG.pdf");

print "Document has been converted successfully";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
namespace Aspose\Pdf\WorkingWithDocumentObject;

use com\aspose\pdf\Document as Document;
use com\aspose\pdf\JavascriptAction as JavascriptAction;


class AddJavascript {

public static function run($dataDir=null)
{
# Open a pdf document.
$doc = new Document($dataDir . "input1.pdf");

# Adding JavaScript at Document Level
# Instantiate JavascriptAction with desried JavaScript statement
$javaScript = new JavascriptAction("this.print({bUI:true,bSilent:false,bShrinkToFit:true});");

# Assign JavascriptAction object to desired action of Document
$doc->setOpenAction($javaScript);

# Adding JavaScript at Page Level
$doc->getPages()->get_Item(2)->getActions()->setOnOpen(new JavascriptAction("app.alert('page 2 is opened')"));
$doc->getPages()->get_Item(2)->getActions()->setOnClose(new JavascriptAction("app.alert('page 2 is closed')"));

# Save PDF Document
$doc->save($dataDir . "JavaScript-Added.pdf");

print "Added JavaScript Successfully, please check the output file.";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace Aspose\Pdf\WorkingWithDocumentObject;

use com\aspose\pdf\Document as Document;
use com\aspose\pdf\TocInfo as TocInfo;
use com\aspose\pdf\TextFragment as TextFragment;
use com\aspose\pdf\TextSegment as TextSegment;
use com\aspose\pdf\Heading as Heading;


class AddToc {

public static function run($dataDir=null)
{
# Open a pdf document.
$doc = new Document($dataDir . "input1.pdf");

# Get access to first page of PDF file
$toc_page = $doc->getPages()->insert(1);

# Create object to represent TOC information
$toc_info = new TocInfo();
$title = new TextFragment("Table Of Contents");
$title->getTextState()->setFontSize(20);
#title.getTextState().setFontStyle(Rjb::import('com.aspose.pdf.FontStyles.Bold'))

# Set the title for TOC
$toc_info->setTitle($title);
$toc_page->setTocInfo($toc_info);

# Create string objects which will be used as TOC elements
$titles = array("First page", "Second page");

$i = 0;
while ($i < 2){
# Create Heading object
$heading2 = new Heading(1);

$segment2 = new TextSegment();
$heading2->setTocPage($toc_page);
$heading2->getSegments()->add($segment2);

# Specify the destination page for heading object
$heading2->setDestinationPage($doc->getPages()->get_Item($i + 2));

# Destination page
$heading2->setTop($doc->getPages()->get_Item($i + 2)->getRect()->getHeight());

# Destination coordinate
$segment2->setText($titles[$i]);

# Add heading to page containing TOC
$toc_page->getParagraphs()->add($heading2);

$i +=1;
}

# Save PDF Document
$doc->save($dataDir . "TOC.pdf");

print "Added TOC Successfully, please check the output file.";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Aspose\Pdf\WorkingWithDocumentObject;

use com\aspose\pdf\Document as Document;

class GetDocumentWindow {

public static function run($dataDir=null)
{
# Open a pdf document.
$doc = new Document($dataDir . "input1.pdf");

# Get different document properties
# Position of document's window - Default: false
print "CenterWindow :- " . $doc->getCenterWindow() . PHP_EOL;

# Predominant reading order; determine the position of page
# when displayed side by side - Default: L2R
print "Direction :- " . $doc->getDirection() . PHP_EOL;

# Whether window's title bar should display document title.
# If false, title bar displays PDF file name - Default: false
print "DisplayDocTitle :- " . $doc->getDisplayDocTitle() . PHP_EOL;

#Whether to resize the document's window to fit the size of
#first displayed page - Default: false
print "FitWindow :- " . $doc->getFitWindow() . PHP_EOL;

# Whether to hide menu bar of the viewer application - Default: false
print "HideMenuBar :-" . $doc->getHideMenubar() . PHP_EOL;

# Whether to hide tool bar of the viewer application - Default: false
print "HideToolBar :-" . $doc->getHideToolBar() . PHP_EOL;

# Whether to hide UI elements like scroll bars
# and leaving only the page contents displayed - Default: false
print "HideWindowUI :-" . $doc->getHideWindowUI() . PHP_EOL;

# The document's page mode. How to display document on exiting full-screen mode.
print "NonFullScreenPageMode :-" . $doc->getNonFullScreenPageMode() . PHP_EOL;

# The page layout i.e. single page, one column
print "PageLayout :-" . $doc->getPageLayout() . PHP_EOL;

#How the document should display when opened.
print "pageMode :-" . $doc->getPageMode() . PHP_EOL;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Aspose\Pdf\WorkingWithDocumentObject;

use com\aspose\pdf\Document as Document;

class GetPdfFileInfo {

public static function run($dataDir=null)
{

# Open a pdf document.
$doc = new Document($dataDir . "input1.pdf");

# Get document information
$doc_info = $doc->getInfo();

# Show document information
print "Author:-" . $doc_info->getAuthor();
print "Creation Date:-" . $doc_info->getCreationDate();
print "Keywords:-" . $doc_info->getKeywords();
print "Modify Date:-" . $doc_info->getModDate();
print "Subject:-" . $doc_info->getSubject();
print "Title:-" . $doc_info->getTitle();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Aspose\Pdf\WorkingWithDocumentObject;

use com\aspose\pdf\Document as Document;

class GetXMPMetadata {

public static function run($dataDir=null)
{

# Open a pdf document.
$doc = new Document($dataDir . "input1.pdf");

# Get properties
print "xmp:CreateDate: " + $doc->getMetadata()->get_Item("xmp:CreateDate") . PHP_EOL;
print "xmp:Nickname: " + $doc->getMetadata()->get_Item("xmp:Nickname") . PHP_EOL;
print "xmp:CustomProperty: " + $doc->getMetadata()->get_Item("xmp:CustomProperty") . PHP_EOL;
}

}
Loading