HTML to PDF converter for Java and .NET

<< back

Pd4Cmd: PD4ML and command line

 PD4ML distribution includes a simple command-line API wrapper Pd4Cmd. (there is the help page with basic usage examples)

Here we are going to review only some special cases.

The command line syntax allows to define document header or footer code in HTML. The HTML code may include some reserved characters, have special meaning in command shell on the hosting platform.

First, you need to make sure, space characters do not corrupt the entire command line.

On Win32 platform, the code must me enclosed to double quotes, or to single quotes on UNIX-derived platforms (including MacOS).

If the HTML code itself has double or single quotes - they have to be substituted with safer equivalents: on Win32, for example, double quotes replaced with single quotes. Or, if it is possible, removed completely: PD4ML accepts attribute values without quotes (in contrast to XML requirements).

On Win32 we were not able to build a command line with an HTML snippet, which has both a space and a double quote. Please let us know if there is a solution.

On UNIX you may escape a single quote with '\'' sequence (single quote, backslash, single quote two times), which looks strange, but works.

On all platforms you should be careful with the following characters in command lines:

'<', '>', '%', ';', '&', '|', '^'

Win32 addition to the list:

'(', ')', ','

UNIX addition to the list:

'{', '}', '[', ']', '$', '#', '*', '?', '`'

Make sure the characters are parts of a text, enclosed to appropriate quotes, or escaped.

If you run Pd4Cmd from an alien environment, like Perl, PHP etc, with an exec() or system() call, look for an exec method or function, which accepts a command line as an array of parameters. In the case a special character escaping is not needed. Methods with a single parameter (represents entire command line) require the escaping and may even add their own issues.

Copyright ©2004-20 zefer|org. All rights reserved. Bookmark and Share