AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Wrapper for libHaru (creates PDFs) (stdlib) [r1, 2009-05-11]
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Thrawn



Joined: 12 May 2008
Posts: 30
Location: Germany

PostPosted: Mon May 11, 2009 11:16 am    Post subject: Wrapper for libHaru (creates PDFs) (stdlib) [r1, 2009-05-11] Reply with quote

libHaru Wrapper
Quote:
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

Known Bugs:
    Annotations - not working
    Dashed Lines - not working

PDFs generated from the examples (zip, 397kb)
Download (lib + examples, zip, 229kb)


Last edited by Thrawn on Wed Jun 03, 2009 1:11 pm; edited 1 time in total
Back to top
View user's profile Send private message
Drugwash



Joined: 07 Sep 2008
Posts: 921
Location: Ploiesti, RO

PostPosted: Mon May 11, 2009 1:54 pm    Post subject: Reply with quote

Great library and great wrapper! Cool

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:
Code:
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:
Code:
   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! Wink
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Thrawn



Joined: 12 May 2008
Posts: 30
Location: Germany

PostPosted: Mon May 11, 2009 5:15 pm    Post subject: Reply with quote

Thanks Drugwash.
I've implemented your improvements.
Back to top
View user's profile Send private message
..:: Free Radical ::..



Joined: 20 Sep 2006
Posts: 72

PostPosted: Tue May 12, 2009 3:57 am    Post subject: Reply with quote

Thank you very much for this Very Happy
Would try making a front end for my work
Back to top
View user's profile Send private message
Thrawn



Joined: 12 May 2008
Posts: 30
Location: Germany

PostPosted: Tue May 12, 2009 9:44 am    Post subject: Reply with quote

Drugwash wrote:
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. Rolling Eyes
So, if you take out the resizing part and let it handle png images separately with HPDF_LoadPNGImageFromFile() it uses libpng13.dll.
Back to top
View user's profile Send private message
Drugwash



Joined: 07 Sep 2008
Posts: 921
Location: Ploiesti, RO

PostPosted: Tue May 12, 2009 4:08 pm    Post subject: Reply with quote

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. Crying or Very sad

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... Question

<->
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Thrawn



Joined: 12 May 2008
Posts: 30
Location: Germany

PostPosted: Thu May 14, 2009 4:19 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Drugwash



Joined: 07 Sep 2008
Posts: 921
Location: Ploiesti, RO

PostPosted: Thu May 14, 2009 7:21 pm    Post subject: Reply with quote

It gets corrupted right after GDIplus conversion. Guess I gotta find a version that works.. if there's any. Sad
Thanks for the suggestion, got me closer to the (bitter) truth.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Thrawn



Joined: 12 May 2008
Posts: 30
Location: Germany

PostPosted: Mon May 18, 2009 9:34 pm    Post subject: Reply with quote

as a workaround you could use this (ImageMagick Wrapper) to convert the png to jpeg, although it would bloat the example with additional dlls.
Back to top
View user's profile Send private message
Drugwash



Joined: 07 Sep 2008
Posts: 921
Location: Ploiesti, RO

PostPosted: Mon May 18, 2009 10:12 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
gwarble



Joined: 23 May 2009
Posts: 224
Location: north bay, california

PostPosted: Thu Aug 27, 2009 6:53 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
..:: Free Radical ::..



Joined: 20 Sep 2006
Posts: 72

PostPosted: Sat Apr 10, 2010 11:29 pm    Post subject: HPDF_LoadPngImageFromFile works fine for me Reply with quote

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.
Back to top
View user's profile Send private message
Cyrille
Guest





PostPosted: Mon Aug 23, 2010 9:56 pm    Post subject: LibHaru - PDF : Problem with accented characters Reply with quote

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.
Back to top
Guest4
Guest





PostPosted: Tue Apr 05, 2011 10:24 am    Post subject: LibHaru - PDF : Windows binaries Reply with quote

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
Back to top
Thrawn



Joined: 12 May 2008
Posts: 30
Location: Germany

PostPosted: Tue Apr 05, 2011 6:07 pm    Post subject: Re: LibHaru - PDF : Windows binaries Reply with quote

Guest4 wrote:
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

http://thrawn.einfachonline.net/download/libharu_2.1.0-vc8-dlls.zip
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group