 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Thrawn
Joined: 12 May 2008 Posts: 29 Location: Germany
|
Posted: Mon May 11, 2009 12:16 pm Post subject: Wrapper for libHaru (creates PDFs) (stdlib) [r1, 2009-05-11] |
|
|
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
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 working
PDFs generated from the examples (zip, 397kb)
Download (lib + examples, zip, 229kb)
Last edited by Thrawn on Wed Jun 03, 2009 2:11 pm; edited 1 time in total |
|
| Back to top |
|
 |
Drugwash
Joined: 08 Sep 2008 Posts: 639 Location: Ploiesti, RO
|
Posted: Mon May 11, 2009 2:54 pm Post subject: |
|
|
Great library and great wrapper!
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!  |
|
| Back to top |
|
 |
Thrawn
Joined: 12 May 2008 Posts: 29 Location: Germany
|
Posted: Mon May 11, 2009 6:15 pm Post subject: |
|
|
Thanks Drugwash.
I've implemented your improvements. |
|
| Back to top |
|
 |
..:: Free Radical ::..
Joined: 20 Sep 2006 Posts: 63
|
Posted: Tue May 12, 2009 4:57 am Post subject: |
|
|
Thank you very much for this
Would try making a front end for my work |
|
| Back to top |
|
 |
Thrawn
Joined: 12 May 2008 Posts: 29 Location: Germany
|
Posted: Tue May 12, 2009 10:44 am Post subject: |
|
|
| 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.
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 |
|
 |
Drugwash
Joined: 08 Sep 2008 Posts: 639 Location: Ploiesti, RO
|
Posted: Tue May 12, 2009 5:08 pm Post subject: |
|
|
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.
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...
<->  |
|
| Back to top |
|
 |
Thrawn
Joined: 12 May 2008 Posts: 29 Location: Germany
|
Posted: Thu May 14, 2009 5:19 pm Post subject: |
|
|
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 |
|
 |
Drugwash
Joined: 08 Sep 2008 Posts: 639 Location: Ploiesti, RO
|
Posted: Thu May 14, 2009 8:21 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Thrawn
Joined: 12 May 2008 Posts: 29 Location: Germany
|
Posted: Mon May 18, 2009 10:34 pm Post subject: |
|
|
| 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 |
|
 |
Drugwash
Joined: 08 Sep 2008 Posts: 639 Location: Ploiesti, RO
|
Posted: Mon May 18, 2009 11:12 pm Post subject: |
|
|
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 |
|
 |
gwarble
Joined: 23 May 2009 Posts: 129 Location: north bay, california
|
Posted: Thu Aug 27, 2009 7:53 am Post subject: |
|
|
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 |
|
 |
..:: Free Radical ::..
Joined: 20 Sep 2006 Posts: 63
|
Posted: Sun Apr 11, 2010 12:29 am Post subject: HPDF_LoadPngImageFromFile works fine for me |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|