GithubHelp home page GithubHelp logo

libharu / libharu Goto Github PK

View Code? Open in Web Editor NEW
1.7K 1.7K 506.0 28.31 MB

libharu - free PDF library

Home Page: http://libharu.org

License: zlib License

CMake 0.30% Makefile 0.19% Shell 0.05% C 81.54% C# 2.68% Pascal 1.90% Python 6.59% Ruby 0.77% FreeBasic 1.36% Visual Basic .NET 2.77% Batchfile 0.01% Visual Basic 6.0 1.86%

libharu's Introduction

Haru Free PDF Library Build Status

URL http://libharu.org/

Copyright 2000-2006 (c) Takeshi Kanno

Copyright 2007-2009 (c) Antony Dovgal et al.

See INSTALL for instructions on how to install libHaru.

What is Haru Free PDF Library?

Haru is a free, cross platform, open-sourced software library for generating PDF. It supports the following features.

  1. Generating PDF files with lines, text, images.
  2. Outline, text annotation, link annotation.
  3. Compressing document with deflate-decode.
  4. Embedding PNG, Jpeg images.
  5. Embedding Type1 font and TrueType font.
  6. Creating encrypted PDF files.
  7. Using various character set (ISO8859-116, MSCP12508, KOI8-R).
  8. Supporting CJK fonts and encodings.

You can add the feature of PDF creation by using Haru without understanding complicated internal structure of PDF.

The differences from the previous version

The biggest differences are that all code is written in C. To our regret, because internal structures changed greatly, The API is not compatible with previous version.

However, the new-version has the following advantages compared with the previous version.

  1. Supported shared-library build. A new-version library is able to be built as shared-library.
  2. The performance has been greatly improved. A new-version library is about 4-15 times faster than a previous version.
  3. Supported more features. TrueType font, 128 bit encryption, arc function, and so on.

Supporting platforms

Haru is written in ANSI-C and should compile easily with any compliant C compiler. I inspected Haru in the following environment and make files for these environments are included in a package.

  1. Cygwin + GCC (Microsoft Windows)
  2. Cygwin + MinGW (Microsoft Windows)
  3. MSYS + MinGW (Microsoft Windows)
  4. Microsoft VC++ (Microsoft Windows)
  5. Borland C++ (Microsoft Windows)
  6. GCC (Linux, FreeBSD, NetBSD, Solaris...)

Also on platforms except the above, it is easy to build HARU. If you success to build HARU on other platforms, please send makefile to me. In addition, ZLIB and PNGLIB are required when you want to use the features of compression and embedding PNG images. (In the case of Windows, static library files for several compilers are included in the package for WIndows. In the case of most of UNIX, these libraries are usually installed.)

Available development environment

Haru can work as both static-library (.a, .lib) and shared-library (.so, .dll). When you use it as static-library, It can be used by C and a C++. But when you use it as shared-library, it can be used by many development languages which support shared library. So far, Haru provides bindings for Ruby, Delphi/Free Pascal and C#.

If you write bindings for other programming languages, please notice me!

Runtime environment of programs using Haru

  1. static-library No runtime files are required.

  2. shared-library In Windows, you have to distribute libhpdf.dll with a program. In UNIX you have to distribute libhpdf.so* with a program.

NOTE: In the UNIX environment, there are the cases that libz.so, libpng.so.x are necessary. About this, please refer to the documentation of PNGLIB and ZLIB.

License

Haru is distributed under the ZLIB/LIBPNG License. Because ZLIB/LIBPNG License is one of the freest licenses, You can use Haru for various purposes.

The license of Haru is as follows.

Copyright (C) 1999-2006 Takeshi Kanno Copyright (C) 2007-2009 Antony Dovgal

This software is provided 'as-is', without any express or implied warranty.

In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

Acknowledgment

  1. Information-technology Promotion Agency(IPA) The development of Haru has been supported by Exploratory Software Project of Information-technology Promotion Agency(IPA), Japan.

  2. All users of libHaru. We wish to thank all users of Haru. In particular, we thank Thomas Nimstad, LeslieM, Par Hogberg, adenelson, Riccardo Cohen, sea_sbs, Andrew. They gave me very useful advices.

  3. Adobe Systems Inc. We thank Adobe Systems Inc. for publishing PDF specification.

libharu's People

Contributors

apple-x-co avatar bramton avatar bvirlet avatar chenrui333 avatar confusedsushi avatar dmitrys99 avatar domfe avatar finnar avatar frankxie05 avatar gahr avatar gix avatar inarvaev avatar joelhecht avatar jschueller avatar kdeforche avatar kubivan avatar lrcg avatar lsbts1291 avatar luzpaz avatar mklemarczyk avatar mvastola avatar nwatkiss avatar orouge avatar paulharris avatar qtamaki avatar simon-swenson-8351 avatar tgotic avatar tony2001 avatar vincent-d avatar vszakats avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libharu's Issues

compilation with PNG leads to erroneous code

libharu 2.3.0RC2
OS: dragonflyBSD

configure OK
make OK
ldd says:
/usr/local/lib/libhpdf.so:
libz.so.3 => /usr/lib/libz.so.3 (0x800e20000)
libpng16.so.16 => /usr/pkg/lib/libpng16.so.16 (0x801034000)
libc.so.7 => /usr/lib/libc.so.7 (0x80081d000)
libm.so.3 => /usr/lib/libm.so.3 (0x801276000)

BUT

HPDF_LoadPngImageFromFile() says:
0x1062 "unsupported function"

Compile error in libharu

I am using bcc32 and have been able to compile and link libhpdf.dll
However, when I try to run the makefile with the "demo" switch, I get an error:

Error E2303 include\hpdf.h 464: Type name expected

File hpdf.h:
459 HPDF_EXPORT(HPDF_XObject)
460 HPDF_Page_CreateXObjectFromImage (HPDF_Doc pdf,
461 HPDF_Page page,
462 HPDF_Rect rect,
463 HPDF_Image image,
464 HPDF_Boolean zoom);

HPDF_Boolean is defined in hpdf_objects.h as a pointer to a structure:

typedef struct _HPDF_Boolean_Rec *HPDF_Boolean;

typedef struct _HPDF_Boolean_Rec {
HPDF_Obj_Header header;
HPDF_BOOL value;
} HPDF_Boolean_Rec;

What is wrong here?

Some gcc compiler errors

Used version of libharu/libpdf: 2.3.0RC2
gcc 4.7.1
compilation flags: -Wall -Wstrict-aliasing=2 -Werror -O3

I usually use a bleeding edge distro (ArchLinux in this case) and new compilers with paranoic flags to discover
bugs early.

I got:

hpdf_encrypt.c: In function ‘HPDF_MD5Update’:
hpdf_encrypt.c:107:9: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
hpdf_encrypt.c:116:9: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
hpdf_encrypt.c: In function ‘HPDF_MD5Final’:
hpdf_encrypt.c:154:9: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
hpdf_encrypt.c:165:5: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
hpdf_encrypt.c:166:5: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
hpdf_encrypt.c:168:5: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
cc1: all warnings being treated as errors

Hotfix in include/pdf_types.h (this only tames the compiler errors, the root problem persists):

ifdef GNUC

define MAY_ALIAS attribute((may_alias))

else

define MAY_ALIAS

endif

typedef signed int HPDF_INT32;
typedef unsigned int MAY_ALIAS HPDF_UINT32;

hpdf_font_cid.c:644:19: error: variable ‘last_btype’ set but not used [-Werror=unused-but-set-variable]

added to hpdf_font_cid.c:

ifndef HPDF_UNUSED

define HPDF_UNUSED(a) ((void)(a))

endif

and

HPDF_UNUSED( last_btype );

in function 'MeasureText'.

hpdf_image_png.c: In function ‘LoadPngData’:
hpdf_image_png.c:303:27: error: ‘row’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
hpdf_image_png.c:243:22: note: ‘row’ was declared here

Not sure, if initializing row to 0 is the right thing to do?

hpdf_u3d.c:165:24: error: ‘type’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

This is a rather annoying one, as the code is pretty ok. Dummy initialization of '*type = NULL' in Get3DStreamType
silences the warning.

Count used lines in HPDF_Page_TextRect()

Hi,

I'm planning to modify the 'HPDF_Page_TextRect' function so it would count the used lines to print the entire text, and multiply that value with the textheight+linespacing to calculate the bottom value.
This should allow a program to print a variable text length and draw a box/border around it.

But i can't seem to figure out how to HPDF_Box uses the bottom-value.
Any help or pointers on this matter are highly appreciated!

With kind Regards,
DeJakke.

Invalid PDF when using HPDF_Image_LoadRawImageFromMem with 1bpp images

When using HPDF_Image_LoadRawImageFromMem with a 1bpp image, the resulting PDF is corrupted and cannot be opened by Acrobat Reader (other readers like Foxit are able to open it, but some image data is missing).

The issue is due to an error when computing the data size from the image dimensions on line 361 of hpdf_image.c: this line should be:

size = ((width * bits_per_component + 7) / 8) * height;

(And a similar change should be made on lines 365 and 370).

alpha mask of embedded png's is not compressed

here is a patch to fix it:

diff --git a/src/hpdf_doc_png.c b/src/hpdf_doc_png.c
index bad87c6..f1daf26 100644
--- a/src/hpdf_doc_png.c
+++ b/src/hpdf_doc_png.c
@@ -155,15 +155,21 @@ LoadPngImageFromStream (HPDF_Doc pdf,
HPDF_BOOL delayed_loading)
{
HPDF_Image image;

  • HPDF_Dict smask;

HPDF_PTRACE ((" HPDF_LoadPngImageFromStream\n"));

image = HPDF_Image_LoadPngImage (pdf->mmgr, imagedata, pdf->xref,
delayed_loading);

  • if (image && (pdf->compression_mode & HPDF_COMP_IMAGE))
  • if (image && (pdf->compression_mode & HPDF_COMP_IMAGE)) {
    image->filter = HPDF_STREAM_FILTER_FLATE_DECODE;
  •   // is there an alpha layer? then compress it also
    
  •   smask = HPDF_Dict_GetItem(image, "SMask", HPDF_OCLASS_DICT);
    
  •   if (smask) smask->filter = HPDF_STREAM_FILTER_FLATE_DECODE;
    
  • }

return image;
}

How do I start using Haru library?

I would like to create pdf file using C.
I installed haru library as per the installation step.

But I could not able to build sample code in Ubuntu12.04.
I use command to run sample code is ,

gcc-o result.o test_code.c

I found following error,
/tmp/ccCzocHH.o: In function main': test_code.c:(.text+0xbf): undefined reference toHPDF_New'
test_code.c:(.text+0xfc): undefined reference to HPDF_Free' test_code.c:(.text+0x112): undefined reference toHPDF_AddPage'
test_code.c:(.text+0x122): undefined reference to HPDF_Page_GetHeight' test_code.c:(.text+0x132): undefined reference toHPDF_Page_GetWidth'
test_code.c:(.text+0x14b): undefined reference to HPDF_Page_SetLineWidth' test_code.c:(.text+0x18b): undefined reference toHPDF_Page_Rectangle'
test_code.c:(.text+0x197): undefined reference to HPDF_Page_Stroke' test_code.c:(.text+0x1b3): undefined reference toHPDF_GetFont'
test_code.c:(.text+0x1d4): undefined reference to HPDF_Page_SetFontAndSize' test_code.c:(.text+0x1e8): undefined reference toHPDF_Page_TextWidth'
test_code.c:(.text+0x1f8): undefined reference to HPDF_Page_BeginText' test_code.c:(.text+0x232): undefined reference toHPDF_Page_TextOut'
test_code.c:(.text+0x23e): undefined reference to HPDF_Page_EndText' test_code.c:(.text+0x24a): undefined reference toHPDF_Page_BeginText'
test_code.c:(.text+0x267): undefined reference to HPDF_Page_SetFontAndSize' test_code.c:(.text+0x294): undefined reference toHPDF_Page_TextOut'
test_code.c:(.text+0x2a0): undefined reference to HPDF_Page_EndText' test_code.c:(.text+0x2ac): undefined reference toHPDF_Page_BeginText'
test_code.c:(.text+0x2d1): undefined reference to HPDF_Page_MoveTextPos' test_code.c:(.text+0x309): undefined reference toHPDF_GetFont'
test_code.c:(.text+0x32a): undefined reference to HPDF_Page_SetFontAndSize' test_code.c:(.text+0x345): undefined reference toHPDF_Page_ShowText'
test_code.c:(.text+0x363): undefined reference to HPDF_Page_MoveTextPos' test_code.c:(.text+0x380): undefined reference toHPDF_Page_SetFontAndSize'
test_code.c:(.text+0x394): undefined reference to HPDF_Page_ShowText' test_code.c:(.text+0x3b2): undefined reference toHPDF_Page_MoveTextPos'
test_code.c:(.text+0x3d6): undefined reference to HPDF_Page_EndText' test_code.c:(.text+0x3ea): undefined reference toHPDF_SaveToFile'
test_code.c:(.text+0x3f6): undefined reference to `HPDF_Free'
collect2: ld returned 1 exit status

can anybody help me?

CMake outputs libhpdfs.a instead of libhpdf.a

I am not sure this was on purpose or not but it would be nice to have the libraries name be consistent between the shared and static libraries.

This can be fixed by adding the following line to your src/CMakeLists.txt:
set_target_properties(${LIBHPDF_NAME_STATIC} PROPERTIES OUTPUT_NAME ${LIBHPDF_NAME})

This would go after the line:
add_library(${LIBHPDF_NAME_STATIC} STATIC ${LIBHPDF_SRCS})

Crash in HPDF_AttachFile()

(gdb) bt
#0  0x00007ffff4903d37 in HPDF_String_Cmp (s1=0x65c5a0, s2=0x0) at hpdf_string.c:199
#1  0x00007ffff48f51e1 in HPDF_NameTree_Add (tree=0x660e40, name=0x65c5a0, obj=0x65bb50) at hpdf_namedict.c:154
#2  0x00007ffff48dba01 in HPDF_AttachFile (pdf=0x651010, file=0x6552b8 "./attach.bin") at hpdf_doc.c:1970
#3  0x000000000040191b in main (argc=<optimized out>, argv=<optimized out>) at testharu.cpp:101
(gdb) p s1
$1 = (HPDF_String) 0x65c5a0
(gdb) p s2
$2 = (HPDF_String) 0x0
(gdb) f 1
#1  0x00007ffff48f51e1 in HPDF_NameTree_Add (tree=0x660e40, name=0x65c5a0, obj=0x65bb50) at hpdf_namedict.c:154
154             if (i == 0 || HPDF_String_Cmp(name, elem) < 0) {
(gdb) p elem
$3 = (HPDF_String) 0x0
(gdb) f 2
#2  0x00007ffff48dba01 in HPDF_AttachFile (pdf=0x651010, file=0x6552b8 "./attach.bin") at hpdf_doc.c:1970
1970        ret += HPDF_NameTree_Add (ntree, name, efile);
(gdb) p ntree
$4 = (HPDF_NameTree) 0x660e40
(gdb) p name
$5 = (HPDF_String) 0x65c5a0
(gdb) p efile
$6 = (HPDF_EmbeddedFile) 0x65bb50

Apparently in the following code, elem can end up being NULL:

116 HPDF_STATUS
117 HPDF_NameTree_Add  (HPDF_NameTree  tree,
118                     HPDF_String    name,
119                     void          *obj)
120 {
121     HPDF_Array items;
122     HPDF_INT32 i, icount;
123 
124     if (!tree || !name)
125         return HPDF_INVALID_PARAMETER;
126 
127     items = HPDF_Dict_GetItem (tree, "Names", HPDF_OCLASS_ARRAY);
128     if (!items)
129         return HPDF_INVALID_OBJECT;
130 
131     /* "The keys shall be sorted in lexical order" -- 7.9.6, Name Trees.
132      * Since we store keys sorted, it's best to do a linear insertion sort
133      * Find the first element larger than 'key', and insert 'key' and then
134      * 'obj' into the items. */
135 
136     icount = HPDF_Array_Items(items);
137 
138     /* If we're larger than the last element, append */
139     if (icount) {
140         HPDF_String last = HPDF_Array_GetItem(items, icount - 2, HPDF_OCLASS_STRING);
141 
142         if (HPDF_String_Cmp(name, last) > 0) {
143             HPDF_Array_Add(items, name);
144             HPDF_Array_Add(items, obj);
145             return HPDF_OK;
146         }
147     }
148 
149     /* Walk backwards through the list until we're smaller than an element=
150      * That's the element to insert in front of. */
151     for (i = icount - 4; i >= 0; i -= 2) {
152         HPDF_String elem = HPDF_Array_GetItem(items, i, HPDF_OCLASS_STRING);
153 
154         if (i == 0 || HPDF_String_Cmp(name, elem) < 0) {
155             HPDF_Array_Insert(items, elem, name);
156             HPDF_Array_Insert(items, elem, obj);
157             return HPDF_OK;
158         }
159     }
160 
161     /* Items list is empty */
162     HPDF_Array_Add(items, name);
163     HPDF_Array_Add(items, obj);
164     return HPDF_OK;
165 }

Steps to reproduce:

  1. Download and unpack this archive: http://we.tl/t11RTIKNcZ
  2. Modify the attach.c libharu test to say this (instead of whatever it's attaching):
    HPDF_AttachFile (pdf, "./att/part0.bin");
    HPDF_AttachFile (pdf, "./att/part1.bin");
    HPDF_AttachFile (pdf, "./att/old_err.pdf");
    HPDF_AttachFile (pdf, "./att/10.jpg");
    HPDF_AttachFile (pdf, "./att/part2.bin");

The content itself seems to be irrelevant: I've zeroed the files size and the issue persists, so it has to be name-related. Also, changing the order (for example, putting old_err.pdf first) seems to take care of the crash, but the attachments are nowhere to be seen in Acrobat Reader's attachments list.

Real embedding of TrueType fonts

Hi.
I'm using HPDF_LoadTTFontFromFile with embedding=HPDF_TRUE. I noticed that Libharu embeds all the glyph data (used and used) in the resulting pdf file. I think it should embed only those portion of the TrueType font that are need for the generation of the document and not only mark them with a width of 0 in the font dictionary.

Installation problems

Hi, I downloaded the tar.gz file from http://libharu.org/. When looking for a "configure" file, there's none. I tried buildconf.sh and think I got a good one, however, I now can't find a Makefile...

I was following the "configure && make && make install" instructions.

Thank you.
By the way, I'm on linux/gcc

Add support for cmap platform 0, encoding 3, format 4 (Mac OSX)

Under Mac OSX a lot of fonts have only the cmap platform 0, encoding 3, format 4 (unicode platform, unicode encoding) and not the platform 0, encoding 3, format 4. Since the format 4 is already know, could we load this cmap as the one for platform 1 (windows platform, unicode encoding)?
I did some tests, and it seem to work, but I'm don't know the differences between the two encodings. Just a couple of fonts (i.e. Chalkduster), that doesn't have the table 'cvt ' doesn't work.

--- hpdf_fontdef_tt.c (5622)
+++ hpdf_fontdef_tt.c (5623)
@@ -874,6 +874,7 @@
     HPDF_UINT16 num_cmap;
     HPDF_UINT i;
     HPDF_UINT32 ms_unicode_encoding_offset = 0;
+    HPDF_UINT32 up_unicode_encoding_offset = 0;
     HPDF_UINT32 byte_encoding_offset = 0;

     HPDF_PTRACE ((" HPDF_TTFontDef_ParseCMap\n"));
@@ -936,6 +937,10 @@
         if (platformID == 1 && encodingID ==0 && format == 1)
             byte_encoding_offset = offset;

+        /* Unicode-Unicode-CMAP will be used if MS-Unicode-CMAP is not found */
+        if (platformID == 0 && encodingID ==3 && format == 4)
+            up_unicode_encoding_offset = offset;
+
         ret = HPDF_Stream_Seek (attr->stream, save_offset, HPDF_SEEK_SET);
         if (ret != HPDF_OK)
            return ret;
@@ -948,6 +953,9 @@
     } else if (byte_encoding_offset != 0) {
         HPDF_PTRACE((" found byte encoding cmap.\n"));
         ret = ParseCMAP_format0(fontdef, byte_encoding_offset + tbl->offset);
+    } else if (up_unicode_encoding_offset != 0) {
+        HPDF_PTRACE((" found unicode platform unicode encoding cmap.\n"));
+        ret = ParseCMAP_format4(fontdef, up_unicode_encoding_offset + tbl->offset);
     } else {
         HPDF_PTRACE((" cannot found target cmap.\n"));
         return HPDF_SetError (fontdef->error, HPDF_TTF_INVALID_FOMAT, 0);

Add flags for vertical alignment of text in rectangles.

Currently, HPDF_TextAlignment has LEFT, RIGHT, CENTER and JUSTIFY options. Would be nice to have TOP, BOTTOM and MIDDLE as well.

Commit 256dfd3 has the necessary changes.

Changed HPDF_Page_TextRect to support multiple flags. For example, to place text in the center-middle of a rectangle, HPDF_TALIGN_CENTER | HPDF_TALIGN_MIDDLE can be passed to HPDF_Page_TextRect.

dash pattern and dash phase, real numbers?

Hi.
I think the function HPDF_Page_SetDash is wrong. In PDF documents, the elements of the dash pattern array can be real numbers.
The dash phase can be a real number also. Maybe the libharu function must be changed to operate correctly.

Regards,
Dome

PHP Haru extension

When will you release next version of libharu that will support UTF-8?

I need UTF-8 in my php application, because all content is multilingual. Will you release new extension for PHP? LibHaru is great alternative for paid PDF library for PHP.

Fedora 17 Install Fails

Tried installing verions 2.2.0 and 2.2.1 from source to Fedora server. In both cases, errors:

hpdf_image_png.c: In function âReadPngData_Interlacedâ:
...
hpdf_image_png.c:138:44: error: dereferencing pointer to incomplete type
hpdf_image_png.c: In function âReadPngDataâ:
hpdf_image_png.c:159:44: error: dereferencing pointer to incomplete type
hpdf_image_png.c: In function âReadTransparentPaletteDataâ:
...
hpdf_image_png.c:215:61: error: dereferencing pointer to incomplete type
hpdf_image_png.c:222:37: error: dereferencing pointer to incomplete type
hpdf_image_png.c: In function âReadTransparentPngDataâ:
...
hpdf_image_png.c:291:29: error: dereferencing pointer to incomplete type
hpdf_image_png.c:294:25: error: dereferencing pointer to incomplete type
hpdf_image_png.c:309:37: error: dereferencing pointer to incomplete type
hpdf_image_png.c: In function âLoadPngDataâ:
...
hpdf_image_png.c:629:24: error: dereferencing pointer to incomplete type
make[1]: *** [hpdf_image_png.lo] Error 1
make[1]: Leaving directory `/etc/libharu-2.2.0/src'
make: *** [all-recursive] Error 1

Where can I get the U3D or U3D+Javascript example?

I found that libharu version 2.3 RC1 has this issue:

Added support for 3dMeasures of subtype PD3 and 3DC, projection annotations, ExData and javascript attached to a U3D model. (Robert Würfel)

I can't find the example of doing this.

Can anyone help me with utilizing u3d and javascript files?

Where can I get the examples of these?

Thank you.

.dll

Do you have a compiled dll? I would like to use this with c# and the .net 3.5, is this supported?

Installation problem

What's this piece of CMake code supposed to do?

install(FILES README CHANGES INSTALL DESTINATION .)
if(NOT DEVPAK)
  install(DIRECTORY if DESTINATION .)
endif(NOT DEVPAK)

for me it installs if directory and documentation into ${PREFIX}, (e.g. /usr/{README,CHANGES,INSTALL,if), I really doubt that is indented behavior.

Invalid binary images when compression is disabled.

Steps to reproduce:

  • Create a new PDF and set compression to HPDF_COMP_NONE;
  • Add a raw binary image with HPDF_Image_LoadRaw1BitImageFromMem or HPDF_LoadRawImageFromMem (actually, the two are equivalent since the latter calls the former when it is given a binary image);
  • Save the PDF.

Expected results:

A PDF file containing an uncompressed binary image.

Actual result:

A PDF file containing some noise and a large white area. Analysis of this PDF suggests that the image data was compressed with CCITT but that the corresponding /Filter was not set.

Additional information:

Version: 2.3.0

build system not compatible with cross compilation

When trying to include this package in yocto, qa_configure step reports failure if it finds the below string pattern in config.log

grep -e 'CROSS COMPILE Badness:' -e 'is unsafe for cross-compilation'

This issue is applicable for both 2.2.1 and 2.3.0RC2 series. I'll send a pull request shortly

Using 2.2.0, crashing on HPDF_Free() after reading invalid png file

I have a several PNG files that libharu fails to load.

One of them (crash.png) causes a crash.
After calling

...
HPDF_Image image = HPDF_LoadPngImageFromFile(pdf, filepath);

if(image == 0)
{
HPDF_Free(pdf); // crash here!!!
}

...

The other two files (fail_to_load1.png, fail_to_load2.png) do not crash when 'HPDF_Free()' is call.

p.s I have no problem opening and seeing these three files using image viewer applications, or Photoshop.

--- crash1.png---
crash

--- fail_to_load1.png---
fail_to_load1

--- fail_to_load2.png---
fail_to_load2

Bug in HPDF_Info_SetInfoDateAttr()

I've noticed a potential bug in the HPDF_Info_SetInfoDateAttr().

According to the documentation, if the ind member of HPDF_Date is ' ' the members off_hour and off_minutes are ignored. However, according to the actual code, as seen in the code below, in hpdf_info.c (lines 109 - 119), this is not really so.

if (value.month < 1 || 12 < value.month ||
    value.day < 1 ||
    23 < value.hour ||
    59 < value.minutes ||
    59 < value.seconds ||
    (value.ind != '+' && value.ind != '-' && value.ind != 'Z' &&
            value.ind != ' ') ||
    23 < value.off_hour ||
    59 < value.off_minutes) {
    return HPDF_SetError (info->error, HPDF_INVALID_DATE_TIME, 0);
}

A close look reveals that AS LONG AS either value.off_hour is NOT less than 23 or value.off_minutes is NOT less than 59, HPDF_INVALID_DATE_TIME will be returned.

The bug was found in a Release Build of a project that uses the libharu library because in Release mode the members off_hour and off_minutes, when uninitialized, carry an arbitrary large positive value.

In debug builds the issue was never seen because the members, when uninitialized, carry an arbitrary large negative value.

Which also brings up another issue: the code section does not check for invalid negative values.

Below is a suggested fix:

if (value.month < 1 || 12 < value.month ||
    value.day < 1 ||
    23 < value.hour ||
    59 < value.minutes ||
    59 < value.seconds ||
    (value.ind != '+' && value.ind != '-' && value.ind != 'Z' &&
            value.ind != ' ') ||
    (23 < value.off_hour && value.ind != ' ') ||
    (59 < value.off_minutes && value.ind != ' ')
    ) {
    return HPDF_SetError (info->error, HPDF_INVALID_DATE_TIME, 0);
}

The issue can be avoided in code that calls HPDF_Info_SetInfoDateAttr() buy initializing the members off_hour and off_minutes to 0 if ind == ' ', which is what I have done in my code. I had not bothered initializing them because I took the documentation literally on the "are ignored" part..

Build libHaru in Windows platforms of false

I make command:
D:\Program Files\Microsoft Visual Studio\VC98\Bin>

nmake -f d:\LibHaru\ClassLibCo
de\libharu-RELEASE_2_2_0\script\Makefile.mingw_dll

Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

NMAKE : fatal error U1073: don't know how to make 'src/hpdf_utils.o'
Stop.

Error in Courier font

Hi

Courier and Courier-Bold fonts don't display C WITH CARON , AND c WITH CARON in WIN1250 encoding.
Other fonts (HELVETICA,TIMES,..) are OK.

Regards,
Franček

Old download link no longer works

My project's makefile downloads a copy of libharu-2.2.1 and builds it if not present in the developer environment (and that includes every clean overnight build on the CI server).

As of midnight on 16 Jan 2013, the link no longer works:

wget http://libharu.org/files/libharu-2.2.1.tar.gz
...
HTTP request sent, awaiting response... 404 Not Found

The tarball URL on the Libharu home page http://libharu.org/ now points to https://github.com/libharu/libharu/tarball/master and this in turn redirects to the current release, libharu-libharu-RELEASE_2_3_0RC2-21-g915f130.tar.gz.

Unfortunately the wget command doesn't appear to be able to handle https URLs. Is there a suitable mirror from which to download this archive?

HPDF_GetFontDef doesn't work with font's real name.

When a font is "Bold" or "Italic" or "BoldItalic", the base_font is assigned with 'font name'+'style name', this causes lots of problems.

for example: font Arial Gras, its unique real name is "Arial-BoldMT", which Adobe's software use it as internal font name. but in here the base_font is "Arial-BoldMT,Bold", why add the subfamily name on it? "Arial-BoldMT" is enough.

I wish you can remove the extra part.

Doesn't support gradient colors

Filling an closed polygon with a gradient color is very common, but this is not supported, I wish you can add this function.

A typo in the HPDF_LineCap enum

Hello.

I have noticed that one of the items in the HPDF_LineCap enum is not correct.
The HPDF_PROJECTING_SCUARE_END item should be HPDF_PROJECTING_SQUARE_END.

Fixing this would break the API so perhaps it is a good idea to do it in a major version release.

Access violation for pictures using PNG_COLOR_MASK_COLOR

For some PNGs "png_get_tRNS" returns num_trans=1 and trans=NULL. In that case an access violation occurs in function ReadTransparentPaletteData becase there is a "<num_trans" check that will be true for 0. hpdf_image_png.c, line 224:
smask_data[width * j + i] = (row_ptr[j][i] < num_trans) ? trans[row_ptr[j][i]] : 0xFF;

I have fixed this by adding following lines after "png_get_tRNS". hpdf_image_png.c, line 491:
if (trans == NULL)
goto no_transparent_color_in_palette;

The reason why the problem happens is because PNG_COLOR_TYPE_PALETTE is defined as (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE). But the code only supports the PNG_COLOR_MASK_PALETTE case but not the PNG_COLOR_MASK_COLOR one.

HPDF_Page_TextRect Special character (German Umlaut) not display properly

I am using libharu for iPad pdf functionality and i want to display german text (specially Umlaut characters) on pdf using HPDF_Page_TextRect. i have tried various combinations in code but not get success to display umlaut characters (üöäÄÜÖß).

If you have any solution for my issue please provide me.

Degree sign '°' (0xB0) is not displayed if font is embedded

There is a bug in the lookup table HPDF_UNICODE_MAP_WIN_ANSI (at position 176). Degree sign is defined as Unicode character 0x02DA which is a "Ring Above" instead a degree sign (0x00B0). It works if you define "CP1252" instead of "WinAnsiEncoding" because there is a table HPDF_UNICODE_MAP_CP1252 that overwrites the degree sign. However the PDF standard defines "WinAnsiEncoding" as "CP1252" therefore HPDF_UNICODE_MAP_CP1252 should not exist at all (see Adobe Document management, Portable document format, Part 1: PDF 1.7).

Problem getting font height

Hello,

I need to restrict the text that can be written in a block. To do so, I use HPDF_Page_MeasureText to get the number of char that can be written in my rect. I also need to find out the height of my text so I can know the number of lines that I will be able to write (number of char * number of lines).

I tried to use HPDF_Font_GetCapHeight but this gave me a huge number (725 or something) , this is for sure not the height of the text I try to print.

To summarise, I know the font, the font size of my text and I need to know the height of it before printing it.

Any pointers ?
Cheers

how to import libharu in eclipse C++

Hi, I know this to be a very noob question but I dont know how to use libharu in my Eclipse C++ and use it in my project. My OS is windows. I downloaded libharu-RELEASE_2_2_0 and dont know where to read further instructions. Thanks in advance

There is no way to read the leading (or equivalently the line gap) of a font

There is a HPDF_Page_SetLeading() which allows setting the leading if using libharu to write whole blocks of text.

Similarly, there is HPDF_Font_GetAscent() and HPDF_Font_GetDescent() to read the maximum vertical extent of a particular font at a particular size.

However, there is no way to obtain the leading or line gap height of a font to know much vertical space to apply between baselines of successive lines of text.

I need this because I am typesetting a Bible with lots of typeface size changes, super-scripts and sub-scripts and the like, and the HPDF_Page_TextRect() doesn't meet my need. For example, I need to work out how much vertical space will be consumed on a page if I include an extra line of text, taking into account the additional cross-reference and foot-note text that will be rendered in a separate area of the page.

The provision of a simple HPDF_Font_GetLeading() or HPDF_Font_GetLineGap() function would meet my need. In the meantime, I may link my application against libfreetype for the sole purpose of obtaining the font leading/line gap information.

Paul.

HPDF_Page_TextRect return HPDF_PAGE_INSUFFICIENT_SPACE

Hi Tony,

I' m getting trouble with HPDF_Page_TextRect based on Chinese text (cp936) if the input Chinese line exceed rectangle width, it return HPDF_PAGE_INSUFFICIENT_SPACE.

  1. demo/mbtext/cp936_t.txt include:

    早上好,多关照。早上好,多关照。早上好,多关照。

  2. Test code based on text_demo2 :

    HPDF_UseCNSEncodings (pdf);
    HPDF_UseCNSFonts (pdf);
    HPDF_Font font = HPDF_GetFont (pdf, "SimSun", "GB-EUC-H");

    HPDF_Rect rect;
    /* HPDF_TALIGN_LEFT */
    rect.left = 25;
    rect.top = 545;
    rect.right = 200;
    rect.bottom = rect.top - 40;

    HPDF_Page_SetCMYKStroke(page,0,1,1,0.07);

    HPDF_Page_Rectangle (page, rect.left, rect.bottom, rect.right - rect.left,
    rect.top - rect.bottom);
    HPDF_Page_Stroke (page);

    HPDF_Page_BeginText (page);
    HPDF_STATUS ret = HPDF_Page_TextRect (page, rect.left, rect.top, rect.right, rect.bottom,
    text, HPDF_TALIGN_LEFT, NULL);
    if (ret != HPDF_OK) printf("Bad return code=%d!\n", ret);

    HPDF_Page_EndText (page);

However, with below input, it worked:

早上好,多关照。早上好,多关照。早上好,多 关照。
                                    ^

Note: ^ denote space between 2 Chinese word.

I didn't see multibyte lang demo of exceeding rectangle width. Within text_demo2, it only demoed English Character.

Have a basic debug, I found this issue came from multibyte calculation issue in hpdf_font_cid.c:

static HPDF_UINT                            
MeasureText  (HPDF_Font          font,      
              const HPDF_BYTE   *text,      
              HPDF_UINT          len,       
              HPDF_REAL          width,     
              HPDF_REAL          font_size, 
              HPDF_REAL          char_space,
              HPDF_REAL          word_space,
              HPDF_BOOL          wordwrap,  
              HPDF_REAL         *real_width)

sorry, I am new to font encoding, pls help look into this issue.

Thanks and Regards
njman

Composite glyphs

Hi there,
thanks for your nice library.

I encountered a small mistake while drawing a composite character, such as сyrillic characters Ё, which consists of a number of nested composite characters.
Recursive call CheckCompositGryph should solve this problem:

CheckCompositGryph

        if (glyph_index > 0 && glyph_index < attr->num_glyphs) {
                HPDF_INT32 pos = HPDF_Stream_Tell(attr->stream);
                if (!attr->glyph_tbl.flgs[glyph_index])
                    CheckCompositGryph (fontdef, glyph_index);
                HPDF_Stream_Seek  (attr->stream, pos, HPDF_SEEK_SET);
                attr->glyph_tbl.flgs[glyph_index] = 1;
          }

Cmake+ demo: can't' find libharu

I've never built libharu on this system, and I suspect that the following line, from demo/CMakeLists.txt, is trying to locate libharu from standard linker search paths (i.e., a previously built/installed version)

  • TARGET_LINK_LIBRARIES( ${demo} libharu )

If this is true, then you might be able to set a CMake variable that points to ${CMAKE_BINARY_DIR}/libharu.[a|so] during the build of the library, and later link directly to that when building the demo.

At any rate, building using CMake without having libharu installed fails to find libharu for linking:

/usr/bin/ld: cannot find -llibharu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.