PDA

View Full Version : QTextDocument Image resource problem



patrik08
26th July 2007, 23:42
To append Resource on QTextDocument i write on this way:
doc->addResource( QTextDocument::ImageResource, QUrl(filefullpath), QPixmap(filefullpath) );

if file exist..

But on export on other format not HTML i like to export the image as copy to.. on same path from export file.

and QTextImageFormat isValid done only by image on qrc resource file... inside ..
all other is display correct image on (QTextBrowser/QGraphicsItem) but QTextImageFormat Pics is false on export, why? i read only the same QTextDocument.



/* QTextImageFormat Pics */

if (Pics.isValid() && Pics.hasProperty(QTextFormat::ImageName) ) {
/* IMAGE TAG internal external............TAGNR. ENUM 417/418 */
/* SVG convert to png transparent ! / original svg base64 encoded data! xml */
QDomElement inlineimage = createElement("fo:internal-graphic");
const QString hrefadress = Pics.name();
qDebug() << "### image 1 name() " << hrefadress;
/* probe to save on export path */
QFileInfo fimp(hrefadress);
QPixmap lodingimage(hrefadress);

if (!lodingimage.isNull()) {
QString path = imagepathexport;
if (!path.endsWith("/")) {
path.append("/");
}
QDir deop(path);
if (!deop.exists()) {
deop.mkpath(path);
}

QString ext = fimp.completeSuffix();
ext.toUpper();
QByteArray extension;
extension = ext.toAscii();
QPixmap PicCopy(lodingimage);
const QString filepathgo = path+fimp.fileName();
bool ActionSave = PicCopy.save(filepathgo,extension.data(),100);
qDebug() << "### image 2" << filepathgo << " bool->" << ActionSave;
inlineimage.setAttribute("src",fimp.fileName());
inlineimage.setAttribute("height",QString("%1pt").arg(lodingimage.height()));
inlineimage.setAttribute("width",QString("%1pt").arg(lodingimage.width()));
} else {
/* save only url if not load */
}

}

wysota
16th August 2007, 16:28
Can you prepare a minimal compilable example reproducing the problem?