Skip to content

Commit

Permalink
Fixed README code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
manuels committed Sep 30, 2012
1 parent bf3925a commit 41d187d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,38 @@ API naming convention
=====================

- Function names are like their [libharu API](https://github.com/libharu/libharu/wiki) pendants but object-oriented and their first letter is lowercase.

```
// javascript code C code
var pdf = new HPDF(); HPDF_Doc pdf = HPDF_New (error_handler, NULL);
var page = pdf.addPage(); HPDF_Page page = HPDF_AddPage(pdf);
pdf.free(); HPDF_Free(pdf);
```

- ``Get``s are ommitted and ``Set``s are kept

```
// javascript code C code
var width = page.width(); HPDF_REAL width = HPDF_Page_GetWidth(page);
page.setLineWidth(5); HPDF_Page_SetLineWidth(page, 5);
```

- Use ``undefined`` in Javascript where you would use ``NULL`` in C
```
// javascript code C code
var root = pdf.createOutline(undefined, root = HPDF_CreateOutline (pdf, NULL, "OutlineRoot", NULL);
"OutlineRoot", undefined);
```

- Use strings (case irrelevant) in Javascript where you would use constants in C
```
// javascript code C code
page.setSize('B5', 'landscape'); HPDF_Page_SetSize(page, HPDF_PAGE_SIZE_B5, HPDF_PAGE_LANDSCAPE);
```

- Tailing ``NULL``s/``undefined``s can be ommitted
```
// javascript code C code
var font = pdf.font('Helvetica'); HPDF_Font font = HPDF_PDF_GetFont(pdf, 'Helvetica', NULL);
```

- Instead of the error handling function in C ``Exception``s are thrown in Javascript

Expand Down

0 comments on commit 41d187d

Please sign in to comment.