JPG image appears corrupt after HTML2PDF conversion

51 views
Skip to first unread message

Ryan

unread,
Jun 22, 2015, 2:52:43 PM6/22/15
to pdfne...@googlegroups.com
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");
           
}
       
}
   
}
}


Reply all
Reply to author
Forward
0 new messages