Documentation for using Aspose.pdf with PHP

I want to use aspose.pdf with PHP via COM Interop.

I cannot find any documentation regarding this. Please direct me to the right place.


This message was posted using Aspose.Live 2 Forum

Hi,

Sorry for replying you late.

You can use Aspose.Pdf for .NET with PHP via COM Interop. First you need to install Aspose.Pdf for .NET and then register it with COM Interop (e.g. callable from unmanaged code).

[.NET Framework 2.0]

regasm "C:\Program Files\Aspose\Aspose.Pdf.Kit for .NET\bin\net20\Aspose.Pdf.Kit.dll" /codebase

You may also check the following link for information on how to Register Managed code library with COM. Use Aspose.Pdf.Kit for .NET via COM Interop

Once Aspose.Pdf for .NET is registered, please try using the following code snippet to create a simple PDF document with one text object.

[PHP]

<?php
echo "

Calling Aspose.Pdf for .NET from PHP using COM Interoperatibility

";

//set license
$lic = new COM("Aspose.Pdf.License");
$lic->SetLicense("D:\ASPOSE\Licences\Aspose.Total licenses\Aspose.Total.lic");

//Instantiate Pdf instance by calling its empty constructor
$pdf = new COM("Aspose.Pdf.Pdf");
//Create a new section in the Pdf object
$pdfsection = new COM("Aspose.Pdf.Section");
//Add section to Pdf object
$pdf->Sections->Add($pdfsection);

// Create Text object
$SampleText = new COM("Aspose.Pdf.Text");
//Add Text Segment to text object

$seg1 = new COM("Aspose.Pdf.Segment");
//Assign some content to the segment
$seg1->Content = "HelloWorld using PHP";
//Add segment (with red text color) to the paragraph
$SampleText->Segments->Add($seg1);
// Add Text paragraph to paragraphs collection of a section
$pdfsection->Paragraphs->Add($SampleText);

// Save the PDF document
$pdf->Save("d:\pdftest\HelloWorldinPHP.pdf");

?>

Please try using it and in case you need any further assistance, please feel free to contact.

Hi

Thanks for the reply. With the little information available on the internet and aspose site, I had already tried out the example PHP script using aspose. I was just wondering other than the API reference material if there was any specific documentation for use of aspose.pdf with PHP. Many times some of the commands do not match the API documentaton.

Thanks

It is so frustrating that there is no reference material available for using Aspose.Pdf or any other Aspose products via COM Interop with PHP. Most of the examples given in C# or VB.Net do not work directly in PHP. Every step is a struggle.

Atleast the Aspose team can declare that they dont have any information on this.

Raji

Hello Raji,

I am afraid currently the complete documentation of using Aspose.Pdf with PHP is not available and currently the documentation is only for C# and VB.NET language over the Live Server. In my previous post I have shared some sample code on how you can use Aspose.Pdf for .NET with PHP.

Please let us know where you are facing the problem and we will try our level best to get it resolved.

We apologize for your inconvenience.

Using the script you had sent earlier and reference the API manual I ventured to create a simple pdf file with tables using the script below but it throws an error at the point of creating Rows.

<?php

$pdf = new COM("Aspose.Pdf.Pdf");
$sec1 = new COM("Aspose.Pdf.Section");

$table1 = new COM("Aspose.Pdf.Table");
$sec1->Paragraphs->Add($table1);
$table1->ColumnWidths = "70 2cm";

$row1= $tables1->Rows->Add();
$cell1Row1 = $row1->Cells->Add("ColumnsSpan");
$cell1Row1->ColumnsSpan = 2;
$cell1Row1->Border->Add("BorderInfo");
$cell1Row1->Border->BorderInfo->SetBorderStyle(15,.5);

$row2 = $table1->Rows->Add();

$cell1Row2 = $row2->Cells->Add("cell1");
$cell1Row2->Border->Add("BorderInfo");
$cell1Row2->Border->BorderInfo->SetBorderStyle(15,.5);

$cell2Row2 = $row2->cells->Add("cell2");
$cell2Row2->Border->Add("BorderInfo");
$cell2Row2->Border->BorderInfo->SetBorderStyle(15,0.5,new Aspose.Pdf.Color("Red"));

$pdf1->Save("test.pdf");

?>

If not a complete manual atleast some guidelines as to how to use the API in PHP would be useful for me.

Thanks

Hi,

Thanks for sharing the code snippet.

I have tested the scenario and I am able to notice the problem. We are looking into the details of this issue and will keep you updated on the status of correction. We apologize for your inconvenience.