Skip to content

Commit 681c708

Browse files
Merge pull request aspose-pdf#11 from fahadadeel/master
Aspose.Pdf Java for PHP
2 parents 861e816 + 1ffdab2 commit 681c708

File tree

63 files changed

+2243
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2243
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Aspose.Pdf Java for PHP
2+
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.
3+
4+
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.
5+
6+
For the configuration/setup of PHP/Java Bridge, please see:
7+
8+
http://php-java-bridge.sourceforge.net/pjb/index.php
9+
10+
To download Aspose.Pdf for Java API to be used with these examples through PHP/Java Bridge
11+
Please navigate to:
12+
13+
http://www.aspose.com/community/files/72/java-components/aspose.pdf-for-java/
14+
15+
For most complete documentation of the project, check Aspose.Pdf Java for PHP confluence wiki link:
16+
17+
http://www.aspose.com/docs/display/pdfjava/2.+Aspose.Pdf+Java+For+Ruby
18+
19+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "asposepdf/aspose_pdf_java_for_php",
3+
"description": "Aspose Pdf Java Examples for PHP Developers. Helps you understand how to use Aspose.Pdf Java classes in your PHP Projects.",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Fahad Adeel",
9+
"email": "fahadadeel@gmail.com"
10+
}
11+
],
12+
"minimum-stability": "dev",
13+
"require": {
14+
"php": ">=5.3.0"
15+
},
16+
"autoload": {
17+
"psr-4": {
18+
"Aspose\\Pdf\\": "src/aspose/pdf"
19+
}
20+
}
21+
}

Plugins/Aspose_Pdf_Java_for_PHP/composer.lock

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Aspose\Pdf\WorkingWithDocumentConversion;
4+
5+
use com\aspose\pdf\Document as Document;
6+
7+
class PdfToDoc {
8+
9+
public static function run($dataDir=null)
10+
{
11+
# Open the target document
12+
$pdf = new Document($dataDir . 'input1.pdf');
13+
14+
# Save the concatenated output file (the target document)
15+
$pdf->save($dataDir . "output.doc");
16+
17+
print "Document has been converted successfully" . PHP_EOL;
18+
}
19+
20+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Aspose\Pdf\WorkingWithDocumentConversion;
4+
5+
use com\aspose\pdf\Document as Document;
6+
use com\aspose\pdf\ExcelSaveOptions as ExcelSaveOptions;
7+
8+
class PdfToExcel {
9+
10+
public static function run($dataDir=null)
11+
{
12+
# Open the target document
13+
$pdf = new Document($dataDir . 'input1.pdf');
14+
15+
# Instantiate ExcelSave Option object
16+
$excelsave = new ExcelSaveOptions();
17+
18+
# Save the output to XLS format
19+
$pdf->save($dataDir . "Converted_Excel.xls", $excelsave);
20+
21+
print "Document has been converted successfully" . PHP_EOL;
22+
}
23+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Aspose\Pdf\WorkingWithDocumentConversion;
4+
5+
use com\aspose\pdf\Document as Document;
6+
use com\aspose\pdf\SvgSaveOptions as SvgSaveOptions;
7+
8+
9+
class PdfToSvg {
10+
11+
public static function run($dataDir=null)
12+
{
13+
# Open the target document
14+
$pdf = new Document($dataDir . 'input1.pdf');
15+
16+
# instantiate an object of SvgSaveOptions
17+
$save_options = new SvgSaveOptions();
18+
19+
# do not compress SVG image to Zip archive
20+
$save_options->CompressOutputToZipArchive = false;
21+
22+
# Save the output to XLS format
23+
$pdf->save($dataDir . "Output.svg", $save_options);
24+
25+
print "Document has been converted successfully" . PHP_EOL;
26+
}
27+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Aspose\Pdf\WorkingWithDocumentConversion;
4+
5+
use com\aspose\pdf\Document as Document;
6+
use com\aspose\pdf\SvgLoadOptions as SvgLoadOptions;
7+
8+
class SvgToPdf {
9+
10+
public static function run($dataDir=null)
11+
{
12+
# Instantiate LoadOption object using SVG load option
13+
$options = new SvgLoadOptions();
14+
15+
# Create document object
16+
$pdf = new Document($dataDir . 'Example.svg', $options);
17+
18+
# Save the output to XLS format
19+
$pdf->save($dataDir . "SVG.pdf");
20+
21+
print "Document has been converted successfully";
22+
}
23+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
namespace Aspose\Pdf\WorkingWithDocumentObject;
3+
4+
use com\aspose\pdf\Document as Document;
5+
use com\aspose\pdf\JavascriptAction as JavascriptAction;
6+
7+
8+
class AddJavascript {
9+
10+
public static function run($dataDir=null)
11+
{
12+
# Open a pdf document.
13+
$doc = new Document($dataDir . "input1.pdf");
14+
15+
# Adding JavaScript at Document Level
16+
# Instantiate JavascriptAction with desried JavaScript statement
17+
$javaScript = new JavascriptAction("this.print({bUI:true,bSilent:false,bShrinkToFit:true});");
18+
19+
# Assign JavascriptAction object to desired action of Document
20+
$doc->setOpenAction($javaScript);
21+
22+
# Adding JavaScript at Page Level
23+
$doc->getPages()->get_Item(2)->getActions()->setOnOpen(new JavascriptAction("app.alert('page 2 is opened')"));
24+
$doc->getPages()->get_Item(2)->getActions()->setOnClose(new JavascriptAction("app.alert('page 2 is closed')"));
25+
26+
# Save PDF Document
27+
$doc->save($dataDir . "JavaScript-Added.pdf");
28+
29+
print "Added JavaScript Successfully, please check the output file.";
30+
}
31+
32+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace Aspose\Pdf\WorkingWithDocumentObject;
4+
5+
use com\aspose\pdf\Document as Document;
6+
use com\aspose\pdf\TocInfo as TocInfo;
7+
use com\aspose\pdf\TextFragment as TextFragment;
8+
use com\aspose\pdf\TextSegment as TextSegment;
9+
use com\aspose\pdf\Heading as Heading;
10+
11+
12+
class AddToc {
13+
14+
public static function run($dataDir=null)
15+
{
16+
# Open a pdf document.
17+
$doc = new Document($dataDir . "input1.pdf");
18+
19+
# Get access to first page of PDF file
20+
$toc_page = $doc->getPages()->insert(1);
21+
22+
# Create object to represent TOC information
23+
$toc_info = new TocInfo();
24+
$title = new TextFragment("Table Of Contents");
25+
$title->getTextState()->setFontSize(20);
26+
#title.getTextState().setFontStyle(Rjb::import('com.aspose.pdf.FontStyles.Bold'))
27+
28+
# Set the title for TOC
29+
$toc_info->setTitle($title);
30+
$toc_page->setTocInfo($toc_info);
31+
32+
# Create string objects which will be used as TOC elements
33+
$titles = array("First page", "Second page");
34+
35+
$i = 0;
36+
while ($i < 2){
37+
# Create Heading object
38+
$heading2 = new Heading(1);
39+
40+
$segment2 = new TextSegment();
41+
$heading2->setTocPage($toc_page);
42+
$heading2->getSegments()->add($segment2);
43+
44+
# Specify the destination page for heading object
45+
$heading2->setDestinationPage($doc->getPages()->get_Item($i + 2));
46+
47+
# Destination page
48+
$heading2->setTop($doc->getPages()->get_Item($i + 2)->getRect()->getHeight());
49+
50+
# Destination coordinate
51+
$segment2->setText($titles[$i]);
52+
53+
# Add heading to page containing TOC
54+
$toc_page->getParagraphs()->add($heading2);
55+
56+
$i +=1;
57+
}
58+
59+
# Save PDF Document
60+
$doc->save($dataDir . "TOC.pdf");
61+
62+
print "Added TOC Successfully, please check the output file.";
63+
}
64+
65+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace Aspose\Pdf\WorkingWithDocumentObject;
4+
5+
use com\aspose\pdf\Document as Document;
6+
7+
class GetDocumentWindow {
8+
9+
public static function run($dataDir=null)
10+
{
11+
# Open a pdf document.
12+
$doc = new Document($dataDir . "input1.pdf");
13+
14+
# Get different document properties
15+
# Position of document's window - Default: false
16+
print "CenterWindow :- " . $doc->getCenterWindow() . PHP_EOL;
17+
18+
# Predominant reading order; determine the position of page
19+
# when displayed side by side - Default: L2R
20+
print "Direction :- " . $doc->getDirection() . PHP_EOL;
21+
22+
# Whether window's title bar should display document title.
23+
# If false, title bar displays PDF file name - Default: false
24+
print "DisplayDocTitle :- " . $doc->getDisplayDocTitle() . PHP_EOL;
25+
26+
#Whether to resize the document's window to fit the size of
27+
#first displayed page - Default: false
28+
print "FitWindow :- " . $doc->getFitWindow() . PHP_EOL;
29+
30+
# Whether to hide menu bar of the viewer application - Default: false
31+
print "HideMenuBar :-" . $doc->getHideMenubar() . PHP_EOL;
32+
33+
# Whether to hide tool bar of the viewer application - Default: false
34+
print "HideToolBar :-" . $doc->getHideToolBar() . PHP_EOL;
35+
36+
# Whether to hide UI elements like scroll bars
37+
# and leaving only the page contents displayed - Default: false
38+
print "HideWindowUI :-" . $doc->getHideWindowUI() . PHP_EOL;
39+
40+
# The document's page mode. How to display document on exiting full-screen mode.
41+
print "NonFullScreenPageMode :-" . $doc->getNonFullScreenPageMode() . PHP_EOL;
42+
43+
# The page layout i.e. single page, one column
44+
print "PageLayout :-" . $doc->getPageLayout() . PHP_EOL;
45+
46+
#How the document should display when opened.
47+
print "pageMode :-" . $doc->getPageMode() . PHP_EOL;
48+
}
49+
50+
}

0 commit comments

Comments
 (0)