int ReadXMLAndWriteToPdf(string XMLFile, string DirDest) { unsigned int index_sec = 0; if ((XMLFile != "") && (DirDest != "")) { CMarkup xml; char* ch_sec = ""; wstring wstrXML(XMLFile.begin(), XMLFile.end()); try { xml.Load(wstrXML); xml.FindElem(); xml.IntoElem(); xml.FindElem(MCD_T("img2PDF")); xml.IntoElem(); dreamsys::DreamSysPDF pdf("", ""); while (xml.FindElem(MCD_T("Tiff"))) { wstring csName = xml.GetAttribName(0); if (csName.length() == 0) break; wstring str_path_ = xml.GetAttrib(csName); string str_path(str_path_.begin(), str_path_.end()); string headerf = str_path.substr(str_path.find_last_of("."), str_path.length()); pdf.addSection(ch_sec); if (stricmp(headerf.c_str(), ".jpg") == 0) pdf.addImagePage(index_sec, TYPE_JPG, str_path); if (stricmp(headerf.c_str(), ".bmp") == 0) pdf.addImagePage(index_sec, TYPE_BMP, str_path); if (stricmp(headerf.c_str(), ".tif") == 0) pdf.addImagePage(index_sec, TYPE_TIFF, str_path); ++index_sec; } int error = pdf.save(DirDest); return error; } catch (...) { return -1; } } return 0; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)