PDA

View Full Version : QPrinter::PdfFormat html format && Link



patrik08
8th April 2007, 10:00
I search a way to make link active on pdf export from qt.... && on future to make textinput field , combobox like latex
\usepackage[bookmarks=false]{hyperref} to send and validate data to db or email...

Now if i must make a link enable pdf ( manual how-to ecc.. ) i export html file with my qt apps
svn co https://qt-webdav.svn.sourceforge.net/svnroot/qt-webdav/html_editor/ html_editor
&& open html file on openoffice && export to pdf ...

Is here a way to subclass QPrinter and make link active?

The only way i know is xslt html2fop (apache fop processor) to make link ... and now fop can parse xforms standard to make input field...

But i am sure QPrinter not required java to make the same job....




void Edit_html::MakefilePrintPdf()
{
QString fileName = QFileDialog::getSaveFileName(this, "Export PDF",QString(setter.value("LastDir").toString()), "*.pdf");
if (fileName.size() > 1) {
QApplication::setOverrideCursor(QCursor(Qt::WaitCu rsor));
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
if (!fileName.endsWith(".pdf")) {
fileName = fileName+".pdf";
}
QString ultimacartellaaperta = fileName.left(fileName.lastIndexOf("/"))+"/";
setter.setValue("LastDir",ultimacartellaaperta);
printer.setOutputFileName(fileName);
wtext->document()->print(&printer); /* wtext qtextedit */
if (is_file(fileName)) {
QApplication::restoreOverrideCursor();
OpenDesktop(QUrl(fileName));
}
}
QApplication::restoreOverrideCursor();
}



on openoffice 2 pdf export link show like this here....



5 0 obj
<</Type/Annot/Subtype/Link/Border[0 0 0]/Rect[69.5 766 376.4 784.5]/A<</Type/Action/S/URI/URI(http://www.qtcentre.org/component/option,com_weblinks/task,view/catid,14/id,27/)>>
>>
endobj


On latex pdflatex textinput field look like this here....




37 0 obj <<
/Type /Annot
/Rect [567.0667 284.7431 724.9647 298.6908]
/Subtype /Widget /F 4 /T (FIELDNAME) /Q 0 /FT /Tx /BS << /W 1 /S /S >> /MK << /BC [0.85 0.85 0.85] /BG [0.89 0.94 0.95] >> /DA (/Helv 11 Tf 0 0 0 rg ) /DV () /V (VALUEDATAHUMAN) /AA << >>
>> endobj


on attachment the qt pdf output from copy & paste link section qtcentre.org
and same from openoffice

marcel
8th April 2007, 10:38
You cannot subclass QPrinter. At most you can subclass QPrintEngine, but there's little you can do with it.

A tedious solution is to take pdf support from Qt( from QPrinter ) and make your own class
of PDF Export.

Also, if all you want si save some text, you can make you're own PDF Export ( not based on QPrinter ). Just take the text from the QTextEdiot and saver it in pdf. It isn't that hard to add a few fonts to the page resources and text to the content stream.

Regards

patrik08
8th April 2007, 12:37
You cannot subclass QPrinter.
Also, if all you want si save some text, you can make you're own PDF Export ( not based on QPrinter ). Just take the text from the QTextEdiot and saver it in pdf. It isn't that hard to add a few fonts to the page resources and text to the content stream.
Regards

Hmmm... Crazy. Back to latex or hope XSL-FO (http://en.wikipedia.org/wiki/XSL-FO) becomes perfect... ( link have it) now only textinput or combobox must work on XForms (http://en.wikipedia.org/wiki/XForms) .. ;)

qt xhtml import to scribus come bad link .. and not import image... on absolute path!
scribus have all perfect... only import && plugin are all on Python and i know only PHP or c++ qt , perl... :o