This is an archived forum post. The information may be outdated. Contact us if you have any questions.

How to configure API Java

nitrox13 wrote on 2015-10-17:
How to configure API Java

My code

import com.pdfcrowd.*;
import java.io.*;

public class PdfcrowdTest {
public static void main(String[] args) {
try
{
FileOutputStream fileStream;

// create an API client instance
Client client = new Client("xxx", "xxx");

// convert an HTML file
fileStream = new FileOutputStream("xxx");
client.convertFile("xxx", fileStream);
fileStream.close();

// retrieve the number of tokens in your account
Integer ntokens = client.numTokens();
}
catch(PdfcrowdError why) {
System.err.println(why.getMessage());
}
catch(IOException exc) {
// handle the exception
}
}
}

What extension for this file?

How to execute him(it) php there?
support wrote on 2015-10-17:
> What extension for this file?

.java


> How to execute him(it) php there?

If you want to convert a local html file:
client.convertFile("MyDocument.html", fileStream);


If you want to convert a web page
client.convertFile("http://example.com", fileStream);
nitrox13 wrote on 2015-10-17:
Thank you, but .java is not executable in my page .php

Test.php

<?php
client.convertFile("xxx", fileStream);
?>
support wrote on 2015-10-20:
Ok. If you want to implement our API in your PHP app, you can use our PHP API client library.