Monthly Archives: May 2006

Record audio with multiple sound cards

Our audio record object can support recording with multiple sound cards. You can do like this:

1. Create multiple audio record objects at initialization time like this. (Take VB.Net as example)

Public Class Form1
    Inherits System.Windows.Forms.Form
    Private rec As AudioCtl.CAudioRecord
    Private rec1 As AudioCtl.CAudioRecord
 
#Region ” Windows Form Designer generated code ”
    Public Sub New()
        MyBase.New()

        ‘This call is required by the Windows Form Designer.
        InitializeComponent()
        ‘Add any initialization after the InitializeComponent() call
        rec = New AudioCtl.CAudioRecord
        rec1 = New AudioCtl.CAudioRecord
        rec.SetSilenceLevel(1000)
    End Sub

 

2. Then the record objects can be used independently by setting the device index to different sound cards. You can record different source line for different sound cards and save the audio in different output files.

Html to image on Linux

If you want to convert html to image on linux, try out html2image linux

It is a command line tool that is easy to use.

We have tested it on the latest Redhat Fedora 5. To use it, open an XTerm window in Gnome, and play with the command line.

Some users may experience a problem that reports missing libpangocairo.

Here is the solution:

Download pango RPM here, extract it and install.

rpm -Uivh cairo-1.0.2-1.1.fc4.nr.i386.rpm glitz-0.4.3-1.1.fc4.nr.i386.rpm libpixman-0.1.5-1.1.fc4.nr.i386.rpm pango-1.10.3-1.1.fc4.nr.i386.rpm pango-devel-1.10.3-1.1.fc4.nr.i386.rpm

Then it should work. Email us if you need any help!

 

 

Stack error with VS2005

Recently I found an issue with our VB.Net and C# demo for PDF components. When compiling with VS2005, the component will fail to be initialized with a stack overflow error. The one compiled with VS2003 (.Net 1.1), the VB, VBScript demo all works well. So I doubt if this is a bug of .Net 2.0.

Overal it is very strange error. The current workaround I found is to call the PDF methods in a second thread which can work well on both .Net 1.1 and 2.0.

Here is the new demo codes for our PDF Split and Merge component.

  Private Sub DoTest()
        Dim pdf As PDFSplitMerge.CPDFSplitMergeObj

        pdf = New CPDFSplitMergeObj

        pdf.SetCode(“Your license code here”)

        pdf.Split(“..1.pdf”, “1;1;1″, “..sp1-%d.pdf”)
        pdf.Split(“..1.pdf”, “1;2;3;4;1-2,3-4;1″, “..sp%d.pdf”)

        pdf.Merge(“..sp0.pdf|..sp1.pdf”, “..m1.pdf”)
        pdf.Merge(“..1.pdf?1-2|..sp1.pdf”, “..m2.pdf”)
        pdf.Merge(“..1.pdf?1-2|..sp1.pdf?2″, “..m1.pdf”)

        pdf = Nothing
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim job As Thread

        job = New Thread(New ThreadStart(AddressOf DoTest))
        job.Start()
        job.Join()
    End Sub

I will keep it updated if we find more deep reason for this issue.

 

Convert html to image at a given size.

Html snapshot can capture the whole html page into image as JPG, TIFF and PNG etc. Sometimes, you may not need a full image but an image at a given width and height. There are several ways to do this:

 1. Use EnableSnapDimensionAsImageSize and SetSnapDimension

     ‘demo how to convert html to image

Dim snap

‘Create the Html Snapshot Object
Set snap = CreateObject(“HTMLSNAP2.HtmlSnap.1″)

‘Set the time to wait for web page loading
snap.SetTimeOut CLng(200000)

‘Set the browser window size
snap.SetSnapDimension 250, 250

‘Set this if you want the image size exactly to be 1000,1000
snap.EnableSnapDimensionAsImageSize 1

‘Begin to capture the web page
snap.SnapUrl “http://www.google.com/“, “google.jpg”

‘Free object
Set snap = Nothing

 

2. Use SetClipRect method then you can get out the image with GetBitmapHandle after calling SnapUrl.

3. Get out the whole image with GetBitmapHandle and apply post processing to cut it into any size as you wish
 

Tutorial: Install php and run html snapshot with IIS

So you are a PHP fan that wants to convert html to image? You can do it with html snapshot with php on windows server. This tutorial shows how to do this with php and IIS. ( Apache for windows can also be used as well.)

My steps (based on Win2003)
1. Download php for win32 from php.net
http://www.php.net/downloads.php

Using PHP 5.1.4 zip as example,
extract the files to c:php

Following the instruction here to enable php in IIS
http://www.simongibson.com/intranet/php2003/
2. Write a small php with the expression and put it to c:inetpubwwwroot to test if php works
. Make sure it is ok

3. Download html snapshot free trial. Install it on the server. Get the php demo and put it in wwwroot. Make sure your IIS account (IUSR_MachineName) can write to the folder that will save the image file.  Alternatively, you can also call SetLogOnUser before calling SnapUrl.

 The example code I used is here:

< ?php

$url = “http://www.google.com/“;
$path = getcwd().”\”;
$img = “1.jpg”;
$timg = “1s.jpg”;

$com = new COM(“HTMLSNAP2.HtmlSnap.1″);

$com->SetLogOnUser(“user”, “.”, “user”);

$com->SnapUrl($url, $path.$img );

$com->GetThumbnailImage($path.$img, $path.$timg, 100, 100, 1);

print “Snapshot of “.$url.”. Click to enlarge
“;
 
?>

Load the php page in IE, you will find the image converted from html in your wwwroot folder.  

Note that I call SetLogOnUser method with an account named “user”. This could be an account that is created specially for converting html to image. You can give him enough privilege to write files or loading ActiveX like flash movie. It can be an Administrator account (needed for capturing flash). Security concern? It is no problem since Html snapshot will only impersonate that user when doing html to image. It will revert to normal web user after SnapUrl call. So it is secure. :)

 

 

 

Convert html to EMF and WMF with html snapshot

As you know, Html snapshot can convert html to raster image format like jpg, jpeg, tiff, png, gif and bmp.

Now it can convert html to vector image format like EMF and WMF. It is a new feature of html snapshot. Hope you like it.

EMF/WMF are the meta file format supported natively by Windows based OS. It is vector image format which means the image is not defined pixel by pixel. Instead, a series of drawing operations are used to render the image.