7 Replies - 1132 Views - Last Post: 16 January 2011 - 02:41 PM Rate Topic: -----

#1 megglz  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 11
  • View blog
  • Posts: 414
  • Joined: 22-August 08

issues including a file in a different folder

Posted 15 January 2011 - 08:21 AM

I have the following file I want to include PDFMerge with

<?php
require_once("../../config.php");
global $CFG, $COURSE;
require_once($CFG->libdir . '/blocklib.php');
require_once($CFG->libdir . '/dmllib.php');
require_once($CFG->libdir.'/tcpdf/tcpdf.php');
require_once($CFG->libdir.'/tcpdf/tcpdfprotection.php');
require_once($CFG->dirroot."/course/lib.php");
require_once($CFG->dirroot .'/blocks/digital_notary/fpdi/fpdi.php');
include($CFG->dirroot .'/blocks/digital_notary/api.php');

echo "hi";
?>



When I run this page, it echoes "hi".

When I add in

include($CFG->dirroot .'/blocks/digital_notary/PDFMerger/PDFMerger.php');



to the list, and run the page. "hi" no longer appears. I am not sure why the script is having issues with PDFMerger alone.

Does anyone have any easy way I can merge pdf's together in php? I am using TCPDF to create a new pdf and I want to merge it with an existing one, then delete the pdf created by TCPDF.

Is This A Good Question/Topic? 0
  • +

Replies To: issues including a file in a different folder

#2 hugoh  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 11
  • Joined: 14-January 11

Re: issues including a file in a different folder

Posted 15 January 2011 - 08:33 AM

TCPDF is very good, I have used it and it works perfectly.

I have never had to merge pdf files with PHP, but here is a link to a tutorial to do this. I hope you find it useful.

Merge PDFs with PHP
Was This Post Helpful? 1
  • +
  • -

#3 megglz  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 11
  • View blog
  • Posts: 414
  • Joined: 22-August 08

Re: issues including a file in a different folder

Posted 15 January 2011 - 11:17 AM

That is what I'm using already and it works independently of my project but won't work within the project.
Was This Post Helpful? 0
  • +
  • -

#4 hugoh  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 11
  • Joined: 14-January 11

Re: issues including a file in a different folder

Posted 15 January 2011 - 11:39 AM

Why don't you try to validate if the file exists before including it?

$pdf_merge_location = $CFG->dirroot .'/blocks/digital_notary/PDFMerger/PDFMerger.php';
if ( file_exists($pdf_merge_location) ) {
    include $pdf_merge_location;
} else {
    echo "PDF Merge was not found!";
}



Just to make sure the file is in the path you are specifying.

Also, do you have all the files that PDFMerger.php needs to work in a path where it can find them?

This post has been edited by hugoh: 15 January 2011 - 11:49 AM

Was This Post Helpful? 1
  • +
  • -

#5 megglz  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 11
  • View blog
  • Posts: 414
  • Joined: 22-August 08

Re: issues including a file in a different folder

Posted 15 January 2011 - 12:51 PM

Yes, so that is why I am not sure why it's not working. I am trying TCPDF and FPDI for now.
Was This Post Helpful? 0
  • +
  • -

#6 hugoh  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 11
  • Joined: 14-January 11

Re: issues including a file in a different folder

Posted 15 January 2011 - 02:14 PM

You are requiring fpdi.php script, which is being called also from PDFMerge.php

The problem here is one of the files you are including or requiring, we need to test one by one. Start with the following code and test, then add another file and test again. Do this until you find the file that is causing the problem.

<?php
require_once("../../config.php");
global $CFG, $COURSE;
include($CFG->dirroot .'/blocks/digital_notary/PDFMerger/PDFMerger.php');
echo "hi";
?>


This post has been edited by hugoh: 15 January 2011 - 02:15 PM

Was This Post Helpful? 1
  • +
  • -

#7 megglz  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 11
  • View blog
  • Posts: 414
  • Joined: 22-August 08

Re: issues including a file in a different folder

Posted 16 January 2011 - 02:01 PM

I have the pdf's merging now with tcpdf and fpdi :)

HOWEVER... I am not sure if it's correctly allowing me to do what I want..

(I have a loop where I want to create a pdf, merge with another pdf, then erase the temporarily created one). It only seems to do it for the first file in the loop, but then doesnt erase the temporary one (I am using unlink($filepath) to erase).

This is the error I get in the script

TCPDF ERROR: </strong>Cannot access protected property MyPDFLib:$k / Undefined property: MyPDFLib::$k



I've googled it but to no avail. :/

This post has been edited by megglz: 16 January 2011 - 02:04 PM

Was This Post Helpful? 0
  • +
  • -

#8 hugoh  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 11
  • Joined: 14-January 11

Re: issues including a file in a different folder

Posted 16 January 2011 - 02:41 PM

That is right, unlink() is the function to erase a file.

Can you paste your code? In that way I can recreate the problem and help you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1