Forum


Replies: 3   Views: 2799
Problem converting pdf to images
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by avo  · 30-11-2016 - 09:20

Hi,

Wonder if someone can help. I have the following code that I am using to convert a pdf file into image files and then add to my document:

<code>

        //get file data
        $file_data = pathinfo( $file_to_append );

        //before doing any work, check if the file is a PDF. If it it is, converto to image and reset the info for this loop
        //it'll run as an image instead then.
        if ( $file_data['extension'] == "pdf" ) {
                $merger->convert_from_pdf( $file_to_append, $tmp_path, $tmp_counter, $file_data, $merge_options );
        } elseif( in_array( $file_data['extension'], $allowed_images ) ) {
                //is it an image?
                $merger->add_image_to_doc( $file_to_append, $tmp_path, $tmp_counter, $file_data );

</code>

If I use individual image files the code works fine and the images are placed on individual pages. If I use a pdf, the pdf is converted to images but they are all stacked on top of each other on a single page of the word document. Can anyone help with resolving this issue. I did not write the code and the original developer cannot assist.

Many thanks

Mark

Posted by admin  · 30-11-2016 - 10:37

Hello,

That code is not from phpdocx and your user doesn't have any license tied. What program or library are you using?

Regards.

Posted by avo  · 30-11-2016 - 11:18

Hi

I am using phpdocx 3.7 and it is a licenced copy. The php code is the function within my page script that carries out the merging of the images into the document.

Hope that helps

Mark

Posted by admin  · 30-11-2016 - 11:56

Hello,

phpdocx 3.7 doesn't have support to transform PDF to images and these methods of your code: convert_from_pdf, add_image_to_doc, are not from the API of phpdocx; they are custom methods of your project.

For further support and check your project you can purchase tickets on:

http://www.phpdocx.com/support

Regards.