Qt-interest Archive, March 2008
Document generation
Message 1 in thread
Hi all!!
I need to generate *.doc and/or *.pdf files from plain text.
Do you know if Qt provides tool for this purpose??
Do you know an easy way to do it?
Lot of thanks!!!!
--
[ signature omitted ]
Message 2 in thread
Also I could generate *.rtf files, and generate pdf an doc from rtf.
Cheers!!
On Tue, Mar 11, 2008 at 11:59 AM, | pedro mateo || <pedrolmn@xxxxxxxxx>
wrote:
> Hi all!!
>
> I need to generate *.doc and/or *.pdf files from plain text.
> Do you know if Qt provides tool for this purpose??
> Do you know an easy way to do it?
>
> Lot of thanks!!!!
>
> --
> Pedro Luis Mateo Navarro || pedrolmn@xxxxxxxxx _ pedromateo@xxxxxxxxx
> > _phone: (+34) 626 14 29 33 or (+34) 968 39 82 58
> > _web: www.pedromana.com
> > _msn: pedrolmn@xxxxxxxxxxx
--
[ signature omitted ]
Message 3 in thread
Pedro Mateo wrote:
> I need to generate *.doc and/or *.pdf files from plain text.
There is no way to produce *.doc from Qt without using a 3rd party
library or the MS Office ActiveX interface and coding it manually. You
should, however, be able to produce PDF by creating a QTextDocument.
Set the plain text in the document (setPlainText) and use the Print
function to send it to a QPrinter. QPrinter uses PDF by default when
configured to print to a file.
Rob
Message 4 in thread
Bachrach, Robert L a écrit :
> Pedro Mateo wrote:
> > I need to generate *.doc and/or *.pdf files from plain text.
>
> There is no way to produce *.doc from Qt without using a 3rd party
> library or the MS Office ActiveX interface and coding it manually.
> You should, however, be able to produce PDF by creating a
> QTextDocument. Set the plain text in the document (setPlainText) and
> use the Print function to send it to a QPrinter. QPrinter uses PDF by
> default when configured to print to a file.
>
> Rob
hi,
maybe this can help?...
here piece of code I wrote to generate pdf from a xml document (this
work actually with Qt434)
so... you could put plaintext in xml class
QTextDocument::setPlainText ( const QString & /text/ ),
you save it in a xml file or modify api of this function to replace
pPubliURL by QTextDocument.
Why did I do this and not simply printed it using pdf configuration of
printer?
because I nedded to control header and footer, new page,etc... so use
xslt transformation file (lStyleFile) to control this.
/******************************************************************************
* Compile a xml file to create a pdf.
*
* @param pPubliFile the xml file
* @param pPDFFile the output pdf file.
******************************************************************************/
bool MyReportPublishingAction::compile( const QString& pPubliURL, const
QString& pPDFURL )
{
//** Retrieves the tools dir
QString lPDFCompilerDir = MyEnvironment::getSystemDirPath(
MyEnvironment::eToolsDir, true );
//** Initializes the PDF compiler full path
QString lPDFCompilerExe = lPDFCompilerDir +
MyApplication::get()->msPDFExePath;
//** Initializes the XSL file full path (fo stylesheet)
QString lStyleFile = MyEnvironment::getSystemDirPath(
MyEnvironment::eResourcesDir, true );
lStyleFile +=
MyEnvironment::cSystemDirNames[MyEnvironment::eDocStyleSheetDir];
lStyleFile += QString(QDir::separator());
lStyleFile += MyApplication::get()->msPdfTransformationFile;
//** Backups the current dir and sets the current dir to the PDF
compiler dir
//** in order to resolve path troubleshooting
QDir lCurrentDir = QDir::current();
QDir::setCurrent( lPDFComilerDir );
//** Initializes the process
QProcess lProcess ( NULL );
lProcess.setProcessChannelMode(QProcess::MergedChannels);
QStringList lArguments;
lArguments << "-xslt" << pPubliURL << lStyleFile << "-pdf" << pPDFURL;
// set application busy before probably long operation
MyApplication::get()->setBusy( true );
//** Executes the transformation Xml2PDF
bool lResult = false;
if
( lProcess.execute( lPDFCompilerExe, lArguments ) ==
QProcess::NormalExit )
{
lResult = true;
}
MyApplication::get()->setBusy( false );
//** Restores the current dir
QDir::setCurrent( lCurrentDir.absolutePath() );
return lResult;
}