准备
linux系统,libharu库,libgtk库。
代码展示
#include <png.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include "hpdf.h"
#include <zlib.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <gtk/gtk.h>
#define HEADLINESIZE 45
#define HEADLINEPOSX 225
#define HEADLINEPOSY (1300-100)
#define OTHERSIZE 20
#define OTHERX 20 //距离pdf页左边位置
#define FIRSTY (1300-175)
#define SECONDY (1300-185)
#define THIRDY (1300-215)
#define FORTHY (1300-255)
#define FIFTHY (1300-265)
#define SIXTHY (245)
#define SEVENTHY (195)
#define EIGHTHY 185
#define LASTY 160
#define PICSH (1300-1000)
#define PICFH (1300-635)//第一行图片纵坐标
char filename3[50][255];//读取目标目录文件名存放
int j=0;
char filename4[50][255];//读取源目录文件名存放
int pngnum=0,n=0;
int x=0,b=0,pstn=1;
#ifndef HPDF_NOPNGLIB
jmp_buf env;
#ifdef HPDF_DLL
void __stdcall
#else
void
#endif
//关于PDF操作的错误处理
error_handler (HPDF_STATUS error_no,
HPDF_STATUS detail_no,
void *user_data)
{
printf ("ERROR: error_no=%04X, detail_no=%u\n", (HPDF_UINT)error_no,
(HPDF_UINT)detail_no);
longjmp(env, 1);
}
//读取目的目录文件
void printdir(char *dir)
{
int i=0;
DIR *dp;
struct dirent *entry;
if((dp =opendir(dir)) ==NULL)//打开目录,错误就报错
{
fprintf(stderr,"cannot open directory: %s\n",dir);
return;
}
chdir(dir);//进入目录
//读取目录下的文件,将名字保存至filename3
while