Home  >  Article  >  Backend Development  >  How to convert php pdf to word

How to convert php pdf to word

藏色散人
藏色散人Original
2020-11-25 10:08:294587browse

php How to convert pdf to word: first find a PDF file; then parse the pdf file through PdfParser; finally use "PHPOffice/PHPWord" to convert the pdf into word.

How to convert php pdf to word

The operating environment of this tutorial: Windows 7 system, PHP version 5.6. This method is suitable for all brands of computers.

Recommended: "PHP Video Tutorial"

php converts a pdf file into a word file:

PdfParser (https ://www.pdfparser.org/demo) This is used to parse pdf

PHPOffice/PHPWord (https://github.com/PHPOffice/PHPWord) This is used to convert to word

When word is dumped to xml, the image can exist in base64 encoding, and these encodings are placed in the ba5eb59130347ddcf33292d1909f6483 tag. Replace these base64 encodings with placeholders (${field30} in the code below) and then perform normal processing to display them normally.

Xml code

<w:pict>  
<v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">  
    <v:stroke joinstyle="miter"/>  
    <v:formulas>  
        <v:f eqn="if lineDrawn pixelLineWidth 0"/>  
        <v:f eqn="sum @0 1 0"/>  
        <v:f eqn="sum 0 0 @1"/>  
        <v:f eqn="prod @2 1 2"/>  
        <v:f eqn="prod @3 21600 pixelWidth"/>  
        <v:f eqn="prod @3 21600 pixelHeight"/>  
        <v:f eqn="sum @0 0 1"/>  
        <v:f eqn="prod @6 1 2"/>  
        <v:f eqn="prod @7 21600 pixelWidth"/>  
        <v:f eqn="sum @8 21600 0"/>  
        <v:f eqn="prod @7 21600 pixelHeight"/>  
        <v:f eqn="sum @10 21600 0"/>  
    </v:formulas>  
    <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>  
    <o:lock v:ext="edit" aspectratio="t"/>  
</v:shapetype>  
<w:binData w:name="wordml://03000001.png" xml:space="preserve">${field30}</w:binData>  
<v:shape id="_x0000_i1025" type="#_x0000_t75" alt="" style="width:90.35pt;height:112.75pt">  
<v:imagedata src="wordml://03000001.png" o:href="http://127.0.0.1:8080/bfp/2016/12/30/00000000001.png"/>  
</v:shape>  
</w:pict>

The above is the detailed content of How to convert php pdf to word. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn