⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jpntest.c

📁 读写pdf格式文件的多平台C语言工具库
💻 C
字号:
/* jpntest.c -- test program for Japanese language support. * Copyright (C) 1999 FastIO Systems, All Rights Reserved. * For conditions of use, license, and distribution, see LICENSE.pdf * included in the distribution or http://www.fastio.com/LICENSE.pdf------------------------------------------------------------------------------------1999-10-01 [io] Reorganized, and changed default unit to centimeter.1999-09-25 [io] Starting with Japanese, and then Korean.cc -Wall -o jpntest -I/usr/local/include jpntest.c -lcpdfpm*/#include <stdio.h>#include <stdlib.h>#include <cpdflib.h>/* 90ms-RKSJ-H (Shift-JIS) text */char *sjis_text[] = {"ClibPDF傪偁側偨偺僾儘僌儔儉偵慻傒崬傓偙偲偵傛傝丄","傾僪價丒僔僗僥儉僘偺傾僋儘僶僢僩摍偵傛傞庤嶌嬈","柍偟偱俹俢俥僼傽僀儖傪帺摦揑偵嶌惉偡傞偙偲偑偱偒傑偡丅","僂僄僽丒僒乕僶忋偱儐乕僓偐傜偺擖椡丄僒乕僶僒僀僪偱偺","僨乕僞儀乕僗丒傾僋僙僗偵傛偭偰丄堦掕偺彂幃偺彂椶傪","戝検偵俹俢俥僼傽僀儖偲偟偰嶌傞傛偆側梡搑偵嵟揔偱偡丅",NULL};char *sjis_english[] = {"By linking ClibPDF into your program,","It is possible to generate PDF files automatically","without manually operating Adobe Systems' Acrobat software","and other related plug-ins.  It is suitable for generating","a large number of documents of a given format based on user","input from Web browsers and server-side data from databases.",NULL};int do_Paragraph(CPDFdoc *pdf, float *x, float *y, float ybump, int alignmode, float fontsize,			const char *font, const char *encoding, const char *paragraph[]);int main(int argc, char *argv[]){CPDFdoc *pdf;float fontsize = 12.0;	/* in points */float x = 2.5;float y = 27.0;		/* in centimeters */int alignmode = TEXTPOS_LL;float ybump = 0.5;	/* in cm */    /* == Initialization == */    pdf = cpdf_open(0, NULL);    cpdf_enableCompression(pdf, YES);		/* use Flate/Zlib compression */    cpdf_init(pdf);    cpdf_setDefaultDomainUnit(pdf, POINTSPERCM);	/* change default unit to cm */    cpdf_pageInit(pdf, 1, PORTRAIT, A4, A4);	/* orientation and size. It's A4 in Japan */    /* Try 5 different font variations out of 2 base fonts: HeiseiKakuGo-W5 and HeiseiMin-W3. */    do_Paragraph(pdf, &x, &y, ybump, alignmode, fontsize,			"HeiseiKakuGo-W5", "90ms-RKSJ-H", sjis_text);    do_Paragraph(pdf, &x, &y, ybump, alignmode, fontsize,			"HeiseiKakuGo-W5,Italic", "90ms-RKSJ-H", sjis_text);    do_Paragraph(pdf, &x, &y, ybump, alignmode, fontsize,			"HeiseiMin-W3", "90ms-RKSJ-H", sjis_text);    do_Paragraph(pdf, &x, &y, ybump, alignmode, fontsize,			"HeiseiMin-W3,Bold", "90ms-RKSJ-H", sjis_text);    do_Paragraph(pdf, &x, &y, ybump, alignmode, fontsize,			"HeiseiMin-W3,BoldItalic", "90ms-RKSJ-H", sjis_text);    /* Now, do English translation. */    do_Paragraph(pdf, &x, &y, ybump, alignmode, fontsize,			"Helvetica", "WinAnsiEncoding", sjis_english);    cpdf_finalizeAll(pdf);			/* PDF file/memstream is actually written here */    cpdf_savePDFmemoryStreamToFile(pdf, "jpntest.pdf");    cpdf_launchPreview(pdf);		/* launch Acrobat/PDF viewer on the output file */    /* == Clean up == */    cpdf_close(pdf);			/* shut down */    return 0;}int do_Paragraph(CPDFdoc *pdf, float *x, float *y, float ybump, int alignmode, float fontsize,			const char *font, const char *encoding, const char *paragraph[]){int i;char buff[1024];    *y -= ybump;    cpdf_beginText(pdf, 0);    cpdf_setFont(pdf, "Times-Italic", "WinAnsiEncoding", 10.0);    sprintf(buff, "[Font: %s      Encoding (CMap): %s ]", font, encoding);    cpdf_textAligned(pdf, *x, *y, 0.0, alignmode, buff);    *y -= ybump;    cpdf_setFont(pdf, font, encoding, fontsize);    for(i = 0; paragraph[i] != NULL; i++) {	cpdf_textAligned(pdf, *x, *y, 0.0, alignmode, paragraph[i]);	*y -= ybump;    }    cpdf_endText(pdf);    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -