NO

Author Topic: libharu for pdf files  (Read 5742 times)

msciej

  • Guest
libharu for pdf files
« on: October 24, 2016, 09:43:56 PM »
Hi,

Has anyone managed to create a libhpdf lib (libharu.org)?
I've been playing with libharu, libpng and zlib sources for quite a while with no success.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: libharu for pdf files
« Reply #1 on: October 25, 2016, 08:47:38 AM »
What problems you had?
For libpng read least this
« Last Edit: October 25, 2016, 09:25:45 AM by TimoVJL »
May the source be with you

msciej

  • Guest
Re: libharu for pdf files
« Reply #2 on: October 26, 2016, 12:00:26 AM »
You saved me again! Success :) Thank you so much.
libhpdf.lib is there among my other libs, phew! I am too tired to check if it works fine, we'll see.

Perhaps we should have here a seperate forum category, something like "popular libs and dlls".
A place with compiling tutorials, test code etc. This could attract newbies that usually switch to  another IDE whenever they cant get any precompiled stuff.


edit:
So i compiled libhpdf.lib, tested a simple code and what I received when comiling a simple win32 code is:

POLINK: error: Unresolved external symbol '_deflateInit_@16'.
POLINK: error: Unresolved external symbol '_deflate@8'.
POLINK: error: Unresolved external symbol '_deflateEnd@4'.

Looks like zlib's stuff, I played a little with defining ZLIB_WINAPI here and there with no success.

What i did:
1. Downloaded src files: zlib, libpng, libhpdf
2. Compiled zlib lib according to TimoVJL instructions (applied the fix he mentioned) -Ze -Go
3. Compiled libpng lib according to TimoVJL instructions -Ze
4. Compiled libhpdf, I didnt use any scripts, -Ze -Go. I simply grabbed all the c files, all the h files + libharu-libharu-d84867e\win32\include\hpdf_config.h and gave it a go in an empty lib project. According to the website, it can be compiled easily with no tricks.

Simple code:

#include <hpdf.h>
#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
    HPDF_Page page1;
    HPDF_Doc pdf = HPDF_New(NULL, NULL);
   
   
    page1 = HPDF_AddPage(pdf);
   
    HPDF_InsertPage(pdf, page1);
   
    HPDF_SaveToFile(pdf, "pdf1.pdf");
   
    HPDF_Free(pdf);
    return 0;
}

Am I doing something wrong?
« Last Edit: October 26, 2016, 02:09:37 PM by msciej »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: libharu for pdf files
« Reply #3 on: October 26, 2016, 05:51:27 PM »
Just compile zlib and libharu with same calling convention.
Like option -Gd, __cdecl
May the source be with you

msciej

  • Guest
Re: libharu for pdf files
« Reply #4 on: October 26, 2016, 08:02:01 PM »
I thought so, but apparently you need to compile zlib with Gd and libharu with Gz!
I just dont get it, but it works. I will try again on a different machine to make sure the calling conventions have to be actually different for both libs, very odd.

edit:
Sadly, we will never know, haha or maybe someday ;)
I was not able to recreate the steps (libhpdf compilation failed) on my day to day machine, I had a few "invalid combination of opcode and operands" errors.
On my laptop (first try) I have PellesC 7.00.355 on my PC this is 8.00.60
At the end I had zlib-cdecl, libpng-cdecl and missing libhpdf (compilation errors), when I copied libhpdf.lib from my laptop it was still throwing cdecl/stdcall mismatch errors in the test code, so I had to move all 3 libz from my laptop that is a walking virus to my PC.

Final thougths:
1. I got all the 32bit libs that I wanted, they work fine, I can post them here if anyone needs them.
2. Apparently libharu will require some further manual tuning with the libharu src to get compiled with the latest PellesC
3. I have no step by step instruction and I need it for colleagues from work. If I send the files from my PC IT/Security freaks will burn me alive :(

TimoVJL, thank you very much for your support, it would take much longer without your help and I needed the libz badly :)
« Last Edit: October 26, 2016, 10:45:33 PM by msciej »