Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8844211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:25:45+00:00 2026-06-14T11:25:45+00:00

I am using COM to convert dynamically created word docx to PDFs. Everything is

  • 0

I am using COM to convert dynamically created word docx to PDFs. Everything is working perfectly, but our c:\windows\temp\ directory is getting extremely large (and we have limited disk space on our C drive). Below is the code I am using to generate the PDF. Is there a way to delete the temp file that gets added to the system’s temp directory after the file is closed? In addition, after the word doc is converted to pdf, we no longer need it (so it doesn’t matter if deleting the tmp file corrupts the word doc).

 /Word Doc to PDF using Com
ini_set("com.allow_dcom","true");

try{
    $word = new com('word.application');
}
catch (com_exception $e)
{
    $nl = "<br />";
    echo $e->getMessage() . $nl;
    echo $e->getCode() . $nl;
    echo $e->getTraceAsString();
    echo $e->getFile() . " LINE: " . $e->getLine();
    $word->Quit();
    $word = null;
    die;

}

$word->Visible = 0; //don't open word gui on server
$word->DisplayAlerts = 0; //don't allow any alerts to open 
//open doc
try{
    $doc = $word->Documents->Open(DOC_LOCATION . "temp_doc/" .  $filename . ".docx");
}
catch (com_exception $e)
{
    $nl = "<br />";
    echo $e->getMessage() . $nl;
    echo $e->getCode() . $nl;
    echo $e->getFile() . " LINE: " . $e->getLine();
    $word->Quit();
    $word = null;
    die;
}
try{
    $doc->ExportAsFixedFormat(DOC_LOCATION . "temp_pdf/" . $filename . ".pdf", 17, false, 0, 0, 0, 0, 7, true, true, 2, true, true, false);

}
catch (com_exception $e)
{
    $nl = "<br />";
    echo $e->getMessage() . $nl;
    echo $e->getCode() . $nl;
    echo $e->getTraceAsString();
    echo $e->getFile() . " LINE: " . $e->getLine();
    $word->Quit();
    $word = null;
    die;
}
$word->Quit();
$word = null;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:25:47+00:00Added an answer on June 14, 2026 at 11:25 am

    Don’t say what version, but for XP- you can use a simple batch file to delete the files in \Documents and Settings\USER\Local Settings\temp\. Example:

    C:
    cd \Documents and Settings\USER\Local Settings\Temp
    attrib -R -S -H *.* /S /D
    DEL /S /F /Q *.*
    

    Modify accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following library https://github.com/Leonidas-from-XIV/node-xml2js To convert XML to JSON. After conversion console.log
I know the string foobar generates the SHA-256 hash c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2 using http://hash.online-convert.com/sha256-generator However the
I'm using this script: http://www.codeproject.com/Articles/11902/Convert-HTML-to-Plain-Text To convert some outlook HTML to plain text. It
I am converting a codeblock from C# to VB.NET using the http://www.developerfusion.com/tools/convert/csharp-to-vb/ All is
I tried to convert a Chrome extenstion to Firefox using this tool http://www.extensionfactory.com/labs/conversion/ and
i currently have highcharts realtime graph working on a browser (e.g. http://www.highcharts.com/demo/dynamic-update ), but
I am trying to retrieve Tiff image data through COM using a StringBuilder but
Using https://github.com/AndreyNikiforov/vault2git I was able to convert a Vault repo to Git and then
Currently I am trying to convert String^ to std::string using marshal_as function (Link: http://msdn.microsoft.com/en-us/library/bb384865.aspx
I am using com.lowagie.text.xml.SAXiTextHandler to convert XML to PDF using iText(v - 2.1.7). I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.