Q:
After HTML2PDF conversion image is corrupted, or mangled.
A:
HTML2PDF conversion sometimes incorrectly adds an SMask to JPEG images in the html. You need to remove this SMask from these images manually. The following code will run through all jpeg images and remove. Ideally though, you can pinpoint which ones are the problem one, say certain page, and only remove those, as some jpeg images actually do need the SMask.
`
SDF::SDFDoc* cos_doc = doc.GetSDFDoc();
int num_objs = cos_doc->XRefSize();
for(int i=1; i<num_objs; ++i)
{
SDF::Obj* obj = cos_doc->GetObj(i);
if(obj && !obj->IsFree() && obj->IsStream())
{
// Process only images
SDF::Obj* type = obj->FindObj(“Subtype”);
if (type && type->IsName() && !strcmp(type->GetName(), “Image”))
{
SDF::Obj* flt = obj->FindObj(“Filter”);
if(flt && flt->IsName() && !strcmp(type->GetName(), “DCTDecode”))
{
obj->Erase(“SMask”);
}
}
}
}
`