pdf


Converting a doc to a pdf in a mvc c# environment


Hi I've got a c# MVC application running under a particular user (app.pool user).
I need to convert a doc or docx file to a pdf.
I thought a good option would be to use libreoffice to fire a process that would start this.
To make life easier for myself (and if libreoffice shouldn't work) I used a batch file.
echo on
SET var1=%2
IF "%var1:~-1%"=="\" SET var1=%var1:~0,-1%
cd %var1%
echo %1
echo %var1%
start /wait "" "C:\Program Files (x86)\LibreOffice 4\program\soffice" -headless -convert-to pdf %1 -outdir %var1%
My code for starting this is as follows.
var ba = #"C:\inetpub\wwwroot\apps\xxxxxxxxx\Services\convert.bat";
fullPath = #"C:\inetpub\wwwroot\apps\xxxxxxxxx\Files\Temp\636295920370843147.doc";
var tempPath = #"C:\inetpub\wwwroot\apps\xxxxxxxxx\Files\Temp";
string command = ba;
//Process.Start(command, fullPath + " " + tempPath);
var processInfo = new ProcessStartInfo("cmd.exe", "/c " + command + " "+ fullPath+ " "+ tempPath);
processInfo.CreateNoWindow = false;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
var process = Process.Start(processInfo);
process.OutputDataReceived += (object sender, DataReceivedEventArgs e) =>
Trace.WriteLine("output>>" + e.Data);
process.BeginOutputReadLine();
process.ErrorDataReceived += (object sender, DataReceivedEventArgs e) =>
Trace.WriteLine("error>>" + e.Data);
process.BeginErrorReadLine();
process.WaitForExit();
Trace.WriteLine("ExitCode: {0}", process.ExitCode.ToString());
process.Close();
This does seem to work manually but when I run the code I can see the whole thing just stalls around the conversion. Looking at the threads and it seems to load the gdiplus.dll which I think is a graphics module which doesn't seem right.
The process though when I copy and paste that into my 'run' box in windows works fine and the pdf is made.
I've checked that the app.pool user has access to both libreoffice and also the folder with the files.
I've ran this as the app.pool user, in the c# it just stalls on the process.WaitForExit();
line. Until I kill the process.
Any ideas?
I've also tried many different ways of executing the soffice conversion. just straight from the c# - libreoffice 4,5.
I've seen some people use libreoffice as a service, is this an option? If so how?
Richard
EDIT
Ah, just changed the app Pool user to myself and now it works, so there is a permissions thing with the standard app pool user. How to find out what....
I added the user into the administrators group on the computer and restarted the machine, then it worked.
It might not be the best solution but after 2 days of trying to get this to work I'm not going to argue.
Richard

Related Links

PDF not building in ATOM on windows using LaTeX
Embedding an active pdf into a webpage?
html to pdf is taking way longer than html to word
Appending PDF to Existing PDF in cold fusion 11
iText is deforming/misspelling Unicode characters in pdf
Extract text from PDF boxes using textbox background colour
Why does my signature revision number increment by 2 (in itext) after detached signing?
From where does the jasperreports engine refer to the fonts from?
How can I print a PDF-file together with all the linked files in it?
Can a name object be an indirect reference in a PDF file?
How to handle indents of very long fo:list-item-labels?
Generating PDF with iText and batik
Printing from Windows to Samba to CUPS-PDF printer gives corrupt pdf output
Is there any PDF field/element that can be used for grouping multiple elements?
Render SSRS .RDL-File to PDF and print it straightly without overviewing it
Creation date 'docProperty' from word docx blank when exporting to pdf

Categories

HOME
date
isabelle
tizen
view
jsrender
jxls
alpha
acquia
mouse
upload
pheatmap
add
google-translate
ssl-client-authentication
handsontable
php-7.1
percona
dynamics-crm-online
amazonsellercentral
scriptcs
microsoft-sync-framework
bootstrap-duallistbox
jaxb2
libuv
vision
kendo-datasource
newline
bcd
binary-data
calibre
pim
libvpx
twitch
hilbert-curve
streamreader
email-templates
botbuilder
firebase-admin
mime
avconv
flickr-api
xml-documentation
parentheses
hibernate-tools
filepicker
komodoedit
colorama
boost-preprocessor
python-cryptography
angular-cache
asp.net-4.5
py2app
persist
blackberry-10
python-stackless
php-internals
wapiti
vhd
operation
remobjects
graph-api-explorer
python-green
neolane
ceil
contenttype
hippomocks
floating-point-precision
mysqltuner
dataservice
batterylevel
padarn
mylyn
specification-pattern
google-email-migration
armcc
errai
wse3.0
netbeans-6.9
php-parser
psi
rfc1123
filtered-index
firefox4
data-driven
yagni
gacutil
scripting-languages
3gp

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App