使用python输出pdf

Python+FPDF 实现灵活的导出数据至PDF FPDF 阅读详情
第一种:直接输出PDF——使用reportlab库
在https://www.reportlab.com/software/installation/上面有完整的说明
首先,下载和安装python,推荐2.5/2.6/2.7
然后下载和安装Python Image Library——http://www.pythonware.com/products/pil/,以便在PDF中使用bitmap格式的图片
当然,主要的工具包当然是必不可少的——https://www.reportlab.com/ftp/reportlab-2.5.win32-py2.7.exe    #后面的py2.7改成自己的版本
如果想用到RML和PageCatcher,还得下载ReportLab PLUS,不过这是收费的
如果在pythonXX文件夹下有这样的路径Lib\site-packages\reportlab,就说明装好了


https://www.reportlab.com/software/documentation/这个链接下有相关的文档支持


下面是一个简单的生成pdf的例子
from reportlab.pdfgen import canvas
def hello(c):
    c.drawString(100, 100, "Hello Wolrd")
c = canvas.Canvas("Hello.pdf")
hello(c)
c.showPage()
c.save()

第二种:word转PDF
//第一步word转txt

如果你是在Windows下, 直接使用win32com就可以进行读取word.doc文档和写入文档了。 

但是在Linux下还真是麻烦, 一种方法是用OpenOffice的一个库来进行操作,那么意味这你要安装慢得要死的OpenOffice., 详细见下面的网址:

http://www.freewisdom.org/projects/python-markdown/odt2txt
我是使用catdoc将word文档转换为txt文档, 然后用Python读取txt文档,存入数据库
catdoc的下载地址是:
http://vitus.wagner.pp.ru/software/catdoc/

当然,如果使用Ubuntu, 直接apt-get就可以安装了
sudo apt-get install catdoc
然后就可以进行操作了,以下是代码:
import os
doc_file = 'a.doc'
text_file = '%s.text' % doc_file
os.system("cat doc %s > %s" % (doc_file, text_file)
f = open(text_file, 'r')
content = f.read()

os.system('rm %s' % text_file)


//然后TXT转pdf
下面是来自Activestate的一段代码:

## {{{ http://code.activestate.com/recipes/189858/ (r8)
"""
 pyText2Pdf - Python script to convert plain text files into Adobe
 Acrobat PDF files.

 Version 1.2

 Author: Anand B Pillai <abpillai at lycos dot com>
 Keywords: python, tools, converter, pdf, text2pdf, adobe, acrobat,
           processing.

 Copyright (C) 2003-2004 Free Software Foundation, Inc.

 This file is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2, or (at your option)
 any later version.

 This file is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
    
 You should have received a copy of the GNU General Public License
 along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.
    
 Commentary:

 Modification History:

 Mon Feb 17 12:20:13 2003 Changed option parsing algorithm to use
                          getopt. Use __main__ calling convention.
                          Bug in FF character fixed.
 Thu Apr 10 11:26:58 2003 Modified to use python style strings
                          and function objects.
 July 1 2003              Fixed help string errors. Added the
                          Creator property.
 Feb 25 2004              Rewrote argument parser to remove
                          duplicate code.Use string.join() instead
                          of concatenation. Modified sys.exit()
                          calls to print messages.
    Code:
"""

# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189858

import sys, os
import string
import time
import getopt

LF_EXTRA=0
LINE_END='\015'
# form feed character (^L)
FF=chr(12)

ENCODING_STR = """\
/Encoding <<
/Differences [ 0 /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /space /exclam
/quotedbl /numbersign /dollar /percent /ampersand
/quoteright /parenleft /parenright /asterisk /plus /comma
/hyphen /period /slash /zero /one /two /three /four /five
/six /seven /eight /nine /colon /semicolon /less /equal
/greater /question /at /A /B /C /D /E /F /G /H /I /J /K /L
/M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft
/backslash /bracketright /asciicircum /underscore
/quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o /p
/q /r /s /t /u /v /w /x /y /z /braceleft /bar /braceright
/asciitilde /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/dotlessi /grave /acute /circumflex /tilde /macron /breve
/dotaccent /dieresis /.notdef /ring /cedilla /.notdef
/hungarumlaut /ogonek /caron /space /exclamdown /cent
/sterling /currency /yen /brokenbar /section /dieresis
/copyright /ordfeminine /guillemotleft /logicalnot /hyphen
/registered /macron /degree /plusminus /twosuperior
/threesuperior /acute /mu /paragraph /periodcentered
/cedilla /onesuperior /ordmasculine /guillemotright
/onequarter /onehalf /threequarters /questiondown /Agrave
/Aacute /Acircumflex /Atilde /Adieresis /Aring /AE
/Ccedilla /Egrave /Eacute /Ecircumflex /Edieresis /Igrave
/Iacute /Icircumflex /Idieresis /Eth /Ntilde /Ograve
/Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash
/Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn
/germandbls /agrave /aacute /acircumflex /atilde /adieresis
/aring /ae /ccedilla /egrave /eacute /ecircumflex
/edieresis /igrave /iacute /icircumflex /idieresis /eth
/ntilde /ograve /oacute /ocircumflex /otilde /odieresis
/divide /oslash /ugrave /uacute /ucircumflex /udieresis
/yacute /thorn /ydieresis ]
>>
"""


PROG_HELP = """\

%(progname)s  [options] [filename]

%(progname)s  makes a 7-bit clean PDF file from any input file.

It reads from a named file, and writes the PDF file to a file specified by 
the user, otherwise to a file with '.pdf' appended to the input file.

Author: Anand B Pillai.

Copyright (C) 2003-2004 Free Software Foundation, http://www.fsf.org

There are various options as follows:

  -h\t\tshow this message\n
  -o/-O\t\tdirect output to this file
  -f<font>\tuse PostScript <font> (must be in standard 14, default: Courier)
  -I\t\tuse ISOLatin1Encoding
  -s<size>\tuse font at given pointsize (default 10) points\n
  -v<dist>\tuse given line spacing (default 12) points
  -l<lines>\tlines per page (default 60, determined automatically\n\t\tif unspecified)
  -c<chars>\tmaximum characters per line (default 80)
  -t<spaces>\tspaces per tab character (default 4)
  -F\t\tignore formfeed characters (^L)
    \t\t(i.e, accept formfeed characters as pagebreaks)\n
  -A4\t\tuse A4 paper (default Letter)
  -A3\t\tuse A3 paper (default Letter)
  -x<width>\tindependent paper width in points
  -y<height>\tindependent paper height in points
  -2\t\tformat in 2 columns
  -L\t\tlandscape mode

Note that where one variable is implied by two options, the second option
takes precedence for that variable. (e.g. -A4 -y500)

In landscape mode, page width and height are simply swapped over before
formatting, no matter how or when they were defined.
"""


class pyText2Pdf:

    def __init__(self):
        # version number
        self._version="1.1.1"
        # iso encoding flag
        self._IsoEnc=0
        # formfeeds flag
        self._doFFs=0
        self._progname="PyText2Pdf"
        self._appname = "".join((self._progname, " Version ", str(self._version)))
        # default font
        self._font="/Courier"
        # default font size
        self._ptSize=10
        # default vert space
        self._vertSpace=12
        self._lines=0
        # number of characters in a row
        self._cols=80
        self._columns=1
        # page ht
        self._pageHt=792
        # page wd
        self._pageWd=612
        # input file 
        self._ifile=""
        # output file 
        self._ofile=""
        # default tab width
        self._tab=4
        # input file descriptor
        self._ifs=None
        # output file descriptor
        self._ofs=None
        # landscape flag
        self._landscape=0

        # marker objects
        self._curobj = 5
        self._pageObs = [0]
        self._locations = [0,0,0,0,0,0]
        self._pageNo=0

        # file position marker
        self._fpos=0

    def argsCallBack(self, argslist, listoftuples=False):
        """ Callback function called by argument parser.
        Helps to remove duplicate code """

        x = 0
        while x<len(argslist):
            item = argslist[x]

            if listoftuples:
                o, a = item
            else:
                o = item

            if o == '-h':
                self.ShowHelp()
            elif o == '-I':
                self._IsoEnc=1
            elif o == '-F':
                self._doFFs=1
            elif o == '-2':
                self._columns=2
            elif o == '-L':
                self._landscape=1
                    
            if o in ('-f', '-s', '-l', '-x', 'y', '-c', '-v', '-o', '-O'):
                
                if not listoftuples:
                    x += 1
                    try:
                        a = argslist[x]
                    except:
                        msg = "Argument error for option " + o
                        sys.exit(msg)

                if a == "" or a[0] == "-":
                    msg = "Error: argument error for option " + o
                    sys.exit(msg)
                elif o == '-f':
                    self._font='/' + a
                elif o == '-A':
                    if a == '3':
                        self._pageWd=842
                        self._pageHt=1190
                    elif a =='4':
                        self._pageWd=595
                        self._pageHt=842
                    else:
                        psz=o[1]+a
                        print self._progname, ': ignoring unknown paper size ', psz
                elif o == '-s':
                    self._ptSize=int(a)
                    if self._ptSize<1:
                        self._ptSize=1
                elif o == '-v':
                    self._vertSpace=int(a)
                    if self._vertSpace<1:
                        self._vertSpace=1       
                elif o == '-l':
                    self._lines=int(a)
                    if self._lines<1:
                        self._lines=1
                elif o == '-c':
                    self._cols=int(a)
                    if self._cols<4:
                        self._cols=4
                elif o == '-t':
                    self._tab=int(a)
                    if self._tab<1:
                        self._tab=1
                elif o == '-x':
                    self._pageWd=int(a)
                    if self._pageWd<72:
                        self._pageWd=72
                elif o == '-y':
                    self._pageHt=int(a)
                    if self._pageHt<72:
                        self._pageHt=72
                elif o in ('-o', '-O'):
                    self._ofile=a
                else:
                    print self._progname, ': ignoring invalid switch: ', o

            x += 1

        
    def parseArgs(self):

        if len(sys.argv) == 1:
            self.ShowHelp()

        arguments=sys.argv[1:]
        
        optlist, args = getopt.getopt(arguments, 'hIF2Lf:A:s:v:l:c:t:x:y:o:')
        
        # input file is the first element in arg list
        # or last element in options list (in case of an error!)
        if len(args):
            self._ifile=args[0]
        else:
            l=len(optlist)
            tup=optlist[l-1]

        # parse options list
        if len(optlist):
            self.argsCallBack( optlist, listoftuples=True )
        else:
            self.argsCallBack( args )

        if self._landscape:
            print 'Landscape option on...'
        if self._columns==2:
            print 'Printing in two columns...'
        if self._doFFs:
            print 'Ignoring form feed character...'
        if self._IsoEnc:
            print 'Using ISO Latin Encoding...'
        print 'Using font', self._font[1:], ' size =', self._ptSize
            

    def writestr(self, str):
        """ Write string to output file descriptor.
        All output operations go through this function.
        We keep the current file position also here"""

        # update current file position
        self._fpos += len(str)
        for x in range(0, len(str)):
            if str[x] == '\n':
                self._fpos += LF_EXTRA
        try:
            self._ofs.write(str)
        except IOError, e:
            print e
            return -1

        return 0
            
    def Convert(self):
        """ Perform the actual conversion """
    
        if self._landscape:
            # swap page width & height
            tmp = self._pageHt
            self._pageHt = self._pageWd
            self._pageWd = tmp

        if self._lines==0:
            self._lines = (self._pageHt - 72)/self._vertSpace
        if self._lines < 1:
            self._lines=1
        
        try:
            self._ifs=open(self._ifile)
        except IOError, (strerror, errno):
            print 'Error: Could not open file to read --->', self._ifile
            sys.exit(3)

        if self._ofile=="":
            self._ofile=self._ifile + '.pdf'

        try:
            self._ofs = open(self._ofile, 'wb')
        except IOError, (strerror, errno):
            print 'Error: Could not open file to write --->', self._ofile
            sys.exit(3)

        print 'Input file =>', self._ifile
        print 'Writing pdf file', self._ofile, '...'
        self.WriteHeader(self._ifile)
        self.WritePages()
        self.WriteRest()

        print 'Wrote file', self._ofile
        self._ifs.close()
        self._ofs.close()
        return 0

    def WriteHeader(self, title):
        """Write the PDF header"""

        ws = self.writestr

        t=time.localtime()
        timestr=str(time.strftime("D:%Y%m%d%H%M%S", t))
        ws("%PDF-1.4\n")
        self._locations[1] = self._fpos
        ws("1 0 obj\n")
        ws("<<\n")

        buf = "".join(("/Creator (", self._appname, " By Anand B Pillai )\n"))
        ws(buf)
        buf = "".join(("/CreationDate (", timestr, ")\n"))
        ws(buf)
        buf = "".join(("/Producer (", self._appname, "(\\251 Free Software Foundation, 2004))\n"))
        ws(buf)
        
        if title:
            buf = "".join(("/Title (", title, ")\n"))
            ws(buf)

        ws(">>\n")
        ws("endobj\n")
    
        self._locations[2] = self._fpos

        ws("2 0 obj\n")
        ws("<<\n")
        ws("/Type /Catalog\n")
        ws("/Pages 3 0 R\n")
        ws(">>\n")
        ws("endobj\n")
        
        self._locations[4] = self._fpos
        ws("4 0 obj\n")
        ws("<<\n")
        buf = "".join(("/BaseFont ", str(self._font), " /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font >>\n"))
        ws(buf)
    
        if self._IsoEnc:
            ws(ENCODING_STR)
            
        ws(">>\n")
        ws("endobj\n")
        
        self._locations[5] = self._fpos
        
        ws("5 0 obj\n")
        ws("<<\n")
        ws("  /Font << /F1 4 0 R >>\n")
        ws("  /ProcSet [ /PDF /Text ]\n")
        ws(">>\n")
        ws("endobj\n")
    
    def StartPage(self):
        """ Start a page of data """

        ws = self.writestr
        
        self._pageNo += 1
        self._curobj += 1

        self._locations.append(self._fpos)
        self._locations[self._curobj]=self._fpos
    
        self._pageObs.append(self._curobj)
        self._pageObs[self._pageNo] = self._curobj
        
        buf = "".join((str(self._curobj), " 0 obj\n"))

        ws(buf)
        ws("<<\n")
        ws("/Type /Page\n")
        ws("/Parent 3 0 R\n")
        ws("/Resources 5 0 R\n")

        self._curobj += 1
        buf = "".join(("/Contents ", str(self._curobj), " 0 R\n"))
        ws(buf)
        ws(">>\n")
        ws("endobj\n")
        
        self._locations.append(self._fpos)
        self._locations[self._curobj] = self._fpos

        buf = "".join((str(self._curobj), " 0 obj\n"))
        ws(buf)
        ws("<<\n")
        
        buf = "".join(("/Length ", str(self._curobj + 1), " 0 R\n"))
        ws(buf)
        ws(">>\n")
        ws("stream\n")
        strmPos = self._fpos
    
        ws("BT\n");
        buf = "".join(("/F1 ", str(self._ptSize), " Tf\n"))
        ws(buf)
        buf = "".join(("1 0 0 1 50 ", str(self._pageHt - 40), " Tm\n"))
        ws(buf)
        buf = "".join((str(self._vertSpace), " TL\n"))
        ws(buf)
    
        return strmPos

    def EndPage(self, streamStart):
        """End a page of data """
        
        ws = self.writestr

        ws("ET\n")
        streamEnd = self._fpos
        ws("endstream\n")
        ws("endobj\n")
    
        self._curobj += 1
        self._locations.append(self._fpos)
        self._locations[self._curobj] = self._fpos
    
        buf = "".join((str(self._curobj), " 0 obj\n"))
        ws(buf)
        buf = "".join((str(streamEnd - streamStart), '\n'))
        ws(buf)
        ws('endobj\n')
    
    def WritePages(self):
        """Write pages as PDF"""
        
        ws = self.writestr

        beginstream=0
        lineNo, charNo=0,0
        ch, column=0,0
        padding,i=0,0
        atEOF=0
        
        while not atEOF:
            beginstream = self.StartPage()
            column=1
            
            while column <= self._columns:
                column += 1
                atFF=0
                atBOP=0
                lineNo=0
            
                while lineNo < self._lines and not atFF and not atEOF:
                    
                    lineNo += 1
                    ws("(")
                    charNo=0
                    
                    while charNo < self._cols:
                        charNo += 1
                        ch = self._ifs.read(1)
                        cond = ((ch != '\n') and not(ch==FF and self._doFFs) and (ch != ''))
                        if not cond:
                            break

                        if ord(ch) >= 32 and ord(ch) <= 127:
                            if ch == '(' or ch == ')' or ch == '\\':
                                ws("\\")
                            ws(ch)
                        else:
                            if ord(ch) == 9:
                                padding =self._tab - ((charNo - 1) % self._tab)
                                for i in range(padding):
                                    ws(" ")
                                charNo += (padding -1)
                            else:
                                if ch != FF:
                                    # write \xxx form for dodgy character
                                    buf = "".join(('\\', ch))
                                    ws(buf)
                                else:
                                    # dont print anything for a FF
                                    charNo -= 1

                    ws(")'\n")
                    if ch == FF:
                        atFF=1
                    if lineNo == self._lines:
                        atBOP=1
                        
                    if atBOP:
                        pos=0
                        ch = self._ifs.read(1)
                        pos= self._ifs.tell()
                        if ch == FF:
                            ch = self._ifs.read(1)
                            pos=self._ifs.tell()
                        # python's EOF signature
                        if ch == '':
                            atEOF=1
                        else:
                            # push position back by one char
                            self._ifs.seek(pos-1)

                    elif atFF:
                        ch = self._ifs.read(1)
                        pos=self._ifs.tell()
                        if ch == '':
                            atEOF=1
                        else:
                            self._ifs.seek(pos-1)

                if column < self._columns:
                    buf = "".join(("1 0 0 1 ",
                                   str((self._pageWd/2 + 25)),
                                   " ",
                                   str(self._pageHt - 40),
                                   " Tm\n"))
                    ws(buf)

            self.EndPage(beginstream)

    def WriteRest(self):
        """Finish the file"""

        ws = self.writestr
        self._locations[3] = self._fpos
    
        ws("3 0 obj\n")
        ws("<<\n")
        ws("/Type /Pages\n")
        buf = "".join(("/Count ", str(self._pageNo), "\n"))
        ws(buf)
        buf = "".join(("/MediaBox [ 0 0 ", str(self._pageWd), " ", str(self._pageHt), " ]\n"))
        ws(buf)
        ws("/Kids [ ")
    
        for i in range(1, self._pageNo+1):
            buf = "".join((str(self._pageObs[i]), " 0 R "))
            ws(buf)

        ws("]\n")
        ws(">>\n")
        ws("endobj\n")
        
        xref = self._fpos
        ws("xref\n")
        buf = "".join(("0 ", str((self._curobj) + 1), "\n"))
        ws(buf)
        buf = "".join(("0000000000 65535 f ", str(LINE_END)))
        ws(buf)

        for i in range(1, self._curobj + 1):
            val = self._locations[i]
            buf = "".join((string.zfill(str(val), 10), " 00000 n ", str(LINE_END)))
            ws(buf)

        ws("trailer\n")
        ws("<<\n")
        buf = "".join(("/Size ", str(self._curobj + 1), "\n"))
        ws(buf)
        ws("/Root 2 0 R\n")
        ws("/Info 1 0 R\n")
        ws(">>\n")
        
        ws("startxref\n")
        buf = "".join((str(xref), "\n"))
        ws(buf)
        ws("%%EOF\n")
        
    def ShowHelp(self):
        """Show help on this program"""
        
        sys.exit( PROG_HELP % {'progname': self._progname} )

def main():
    
    pdfclass=pyText2Pdf()
    pdfclass.parseArgs()
    pdfclass.Convert()

if __name__ == "__main__":
    main()
## end of http://code.activestate.com/recipes/189858/ }}}




遇到的一些问题:

使用pywin32:

当找不到指定模块时,即import的模块找不到时,使用下列语句

import pywintypes   #import pythoncom # Uncomment this if some other DLL load will fail

python2.7下找不到win32ui,换python2.6试一下

自动化生成报告:如何使用 Python 动态填充数据并输出 PDF 本文介绍了如何利用Python实现自动化报告生成,重点讲解了动态数据填充和PDF格式输出的方法。通过Jinja2模板引擎实现数据动态填充,结合Pandas处理表格数据,并使用ReportLab或pdfkit将HTML内容转换为PDF格式。文章还演示了如何用Matplotlib生成可视化图表并嵌入PDF报告。这套自动化流程适用于销售、财务和数据分析等场景,能显著提升报告生成效率,减少人工错误。 阅读详情

相关推荐

使用C#的DrawString方法绘制文本

总结一下,C#的DrawString方法是一个十分有用的功能,可以帮助我们在图像或控件上绘制出各种文本信息。通过合理地使用DrawString方法,我们可以实现丰富多样的文本绘制效果。在C#编程中,我们经常需要将文本绘制到图形界面上。DrawString方法是.NET Framework提供的一个功能强大的方法,用于在图像或控件上绘制字符串。你可以根据自己的需求修改字体、文本内容和位置,并进行更加复杂的绘制操作。在上述示例中,我们创建了一个Windows窗体应用程序,并在窗体的。,用于确定绘制文本的颜色。

m0_47037246的博客 1875

python轻松生成pdf文档

python轻松生成pdf文档

Java癫疯的博客 1万+

python实现PDF (附完整源码)

python实现PDF (附完整源码)

希望我的博客,能帮上你解决学习中工作中所遇到的问题 432

python生成中文PDF文件的5个方法

ReportLab库支持包括文字、线条、配色、图形、图片等在内的多种元素绘制,但默认不支持中文。WeasyPrint 是一个将HTML+CSS内容转换为PDF的Python库,非常适合需要首先通过HTML生成内容,然后再转成PDF的情况。PyPDF2 是最常用的PDF处理库,它支持PDF的分页、合并、剪辑以及插入图片、文字等内容。中文字体支持:在TeXLive中安装xelatex或lualatex,并使用CTeX宏包。中文字体支持:直接使用系统中的已安装字体或者自己下载一个开源中文字体并安装,例如。

weixin_41168869的博客 1万+

企业固定资产管理的SAP实战:FICO模块配置与折旧范围设置详解

本文深入解析了SAP FICO模块中固定资产会计配置的核心实践,重点阐述了折旧范围的设计哲学与配置逻辑。通过详解折旧表、折旧范围、资产分类及折旧码等关键配置步骤,指导企业如何搭建满足多会计准则(如CAS、IFRS)与税务要求的资产管理体系,实现资产购置、折旧计提与报废清理的自动化与精准化。

wdx01234567的博客 728

433MHz无线通信避坑指南:如何解决信号干扰和误码问题

本文深入探讨433MHz无线通信中的信号干扰和误码问题,提供从射频前端设计到协议优化的全链路解决方案。通过天线匹配、电源噪声抑制、曼彻斯特编码改进及实时频点切换等技术,显著提升通信稳定性和距离。适合智能家居和工业无线控制系统的开发者参考。

weixin_29288313的博客 419

【转】Python读取PDF文档,输出内容

Python3读取pdf文档,输出内容(txt) from urllib.request import urlopen from pdfminer.pdfinterp import PDFResourceManager,process_pdf from pdfminer.converter import TextConverter from pdfminer.layout imp...

weixin_30748995的博客 208

win7 vs2012+wdk8.0 搭建wdf驱动开发环境

开发环境搭建: 系统:win7 x64 工具:vs2012 + WDK8.0 插件:wdfcoinstaller.msi (1)先安装vs2012,再安装wdk8.0,这样在打开vs2012时可以创建windows drivers类型的工程。 注:vs2012不能安装wdk8.1,wdk8.1必须安装在vs2013上 下载链接:http://msdn.microsoft.com/zh-cn/win...

技术联盟 5344

python显示pdf_利用python将pdf输出为txt的实例讲解

一个礼拜前一个同学问我这个事情,由于之前在参加华为的比赛,所以赛后看了一下,据说需要用到pdfminer这个包。于是安装了一下,安装过程很简单:sudo pip install pdfminer;中间也没有任何的报错。至于如何调用,本人也没有很好的研究过pdfminer这个库,于是开始了百度……完全使用python编写。 (适用于2.4或更新版本)解析,分析,并转换成PDF文档。PDF-1.7规范...

weixin_34717961的博客 268

YOLOv11 损失函数进阶:Varifocal Loss 让正负样本精度双升

创建self.alpha = alpha # 正样本权重系数self.gamma = gamma # 聚焦系数self.lambda_reg = lambda_reg # 回归损失权重# 分类损失:Varifocal Classification Loss# 正样本权重:基于预测置信度# 计算 BCE 损失并加权cls_loss = cls_loss.sum() / (cls_true.sum() + 1e-6) # 按正样本数归一化。

m0_71589036的博客 441

使用verilog实现基于FPGA的TDC设计

verilog实现TDC 高精度时间数字转换器概述(TDC) 简介: TDC被用于测量时间间隔,应用在物理研究、飞行时间测量领域等。 本设计使用verilog实现并在xilinx和altera的FPGA上均可实现! 设计中使用到下述几个模块,包括FIFO,COUNT等,在xilinx下也使用到了一些原语等。下面有实现的代码和仿真截图等。 顶层模块设计如下: module top( input wire start, input wire stop, input wire clk, output wire T

QQ_778132974的博客 6254

Python PDF转图片自定义输出

12import os上一篇文章已经介绍过要使用的库,和写代码要用到的思路了。

wuyi的个人博客 799

Xiaojie雷达之路---手把手教你从串口获取雷达原始数据(一)---新建工程(开始)

Hello,大家好,我是Xiaojie,欢迎大家能够和Xiaojie来一起学习毫米波雷达知识,Xiaojie准备连载一个系列的文章---利用串口获取毫米波雷达中的原始数据,本系列文章将从新建工程到最后原始数据显示到PC上进行逐步介绍,这个系列的文章大约是一个4-5篇左右。本篇文章呢,主要讲的是如何新建一个毫米波雷达的工程。

XiaoJie的博客 5810

python怎么输出pdf_python输出pdf文档的实例

python导出pdf,参考诸多资料,发现pdfkit是效果比较好的。故下载后进行了实现,多次失败后终于成功了,现将其中经验总结如下:"""需要安装pdfkit,另外需要安装可执行文件wkhtmltopdf.exe,pdfkit核心命令是调用wkhtmltopdf.exe实现转pdf有三个接口:pdfkit.from_urlpdfkit.from_stringpdfkit.from_file 需要...

weixin_39880301的博客 959

NX二次开发点通过云配准获取相同体

先找到体的参考方向(这个参考方向对于相同体重合之后是相同的),这个时候我们的思路是三个不共线的点确定一个坐标系,然后和绝对方向求转换矩阵。然后获取体的所有边的几何中心,把这些点通过转换矩阵转换之后存起来,再和另外一个体转换之后的点数据作对比,在误差范围内配对点的数量等于体获取点的数量就是相同体

qq_39541524的博客 1646

【前沿】多模态数据时间同步与对齐技术方案

多模态系统时间同步面临硬件差异、传输延迟和时钟漂移等核心挑战。解决方案包括硬件级的GPS授时(μs级)、FPGA同步电路,以及软件级的动态时间规整(DTW)、卡尔曼滤波和Transformer跨模态对齐算法。工程实践中采用滑动窗口缓冲、分布式一致性协议等方法,已在工业质检(误差≤0.1mm)、自动驾驶(延迟<30ms)等场景取得显著效果。未来需解决高动态场景鲁棒性、边缘设备能耗优化等问题,随着TSN和5G URLLC技术的发展,微秒级同步将成为可能。

从技术实践立足,从项目管理方法论延伸思考 1393

【python读取pdf】批量读取pdf中的文字内容并输出为txt文件

参考网上的代码改的,同样增加了批量读取的功能,直接读取目标文件夹内的pdf内容,输出txt的文件名和所读取的pdf名相同。导出的文本是没有分割的,需要后续自行做分词处理。

ZERWW的博客 977

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

python 表格输出到pdf_用python将excel文件中选定的工作表打印为pdf

我需要编写一个python脚本来读取excel文件,找到每个工作表,然后用excel中定义的标准格式将它们打印成pdf。这使我能够找到每个工作表的名称。import xlrdbook = xlrd.open_workbook("myfile.xls")print "Worksheet name(s):", book.sheet_names()这将导致Worksheet name(s): [u'Fo...

weixin_39526872的博客 1320

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

python+ollama本地大模型批量识别PDF,总结摘要以及关键词并输出EXCEL。

这段是处理指定文件夹中的所有PDF文件,并读取PDF识别后的txt文件中的文章信息,提交给本地大模型,我这里使用的qwen2.5:14b,总体上来说,qwen2.5还是好用的,并将结果保存到EXCEL中。,如下是如何处理单个PDF,并设有异常处理,在处理PDF时存在部分乱码,可能是包含有图片格式的问题,故此设置了清洗文本,只保留了可以打印的字符,在提交给大模型进行回答时不受影响,个人没有进行未清洗测试。然而随着AI的兴起,本地大模型的部署,这些成为一种很方便的方法,接下来我将为各位介绍我所使用的方法。

m0_62662762的博客 1万+

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

python自动输出,将ipython输出自动化为pdf

I have a little program that basically does all kinds of statistical calculation and prints out results and charts.At present, a convenient way to get a nice pdf output of my program is to run my code...

weixin_42510201的博客 98

python怎么输出pdf,利用python将pdf输出为txt的实例讲解

一个礼拜前一个同学问我这个事情,由于之前在参加华为的比赛,所以赛后看了一下,据说需要用到pdfminer这个包。于是安装了一下,安装过程很简单:中间也没有任何的报错。至于如何调用,本人也没有很好的研究过pdfminer这个库,于是开始了百度……完全使用python编写。 (适用于2.4或更新版本)解析,分析,并转换成PDF文档。PDF-1.7规范的支持。 (几乎)中日韩语言和垂直书写脚本支持。各种...

weixin_34547167的博客 293

python输出pdf文件_从Python输出文件(最好是PDF)

I've got a Python script (3.5) that will go through a whole battery of tests. The user gets to select which tests get run out of N possible tests. So, the user could run 1 tests up to N tests.Right ...

weixin_39950470的博客 399

python输出pdf文档

python导出pdf,参考诸多资料,发现pdfkit是效果比较好的。故下载后进行了实现,多次失败后终于成功了,现将其中经验总结如下: """ 需要安装pdfkit,另外需要安装可执行文件wkhtmltopdf.exe, pdfkit核心命令是调用wkhtmltopdf.exe实现转pdf 有三个接口: pdfkit.from_url pdfkit.from_string pdfkit.fr...

qq_39314099的博客 6784

python 把pdf输出为png图片

# encoding=UTF-8 import fitz """ 包安装 pip install PyMuPDF """ pdf = fitz.open('./log/send_email.pdf') for cnt in range(0, pdf.page_count): trans = fitz.Matrix(2, 2) # 设置转换比列,数字默认为1,数字越大输出图片越大 png = pdf[0].getPixmap(matrix=trans)

sky0Lan的博客 400

python自动输出_将ipython输出自动化为pdf

I have a little program that basically does all kinds of statistical calculation and prints out results and charts.At present, a convenient way to get a nice pdf output of my program is to run my code...

weixin_39641450的博客 137
上一篇: 构造函数初始化列表和函数内部赋值的区别
下一篇: Pictrue Control和TreeCtrl的拖动
C__Allen
博客等级 码龄18年 12粉丝 25原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值