Jump to content


Photo

Wrapper for libHaru (creates PDFs) (stdlib) [r1, 2009-05-11]


  • Please log in to reply
16 replies to this topic

#1 Thrawn

Thrawn
  • Members
  • 30 posts

Posted 11 May 2009 - 11:16 AM

libHaru Wrapper

libHaru is a free, cross platform, open source library for generating PDF files.
It supports the following features:
- Generating PDF files with lines, text, images.
- Outline, text annotation, link annotation.
- Compressing document with deflate-decode.
- Embedding PNG, Jpeg images.
- Embedding Type1 font and TrueType font.
- Creating encrypted PDF files.
- Using various character sets (ISO8859-1~16, MSCP1250~8, KOI8-R).
- Supporting CJK fonts and encodings.

Documentation
Download (ahk-lib)
Download (required dlls)

you want the latest msvc8 windows binary release (libhpdf.dll, libpng13.dll and zlib.dll)

Examples
Arc (pdf, code, jpg)
Encoding List (pdf, code, jpg)
GridSheet (pdf, code 1, code 2)
Image (pdf, code, jpg)
Line (pdf, code, jpg)
Outline (pdf, code, jpg)
Permission (pdf, code)
RawImage (pdf, code)
Text 1 (pdf, code, jpg)
Text 2 (pdf, code, jpg)
Thumbnails (pdf, code, jpg) Images from here, uses tic's gdi+ stdlib for scaling images before embedding
TrueType Font (pdf, code, jpg)
ANSI .txt to .pdf (code)Known Bugs:Annotations - not working
Dashed Lines - not workingPDFs generated from the examples (zip, 397kb)
Download (lib + examples, zip, 229kb)

#2 Drugwash

Drugwash
  • Members
  • 1048 posts

Posted 11 May 2009 - 01:54 PM

Great library and great wrapper! 8)

One minor issue with the thumbnails example under Win9x: there is no User Shell Folders > My Pictures key, unless maybe there are more users set up, which is not so usual for a Win9x installation.

A small addition would make it work correctly under 9x - all other examples work perfectly:
shfld := ( (A_OSType in WIN32_WINDOWS) ? "" : "User " ) . "Shell Folders"
   RegRead, path, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\%shfld%, My Pictures
Hopefully this doesn't affect other OS versions. I've also enhanced the thumbnails script a bit, adding other picture types. Others can easily be added:
Loop, %path%\*, 0, 0
	if A_LoopFileExt in jpg,jpeg,png,bmp,gif
The only problem I have is with a small 96x96 PNG image that for some reason appears corrupt when upscaled. Dunno whose fault is, since libpng13.dll doesn't seem to be used (tried an old version I already had installed in %system% as well as the VC2005-dependant found in the VC8 binary zip - since the VC6 zip misses the actual binaries). Also tried with 2 different versions of zlib.dll - no change.

Anyway, this is not wrapper's problem so no sweat. Thanks again and keep up the good work! ;)

#3 Thrawn

Thrawn
  • Members
  • 30 posts

Posted 11 May 2009 - 05:15 PM

Thanks Drugwash.
I've implemented your improvements.

#4 ..:: Free Radical ::..

..:: Free Radical ::..
  • Members
  • 74 posts

Posted 12 May 2009 - 03:57 AM

Thank you very much for this :D
Would try making a front end for my work

#5 Thrawn

Thrawn
  • Members
  • 30 posts

Posted 12 May 2009 - 09:44 AM

The only problem I have is with a small 96x96 PNG image that for some reason appears corrupt when upscaled. Dunno whose fault is, since libpng13.dll doesn't seem to be used (tried an old version I already had installed in %system% as well as the VC2005-dependant found in the VC8 binary zip - since the VC6 zip misses the actual binaries). Also tried with 2 different versions of zlib.dll - no change.

libpng13.dll is not being used in the thumbnails example, because every image is being resampled and converted to jpeg prior to embedding it into the pdf. :roll:
So, if you take out the resizing part and let it handle png images separately with HPDF_LoadPNGImageFromFile() it uses libpng13.dll.

#6 Drugwash

Drugwash
  • Members
  • 1048 posts

Posted 12 May 2009 - 04:08 PM

I'm more curious about who corrupts the PNG. From what you say, it could be gdiplus, but I replaced the previous XP-SP2 version (5.1.3102.2180) with XP-SP3 (5.1.3102.5660) and corruption still occurs. :cry:

When I let libpng13 to handle the PNG files (as you mentioned above), they all come out fine, without corruption. Whadda heck is goin' on here... :?:

Posted Image <-> Posted Image

#7 Thrawn

Thrawn
  • Members
  • 30 posts

Posted 14 May 2009 - 04:19 PM

you could adapt the resampling function so the converted pictures won't be deleted and see if they get corrupted before they are embedded in the pdf.
if they are corrupted -> it's gdi+ or the resampling code
if they are fine > its libharus fault

#8 Drugwash

Drugwash
  • Members
  • 1048 posts

Posted 14 May 2009 - 07:21 PM

It gets corrupted right after GDIplus conversion. Guess I gotta find a version that works.. if there's any. :(
Thanks for the suggestion, got me closer to the (bitter) truth.

#9 Thrawn

Thrawn
  • Members
  • 30 posts

Posted 18 May 2009 - 09:34 PM

as a workaround you could use this (ImageMagick Wrapper) to convert the png to jpeg, although it would bloat the example with additional dlls.

#10 Drugwash

Drugwash
  • Members
  • 1048 posts

Posted 18 May 2009 - 10:12 PM

Frankly I kinda dislike the JPEG format due to its lossy nature. PNG has good quality and small size, its only disadvantage would be unsupported alpha layer on 9x systems. I think I'll keep conversion disabled for PNGs in this particular case.

Thanks for providing that link though, hopefully it will be of help for someone.

#11 gwarble

gwarble
  • Members
  • 508 posts

Posted 27 August 2009 - 06:53 AM

thanks for a great wrapper, i'm having fun playing with it.

quick question, zlib and libpng13 DLLs are needed, but i like to keep my dlls in %A_ScriptDir%\Resources\*.dll but its not finding them unless they are in %A_ScriptDir%\*.dll or %windir%\system32\*.dll

know how to affect those dlls being called? or is buried inside the libharu .dll

thanks
- gwarble

edit: never could find the call, so temporarily changing SetWorkingDir to the dll folder was the only solution i could find

#12 ..:: Free Radical ::..

..:: Free Radical ::..
  • Members
  • 74 posts

Posted 10 April 2010 - 11:29 PM

Ok, I finally felt the need to use this excellent library for making pdfs from my scanned images. This is so fast. I mean its instantaneous. It converted a set of 1000 images (a mix of HiRes jpegs and pngs) on my lowly dual core in under a second!

Thanks again for this nifty wrapper and excellent examples!

And yes, I used HPDF_LoadPngImageFromFile and not ImageMagick or gdip for the pngs.

Is it possible to embed more formats like bmp, gifs and tiffs without using gdip to convert for this?

EDIT:
I realized I was using libHPDF v2.0.8.0 which never prompted me for libPNG and works like a charm.

#13 Cyrille

Cyrille
  • Guests

Posted 23 August 2010 - 09:56 PM

Hello
I start my first program in AutoHotkey. I use LibHaru to create PDFs.
But I have a problem. Accented characters (é, è, à ...) don't appear correctly in the PDF. They are replaced by Ø.
Do you know how to solve this problem ?
In advance, thank you.

PS: Sorry for my English, I'm French and I'm very bad at English and programming.

#14 Guest4

Guest4
  • Guests

Posted 05 April 2011 - 10:24 AM

Hi ..

I am trying to get LibHaru Windows Binaries 2.1.0 VC8 but the link on http://libharu.org/wiki/Downloads is broken (site down and will be unavailable until the server has been rebuilt)

If any one already has them.. I do appreciate helping me to get them

Thanks

#15 Thrawn

Thrawn
  • Members
  • 30 posts

Posted 05 April 2011 - 06:07 PM

Hi ..

I am trying to get LibHaru Windows Binaries 2.1.0 VC8 but the link on <!-- m -->http://libharu.org/wiki/Downloads<!-- m --> is broken (site down and will be unavailable until the server has been rebuilt)

If any one already has them.. I do appreciate helping me to get them

Thanks

<!-- m -->http://thrawn.einfac... ... 8-dlls.zip<!-- m -->