Forum


Replies: 3   Views: 2957
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