注册 登录
编程论坛 VFP论坛

用免费的libhpdf.dll在pdf中输出文字

sam_jiang 发布于 2023-10-21 15:19, 1028 次点击
上次狐友提供的libhpdf.dll库挺强大的,我把c++的输出文字到pdf的源码改成vfp的,在win7+VFP9.0下 运行通过,现在分享给大家。
可惜这个库里很多函数不知道怎么用,慢慢摸索吧。。。
奉上代码:

程序代码:

DO decl
dime font_list[14]
    font_list[1]="Courier"
    font_list[2]="Courier-Bold"
    font_list[3]="Courier-Oblique"
    font_list[4]="Courier-BoldOblique"
    font_list[5]="Helvetica"
    font_list[6]="Helvetica-Bold"
    font_list[7]="Helvetica-Oblique"
    font_list[8]="Helvetica-BoldOblique"
    font_list[9]="Times-Roman"
    font_list[10]="Times-Bold"
    font_list[11]="Times-Italic"
    font_list[12]="Times-BoldItalic"
    font_list[13]="Symbol"
    font_list[14]="ZapfDingbats"


local page_title,hpdf,fname,npage,def_font,ntextwidth,nheight,nwidth,i,samp_text,hfont
page_title= "Font Demo"
hpdf=hpdf_new(0,0)
IF hpdf=0
    RETURN .f.
ENDIF
   
*!* Add a new page object. *!*
npage = HPDF_AddPage (hpdf)
nheight = HPDF_Page_GetHeight(npage)
nwidth = HPDF_Page_GetWidth (npage)

*!*     Print the lines of the page. *!*
HPDF_Page_SetLineWidth (npage, 1)
HPDF_Page_Rectangle(npage, 50, 50, nwidth - 100, nheight - 110)
HPDF_Page_Stroke(npage)

*!* Print the title of the page (with positioning center). */
def_font = HPDF_GetFont (hpdf, "Helvetica", 0)
HPDF_Page_SetFontAndSize (npage, def_font, 24)

ntextwidth = HPDF_Page_TextWidth (npage, page_title)
HPDF_Page_BeginText (npage)
HPDF_Page_TextOut (npage, (nwidth - ntextwidth) / 2, nheight - 50, page_title)
HPDF_Page_EndText (npage)

*!*    /* output subtitle. */
HPDF_Page_BeginText (npage)
HPDF_Page_SetFontAndSize (npage, def_font, 16)
HPDF_Page_TextOut (npage, 60, nheight - 80, "<Standerd Type1 fonts samples>")
HPDF_Page_EndText (npage)

HPDF_Page_BeginText (npage)
HPDF_Page_MoveTextPos (npage, 60, nheight - 105)

FOR i=1 TO aLEN(font_list)
    samp_text="abcdefgABCDEFG12345!#$%&+-@?"
    hfont = HPDF_GetFont(hpdf, font_list[i], 0)
    *!*/* print a label of text */
    HPDF_Page_SetFontAndSize (npage, def_font, 9)
    HPDF_Page_ShowText(npage, font_list[i])
    HPDF_Page_MoveTextPos(npage, 0, -18)

    *!*    /* print a sample text. */
    HPDF_Page_SetFontAndSize(npage, hfont, 20)
    HPDF_Page_ShowText(npage, samp_text)
    HPDF_Page_MoveTextPos(npage, 0, -20)
ENDFOR
HPDF_Page_EndText(npage)
fname=PUTFILE("","pdftest","pdf")
HPDF_SaveToFile (hpdf, fname)
*!*    /* clean up */
HPDF_Free(hpdf)
RETURN .t.


*!*    pdf = HPDF_New(0, 0)
*!*    HPDF_UseCNSFonts(pdf)
*!*    HPDF_UseCNSEncodings(pdf)
*!*    HPDF_SetCompressionMode(pdf, HPDF_COMP_ALL)
*!*    page1 = HPDF_AddPage(pdf)
*!*    lnHandle=HPDF_LoadJpegImageFromFile(pdf, lcFile)
*!*    HPDF_Page_DrawImage(Page1, lnHandle, 0,0,620,878)
*!*    HPDF_SaveToFile (pdf,(dir1)+'\'+afile1+".pdf")
*!*    HPDF_Free(pdf)
*!*    我试了,
*!*    HPDF_Page_DrawImage(Page1, lnHandle, nx,ny,nwidth,nheight) &&nx,ny是以左下角为坐标点的
*!*    单个文件转换代码:
*!*    pdf=hpdf_new(0,0)
*!*    nhandle=hpdf_loadjpegimagefromfile(pdf,GETFILE())
*!*    page1=hpdf_addpage(pdf)
*!*    y=hpdf_page_getheight(page1)
*!*    hpdf_page_drawimage(page1,nhandle,0,y-nheight,nwidth,nheight) && nwidth,nheight得是图片尺寸,才不会变型,否则图像被放大或缩小
*!*    hpdf_savetofile(pdf,putfile("","unnamed","pdf"))
*!*    DO decl
PROCEDURE decl
    Declare Integer HPDF_New In libhpdf.dll Integer herror, Integer pointer
    Declare Integer HPDF_Free In libhpdf.dll Integer hpdf
    Declare Integer HPDF_SaveToFile In libhpdf.dll Integer hpdf, String cfilename
    Declare Integer HPDF_GetError In libhpdf.dll Integer hpdf
    Declare Integer HPDF_ResetError In libhpdf.dll Integer hpdf
    Declare Integer HPDF_SetPageMode In libhpdf.dll Integer hpdf, Integer npagemode
    Declare Integer HPDF_GetCurrentPage In libhpdf.dll Integer hpdf
    Declare Integer HPDF_AddPage In libhpdf.dll Integer hpdf
    Declare Integer HPDF_Page_SetWidth In libhpdf.dll Integer hpdf, Single nwidth
    Declare Integer HPDF_Page_SetHeight In libhpdf.dll Integer hpdf, Single nheight
    Declare Integer HPDF_GetFont In libhpdf.dll Integer hpdf, String fontname, String encodingname
    Declare String  HPDF_LoadTTFontFromFile In libhpdf.dll Integer hpdf, String filename, Integer embedding
    Declare String  HPDF_LoadTTFontFromFile2 In libhpdf.dll Integer, String, Integer
    Declare Integer HPDF_GetEncoder In libhpdf.dll Integer, String
    Declare Integer HPDF_GetCurrentEncoder In libhpdf.dll Integer
    Declare Integer HPDF_SetCurrentEncoder In libhpdf.dll Integer, String
    Declare Integer HPDF_Encoder_GetType In libhpdf.dll Integer
    Declare Integer HPDF_Encoder_GetByteType In libhpdf.dll Integer, String, Integer
    Declare String  HPDF_Encoder_GetUnicode In libhpdf.dll Integer, String
    Declare Integer HPDF_Encoder_GetWritingMode In libhpdf.dll Integer
    Declare Integer HPDF_UseJPEncodings In libhpdf.dll Integer
    Declare Integer HPDF_UseKREncodings In libhpdf.dll Integer
    Declare Integer HPDF_UseCNSEncodings In libhpdf.dll Integer
    Declare Integer HPDF_UseCNTEncodings In libhpdf.dll Integer
    Declare Integer HPDF_LoadPngImageFromFile In libhpdf.dll Integer, String
    Declare Integer HPDF_LoadJpegImageFromFile In libhpdf.dll Integer, String
    Declare Integer HPDF_Image_GetWidth In libhpdf.dll Integer hpage
    Declare Integer HPDF_Image_GetHeight In libhpdf.dll Integer hpage
    Declare Integer HPDF_SetInfoAttr In libhpdf.dll Integer, Integer, String
    Declare Integer HPDF_SetPassword In libhpdf.dll Integer, String, String
    Declare Integer HPDF_SetPermission In libhpdf.dll Integer, Integer
    Declare Integer HPDF_SetEncryptionMode In libhpdf.dll Integer, Integer, Integer
    Declare Integer HPDF_SetCompressionMode In libhpdf.dll Integer, Integer
    Declare Integer HPDF_Font_MeasureText In libhpdf.dll Integer, String, Integer, Single, Single, Single, Single, Integer, Single @
    Declare Single  HPDF_Page_GetWidth In libhpdf.dll Integer
    Declare Single  HPDF_Page_GetHeight In libhpdf.dll Integer
    Declare Single  HPDF_Page_TextWidth In libhpdf.dll Integer, String
    Declare Integer HPDF_Page_GetCurrentFont In libhpdf.dll Integer
    Declare Integer HPDF_Page_MeasureText In libhpdf.dll Integer, String, Single, Integer, Single @
    Declare Integer HPDF_Page_GetRGBFill In libhpdf.dll Integer
    Declare Integer HPDF_Page_GetCurrentFont In libhpdf.dll Integer
    Declare Single  HPDF_Page_GetCurrentFontSize In libhpdf.dll Integer
    Declare Integer HPDF_Page_SetLineWidth In libhpdf.dll Integer, Single
    Declare Integer HPDF_Page_SetDash In libhpdf.dll Integer, String, Integer, Integer
    Declare Integer HPDF_Page_MoveTo In libhpdf.dll Integer, Single, Single
    Declare Integer HPDF_Page_LineTo In libhpdf.dll Integer, Single, Single
    Declare Integer HPDF_Page_ClosePath In libhpdf.dll Integer
    Declare Integer HPDF_Page_Rectangle In libhpdf.dll Integer, Single, Single, Single, Single
    Declare Integer HPDF_Page_Concat In libhpdf.dll Integer, Single, Single, Single, Single, Single, Single
    Declare Integer HPDF_Page_SetCharSpace In libhpdf.dll Integer, Single
    Declare Integer HPDF_Page_SetWordSpace In libhpdf.dll Integer, Single
    Declare Integer HPDF_Page_SetHorizontalScalling In libhpdf.dll Integer, Single
    Declare Integer HPDF_Page_SetTextLeading In libhpdf.dll Integer, Single
    Declare Integer HPDF_Page_SetTextRise In libhpdf.dll Integer, Single
    Declare Integer HPDF_Page_Stroke In libhpdf.dll Integer
    Declare Integer HPDF_Page_ClosePathStroke In libhpdf.dll Integer
    Declare Integer HPDF_Page_Fill In libhpdf.dll Integer
    Declare Integer HPDF_Page_FillStroke In libhpdf.dll Integer
    Declare Integer HPDF_Page_EndPath In libhpdf.dll Integer
    Declare Integer HPDF_Page_BeginText In libhpdf.dll Integer
    Declare Integer HPDF_Page_EndText In libhpdf.dll Integer
    Declare Integer HPDF_Page_SetFontAndSize In libhpdf.dll Integer, Integer, Single
    Declare Integer HPDF_Page_SetTextRenderingMode In libhpdf.dll Integer, Integer
    Declare Integer HPDF_Page_MoveTextPos In libhpdf.dll Integer, Single, Single
    Declare Integer HPDF_Page_MoveToNextLine In libhpdf.dll Integer
    Declare Integer HPDF_Page_SetRGBFill In libhpdf.dll Integer, Single, Single, Single
    Declare Integer HPDF_Page_SetRGBStroke In libhpdf.dll Integer, Single, Single, Single
    Declare Integer HPDF_Page_Ellipse In libhpdf.dll Integer, Single, Single, Single, Single
    Declare Integer HPDF_Page_DrawImage In libhpdf.dll Integer, Integer, Single, Single, Single, Single
    Declare Integer HPDF_Page_TextRect In libhpdf.dll Integer, Single, Single, Single, Single, String, Integer, Integer
    Declare Integer HPDF_Page_TextOut In libhpdf.dll Integer, Single, Single, String
    Declare Integer HPDF_Page_SetTextMatrix In libhpdf.dll Integer ,Single, Single, Single, Single, Single, Single
    Declare Integer HPDF_Page_ShowText In libhpdf.dll Integer, String
    Declare Integer HPDF_Page_CurveTo In libhpdf.dll Integer, Single, Single, Single, Single, Single, Single
    Declare integer HPDF_UseCNSFonts In libhpdf.dll Integer
ENDPROC
19 回复
#2
sam_jiang2023-10-21 15:33
只有本站会员才能查看附件,请 登录
#3
schtg2023-10-21 17:44
谢谢!
#4
sych2023-10-22 09:20
http://
有会的朋友,把最新的编译成dll吧,谢谢

#5
iswith2023-10-22 10:55
试了一下,确实OK,小日本的,用着心里头不舒服。。。。。
只有本站会员才能查看附件,请 登录


#6
sam_jiang2023-10-22 11:02
回复 4楼 sych
有C语言编译器的应该都可以编译
#7
sam_jiang2023-10-22 11:05
回复 5楼 iswith
小日本以前挺厉害的,记得日本在压缩算法有一款共享软件很出名的,另外在条码上也很厉害。还有一款反编译软件execope好像也是出自日本人之手。。。
#8
iswith2023-10-22 11:21
以下是引用sam_jiang在2023-10-22 11:05:25的发言:

小日本以前挺厉害的,记得日本在压缩算法有一款共享软件很出名的,另外在条码上也很厉害。还有一款反编译软件execope好像也是出自日本人之手。。。

这里有一个问题,就是从frx-->image-->>pdf 你的PDF就改变了性质了不是矢量图了!放大变型且不可选择文字。。。成为图片在PDF,这种应该不对。。。。,优点就是转换快速,不用依赖。。。。一个DLL有拥有FRX-->PDF

[此贴子已经被作者于2023-10-22 11:26编辑过]

#9
mail05952023-11-11 16:13
好像没有指定打印机静默打印,放大缩小打印的函数!
#10
seasoners2023-11-13 14:01
汉字库好像不行
#11
sam_jiang2023-11-13 19:46
回复 10楼 seasoners
支持宋体和黑体的

HPDF_UseCNSFonts(Hpdf)

支持的简体字体如下
SimSun(宋体)
SimSun,Bold
SimSun,Italic
SimSun,BoldItalic
SimHei (黑体)
SimHei,Bold
SimHei,Italic
SimHei,BoldItalic

示例:
HPDF_UseCNSFonts(Hpdf)
HPDF_UseCNSEncodings(Hpdf)
def_font = HPDF_GetFont (Hpdf, "SimSun", [GBK-EUC-H])
HPDF_Page_SetFontAndSize (npage, def_font, 24)

[此贴子已经被作者于2023-11-13 21:18编辑过]

#12
sam_jiang2023-11-13 20:46
附上加入汉字显示的代码:
程序代码:

DO decl
dime font_list[15]
    font_list[1]="Courier"
    font_list[2]="Courier-Bold"
    font_list[3]="Courier-Oblique"
    font_list[4]="Courier-BoldOblique"
    font_list[5]="Helvetica"
    font_list[6]="Helvetica-Bold"
    font_list[7]="Helvetica-Oblique"
    font_list[8]="Helvetica-BoldOblique"
    font_list[9]="Times-Roman"
    font_list[10]="Times-Bold"
    font_list[11]="Times-Italic"
    font_list[12]="Times-BoldItalic"
    font_list[13]="Symbol"
    font_list[14]="ZapfDingbats"
    font_list[15]="SimSun" &&宋体

local page_title,hpdf,fname,npage,def_font,ntextwidth,nheight,nwidth,i,samp_text,hfont
page_title= "Font Demo"
hpdf=hpdf_new(0,0)
IF hpdf=0
    RETURN .f.
ENDIF

HPDF_UseCNSFonts(Hpdf) &&显示汉字必须调用这两个函数
HPDF_UseCNSEncodings(Hpdf) &&显示汉字必须调用这两个函数

*!* Add a new page object. *!*
npage = HPDF_AddPage (hpdf)
nheight = HPDF_Page_GetHeight(npage)
nwidth = HPDF_Page_GetWidth (npage)

*!*     Print the lines of the page. *!*
HPDF_Page_SetLineWidth (npage, 1)
HPDF_Page_Rectangle(npage, 50, 50, nwidth - 100, nheight - 110)
HPDF_Page_Stroke(npage)

*!* Print the title of the page (with positioning center). */
def_font = HPDF_GetFont (hpdf, "Helvetica", 0)
HPDF_Page_SetFontAndSize (npage, def_font, 24)

ntextwidth = HPDF_Page_TextWidth (npage, page_title)
HPDF_Page_BeginText (npage)
HPDF_Page_TextOut (npage, (nwidth - ntextwidth) / 2, nheight - 50, page_title)
HPDF_Page_EndText (npage)

*!*    /* output subtitle. */
HPDF_Page_BeginText (npage)
HPDF_Page_SetFontAndSize (npage, def_font, 16)
HPDF_Page_TextOut (npage, 60, nheight - 80, "<Standerd Type1 fonts samples>")
HPDF_Page_EndText (npage)

HPDF_Page_BeginText (npage)
HPDF_Page_MoveTextPos (npage, 60, nheight - 105)

FOR i=1 TO aLEN(font_list)
    IF i=15
        samp_text="欢迎使用libhpdf宋体汉字库!"
              hfont = HPDF_GetFont(hpdf, font_list[i],[GBK-EUC-H])
    else   
        samp_text="abcdefgABCDEFG12345!#$%&+-@?"
           hfont = HPDF_GetFont(hpdf, font_list[i], 0)
    endif   

 
    *!*/* print a label of text */
    HPDF_Page_SetFontAndSize (npage, def_font, 9)
    HPDF_Page_ShowText(npage, font_list[i])
    HPDF_Page_MoveTextPos(npage, 0, -18)

    *!*    /* print a sample text. */
    HPDF_Page_SetFontAndSize(npage, hfont, 20)
    HPDF_Page_ShowText(npage, samp_text)
    HPDF_Page_MoveTextPos(npage, 0, -20)
ENDFOR
HPDF_Page_EndText(npage)
fname=PUTFILE("","pdftest","pdf")
HPDF_SaveToFile (hpdf, fname)
*!*    /* clean up */
HPDF_Free(hpdf)
RETURN .t.


*!*    pdf = HPDF_New(0, 0)
*!*    HPDF_UseCNSFonts(pdf)
*!*    HPDF_UseCNSEncodings(pdf)
*!*    HPDF_SetCompressionMode(pdf, HPDF_COMP_ALL)
*!*    page1 = HPDF_AddPage(pdf)
*!*    lnHandle=HPDF_LoadJpegImageFromFile(pdf, lcFile)
*!*    HPDF_Page_DrawImage(Page1, lnHandle, 0,0,620,878)
*!*    HPDF_SaveToFile (pdf,(dir1)+'\'+afile1+".pdf")
*!*    HPDF_Free(pdf)
*!*    我试了,
*!*    HPDF_Page_DrawImage(Page1, lnHandle, nx,ny,nwidth,nheight) &&nx,ny是以左下角为坐标点的
*!*    单个文件转换代码:
*!*    pdf=hpdf_new(0,0)
*!*    nhandle=hpdf_loadjpegimagefromfile(pdf,GETFILE())
*!*    page1=hpdf_addpage(pdf)
*!*    y=hpdf_page_getheight(page1)
*!*    hpdf_page_drawimage(page1,nhandle,0,y-nheight,nwidth,nheight) && nwidth,nheight得是图片尺寸,才不会变型,否则图像被放大或缩小
*!*    hpdf_savetofile(pdf,putfile("","unnamed","pdf"))
*!*    DO decl
PROCEDURE decl
    Declare Integer HPDF_New In libhpdf.dll Integer herror, Integer pointer
    Declare Integer HPDF_Free In libhpdf.dll Integer hpdf
    Declare Integer HPDF_SaveToFile In libhpdf.dll Integer hpdf, String cfilename
    Declare Integer HPDF_GetError In libhpdf.dll Integer hpdf
    Declare Integer HPDF_ResetError In libhpdf.dll Integer hpdf
    Declare Integer HPDF_SetPageMode In libhpdf.dll Integer hpdf, Integer npagemode
    Declare Integer HPDF_GetCurrentPage In libhpdf.dll Integer hpdf
    Declare Integer HPDF_AddPage In libhpdf.dll Integer hpdf
    Declare Integer HPDF_Page_SetWidth In libhpdf.dll Integer hpdf, Single nwidth
    Declare Integer HPDF_Page_SetHeight In libhpdf.dll Integer hpdf, Single nheight
    Declare Integer HPDF_GetFont In libhpdf.dll Integer hpdf, String fontname, String encodingname
    Declare String  HPDF_LoadTTFontFromFile In libhpdf.dll Integer hpdf, String filename, Integer embedding
    Declare String  HPDF_LoadTTFontFromFile2 In libhpdf.dll Integer hpdf, String filename, Integer embedding
    Declare Integer HPDF_GetEncoder In libhpdf.dll Integer hpdf, String encodingname
    Declare Integer HPDF_GetCurrentEncoder In libhpdf.dll Integer hpdf
    Declare Integer HPDF_SetCurrentEncoder In libhpdf.dll Integer hpdf, String encodingname
    Declare Integer HPDF_Encoder_GetType In libhpdf.dll Integer encoder
    Declare Integer HPDF_Encoder_GetByteType In libhpdf.dll Integer encoder, String ctext, Integer nindex
    Declare String  HPDF_Encoder_GetUnicode In libhpdf.dll Integer encoder, String ccode
    Declare Integer HPDF_Encoder_GetWritingMode In libhpdf.dll Integer encoder
    Declare Integer HPDF_UseJPEncodings In libhpdf.dll Integer hpdf
    Declare Integer HPDF_UseKREncodings In libhpdf.dll Integer hpdf
    Declare Integer HPDF_UseCNSEncodings In libhpdf.dll Integer hpdf
    Declare Integer HPDF_UseCNTEncodings In libhpdf.dll Integer hpdf
    Declare Integer HPDF_LoadPngImageFromFile In libhpdf.dll Integer hpdf, String cfilename
    Declare Integer HPDF_LoadJpegImageFromFile In libhpdf.dll Integer hpdf, String cfilename
    Declare Integer HPDF_Image_GetWidth In libhpdf.dll Integer hpage
    Declare Integer HPDF_Image_GetHeight In libhpdf.dll Integer hpage
    Declare Integer HPDF_SetInfoAttr In libhpdf.dll Integer hpdf, Integer ntype, String cvalue
    Declare Integer HPDF_SetPassword In libhpdf.dll Integer hpdf, String ownerpassword, String userpassword
    Declare Integer HPDF_SetPermission In libhpdf.dll Integer hpdf, Integer npermission
    Declare Integer HPDF_SetEncryptionMode In libhpdf.dll Integer hpdf, Integer nmode, Integer nkeylen
    Declare Integer HPDF_SetCompressionMode In libhpdf.dll Integer hpdf, Integer nmode
    Declare Integer HPDF_Font_MeasureText In libhpdf.dll Integer hfont, String ctext, Integer nlength, Single nwidth, ;
                                                        Single nfontsize, Single ncharspace, Single nwordspace, Integer nwordwrap, Single @nrealwidth
    Declare Single  HPDF_Page_GetWidth In libhpdf.dll Integer hpage
    Declare Single  HPDF_Page_GetHeight In libhpdf.dll Integer hpage
    Declare Single  HPDF_Page_TextWidth In libhpdf.dll Integer hpage, String ctext
    Declare Integer HPDF_Page_GetCurrentFont In libhpdf.dll Integer hpage
    Declare Integer HPDF_Page_MeasureText In libhpdf.dll Integer hpage, String ctext, Single nwidth, Integer nwordwrap, Single @nrealwidth
    Declare Integer HPDF_Page_GetRGBFill In libhpdf.dll Integer hpage
    Declare Integer HPDF_Page_GetCurrentFont In libhpdf.dll Integer hpage
    Declare Single  HPDF_Page_GetCurrentFontSize In libhpdf.dll Integer hpage
    Declare Integer HPDF_Page_SetLineWidth In libhpdf.dll Integer npage, Single nlinewidth
    Declare Integer HPDF_Page_SetDash In libhpdf.dll Integer npage, String cdashptn, Integer nnumpara, Integer nphase
    Declare Integer HPDF_Page_MoveTo In libhpdf.dll Integer hpage, Single x, Single y
    Declare Integer HPDF_Page_LineTo In libhpdf.dll Integer hpage, Single x, Single y
    Declare Integer HPDF_Page_ClosePath In libhpdf.dll Integer hpage
    Declare Integer HPDF_Page_Rectangle In libhpdf.dll Integer hpage, Single x, Single y, Single nwidth, Single nheight
    Declare Integer HPDF_Page_Concat In libhpdf.dll Integer hpage, Single a, Single b, Single c, Single d, Single x, Single y
    Declare Integer HPDF_Page_SetCharSpace In libhpdf.dll Integer hpage, Single nspace
    Declare Integer HPDF_Page_SetWordSpace In libhpdf.dll Integer hpage, Single nspace
    Declare Integer HPDF_Page_SetHorizontalScalling In libhpdf.dll Integer hpage, Single nscalling
    Declare Integer HPDF_Page_SetTextLeading In libhpdf.dll Integer hpage, Single nleading
    Declare Integer HPDF_Page_SetTextRise In libhpdf.dll Integer hpage, Single nrise
    Declare Integer HPDF_Page_Stroke In libhpdf.dll Integer hpage
    Declare Integer HPDF_Page_ClosePathStroke In libhpdf.dll Integer hpage
    Declare Integer HPDF_Page_Fill In libhpdf.dll Integer hpage
    Declare Integer HPDF_Page_FillStroke In libhpdf.dll Integer
    Declare Integer HPDF_Page_EndPath In libhpdf.dll Integer
    Declare Integer HPDF_Page_BeginText In libhpdf.dll Integer
    Declare Integer HPDF_Page_EndText In libhpdf.dll Integer
    Declare Integer HPDF_Page_SetFontAndSize In libhpdf.dll Integer, Integer, Single
    Declare Integer HPDF_Page_SetTextRenderingMode In libhpdf.dll Integer, Integer
    Declare Integer HPDF_Page_MoveTextPos In libhpdf.dll Integer, Single, Single
    Declare Integer HPDF_Page_MoveToNextLine In libhpdf.dll Integer
    Declare Integer HPDF_Page_SetRGBFill In libhpdf.dll Integer, Single, Single, Single
    Declare Integer HPDF_Page_SetRGBStroke In libhpdf.dll Integer, Single, Single, Single
    Declare Integer HPDF_Page_Ellipse In libhpdf.dll Integer, Single, Single, Single, Single
    Declare Integer HPDF_Page_DrawImage In libhpdf.dll Integer, Integer, Single, Single, Single, Single
    Declare Integer HPDF_Page_TextRect In libhpdf.dll Integer, Single, Single, Single, Single, String, Integer, Integer
    Declare Integer HPDF_Page_TextOut In libhpdf.dll Integer, Single, Single, String
    Declare Integer HPDF_Page_SetTextMatrix In libhpdf.dll Integer ,Single, Single, Single, Single, Single, Single
    Declare Integer HPDF_Page_ShowText In libhpdf.dll Integer, String
    Declare Integer HPDF_Page_CurveTo In libhpdf.dll Integer, Single, Single, Single, Single, Single, Single
    Declare integer HPDF_UseCNSFonts In libhpdf.dll Integer
ENDPROC


上面的代码在win7+VFP9 环境编译通过!

#13
sam_jiang2023-11-13 21:22
回复 9楼 mail0595
跟打印没有关系的,这是Pdf库
#14
seasoners2023-12-14 07:54
其他汉字不行吧
#15
sam_jiang2023-12-17 18:55
回复 14楼 seasoners
好像目前只支持宋体和黑体。。。
#16
sostemp2023-12-19 09:10
先收藏学习代码,dll谁上传一个新版。
#17
csyx2023-12-19 10:18
以下是引用sam_jiang在2023-12-17 18:55:29的发言:

好像目前只支持宋体和黑体。。。

可以的,只是用 HPDF_UseCNSFonts 仅加载了宋体和黑体字体,其他中文字体需要用 HPDF_LoadTTFontFromFile(加载 TTF 字体文件)或 HPDF_LoadTTFontFromFile2 (加载 TTC 字体文件)
只有本站会员才能查看附件,请 登录

总的来说这个 dll 问题很多,例如前面提到过的出口参数问题;中文也有问题,例如要显示 GBK 字符集中的汉字,例如:朱(镕)基、(焗)油,就必须将 GB-EUC-H 换成 GBK-EUC-H,但这样一来,英文/数字/符号又不显示了 。。。一言难尽,唯有弃用
#18
foxfans2023-12-19 11:14
只有本站会员才能查看附件,请 登录

是这个?代码调用问题?


[此贴子已经被作者于2023-12-19 11:16编辑过]

#19
csyx2023-12-19 13:21
以下是引用foxfans在2023-12-19 11:14:27的发言:
是这个?代码调用问题?

不是,使用 HPDF_UseCNSFonts 装入的宋体、黑体没问题,问题出在使用 HPDF_LoadTTFontFromFile/HPDF_LoadTTFontFromFile2 装入的其他中文字体
只有本站会员才能查看附件,请 登录
#20
老去的流星雨2024-02-19 14:01
搞那么复杂干什么,直接调用WINDOWS的PDF打印机不就得了,可以完美保留字体和样式
自己使用的调用PDF打印机的代码片断
        DELETE FILE GETENV("TEMP")+'\pdf*.*'
        COPY FILE _Cfg.AppPath+IIF('ZDesigner'$Thisform.cPrintName,"Reports\ZT211\","Reports\")+ ALLTRIM(TB_BAG_STICKER_REPORT.打印模版)+'.*' TO GETENV("TEMP")+'\pdf.*'
        USE GETENV("TEMP")+'\pdf.frx' IN SELECT(1)
        APRINTERS(prt)
        lcPrintName = ""
        FOR i = 1 TO ALEN(prt,1)
            IF 'PDF'$prt(i,1)
                lcPrintName = prt(i,1)
            ENDIF
        ENDFOR
        SET PRINTER TO NAME (lcPrintName)
        REPLACE tag WITH '' tag2 WITH '' IN pdf
        USE IN pdf
        REPORT FORM GETENV("TEMP")+'\pdf.frx' NOEJECT NOCONSOLE TO PRINTER
1