b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

pdflib_pdflib 表单_acrobat pdf sdk(3)

电脑杂谈  发布时间:2016-11-21 22:05:35  来源:网络整理

可是我们经常并不清楚.ttc里包含哪些字体。在这种情况PDFlib提供了另一种调用方式—索引(Index)。用此方式,首先须给字体文件名一个别名,然后在别名后加冒号再加数字(0表示文件中第一种字体,1 表示第二种,依次类推。)

int Font_E = 0;  /*  Give “C:\WINDOWS\Fonts\MSGOTHIC.TTC an alias “gothic” */   PDF_set_parameter(p, "FontOutline", "gothic=C:\\WINDOWS\\Fonts\\MSGOTHIC.TTC");   Font_E= PDF_load_font(p, "gothic:0", 0, "winansi", ""); /* Use MS Gothic */   Font_E= PDF_load_font(p, "gothic:1", 0, "winansi", ""); /* Use MS PGothic */   Font_E= PDF_load_font(p, "gothic:2", 0, "winansi", ""); /* Use MS UI Gothic */  下面是一个相关的例子--C 源程序/*******************************************************************/  /* This example demostrates the usage of host font and other fonts  /* based on Chinese Simplifed Windows.  /*******************************************************************/    #include <stdio.h>  #include <stdlib.h>  #include <string.h>    #include "pdflib.h"    int main(void)  {      PDF         *p = NULL;      int             i = 0, j = 0, Left = 50, Top = 800;      int             Font_E = 0, Font_CS = 0;      char          fontfile[1024];      char          buf[1024];      char          TextUnicode[] = "\x80\x7B\x53\x4F\x2D\x4E\x87\x65";        /* create a new PDFlib object */      if ((p = PDF_new()) == (PDF *) 0)      {          printf("Couldn't create PDFlib object (out of memory)!\n");          return(2);      }        PDF_TRY(p) {  	if (PDF_begin_document(p, "pdflib_cs2.pdf", 0, "") == -1)                {  	    printf("Error: %s\n", PDF_get_errmsg(p));  	    return(2);  	}    	PDF_set_info(p, "Creator", "pdflib_cs2.c");  	PDF_set_info(p, "Author", "myi@pdflib.com");  	PDF_set_info(p, "Title", "Output Chinese Simplify with host font and others");            /* Start a new page. */          PDF_begin_page_ext(p, a4_width, a4_height, "");          Font_E = PDF_load_font(p, "Helvetica-Bold", 0, "winansi", "");            /* Using host font -- C:\WINDOWS\Fonts\SimHei.ttf.              PDFlib is using BOM UTF8 string to calling multi-byte character string             SimHei.ttf font name is "黑体", its corresponding BOM UTF8 string is              "\xEF\xBB\xBF\xE9\xBB\x91\xE4\xBD\x93" */            Font_CS= PDF_load_font(p, "\xEF\xBB\xBF\xE9\xBB\x91\xE4\xBD\x93", 0, "unicode", "");          /* Font_CS= PDF_load_font(p, "SimHei", 0, "unicode", ""); */  		          PDF_setfont(p, Font_E, 20);          PDF_show_xy(p, "SimHei font:" , Left,  Top);          PDF_setfont(p, Font_CS, 24);          Top-=30;          PDF_show_xy(p, TextUnicode , Left,  Top);            /* Using other disk-based font file that is not installed in system directory --               C:\PSFONTS\CS\gkai00mp.ttf*/          Top-=50;          strcpy(fontfile, "C:\\PSFONTS\\CS\\gkai00mp.ttf");          sprintf(buf, "kai=%s", fontfile);          /* Defines kai as alias for ..\gkai00mp.ttf */          PDF_set_parameter(p, "FontOutline", buf);           Font_CS= PDF_load_font(p, "kai", 0, "unicode", "");          PDF_setfont(p, Font_E, 20);          PDF_show_xy(p, "AR PL KaitiM GB  font:" , Left,  Top);          PDF_setfont(p, Font_CS, 24);          Top-=30;          PDF_show_xy(p, TextUnicode , Left,  Top);            /* Using TrueType collection font with index -- C:\WINDOWS\Fonts\simsun.ttc*/          Top-=50;          strcpy(fontfile, "C:\\WINDOWS\\Fonts\\simsun.ttc");          sprintf(buf, "simsun=%s", fontfile);          /* Defines AdobeSongStd as alias for ..\AdobeSongStd-Light.otf           This only need to claim once will be sufficient to   		configure all fonts in simsun.ttc*/          PDF_set_parameter(p, "FontOutline", buf);           /* TTC files contain multiple separate fonts.          Address 1st font by appending a colon character and 0 after alias simsun */          Font_CS= PDF_load_font(p, "simsun:0", 0, "unicode", "");          PDF_setfont(p, Font_E, 20);          PDF_show_xy(p, "simsun:0 font:", Left, Top);          PDF_setfont(p, Font_CS, 24);          Top-=30;          PDF_show_xy2(p, TextUnicode, 8, Left,  Top);            /*Address 2nd font by appending a colon character and 1 after alias simsun */          Top-=50;          Font_CS= PDF_load_font(p, "simsun:1", 0, "unicode", "");          PDF_setfont(p, Font_E, 20);          PDF_show_xy(p, "simsun:1 font:", Left, Top);          PDF_setfont(p, Font_CS, 24);          Top-=30;          PDF_show_xy2(p, TextUnicode, 8, Left,  Top);            /* End of page. */          PDF_end_page_ext(p, "");          PDF_end_document(p, "");      }        PDF_CATCH(p) {          printf("PDFlib exception occurred in pdflib_cs2 sample:\n");          printf("[%d] %s: %s\n",  	    PDF_get_errnum(p), PDF_get_apiname(p), PDF_get_errmsg(p));          PDF_delete(p);          return(2);      }        PDF_delete(p);      return 0;  }  


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-21423-3.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...