static void writeobject(int num, int gen) { fz_error error; fz_obj *obj; fz_obj *type; error = pdf_loadobject(&obj, xref, num, gen); if (error) die(error); /* skip ObjStm and XRef objects */ if (fz_isdict(obj)) { type = fz_dictgets(obj, "Type"); if (fz_isname(type) && !strcmp(fz_toname(type), "ObjStm")) { uselist[num] = 0; fz_dropobj(obj); return; } if (fz_isname(type) && !strcmp(fz_toname(type), "XRef")) { uselist[num] = 0; fz_dropobj(obj); return; } } if (!pdf_isstream(xref, num, gen)) { fprintf(out, "%d %d obj\n", num, gen); fz_fprintobj(out, obj, !doexpand); fprintf(out, "endobj\n\n"); } else { if (doexpand && !pdf_isjpximage(obj)) expandstream(obj, num, gen); else copystream(obj, num, gen); } fz_dropobj(obj); }
static void writeobject(int num, int gen) { fz_obj *obj; fz_obj *type; obj = pdf_load_object(xref, num, gen); /* skip ObjStm and XRef objects */ if (fz_is_dict(obj)) { type = fz_dict_gets(obj, "Type"); if (fz_is_name(type) && !strcmp(fz_to_name(type), "ObjStm")) { uselist[num] = 0; fz_drop_obj(obj); return; } if (fz_is_name(type) && !strcmp(fz_to_name(type), "XRef")) { uselist[num] = 0; fz_drop_obj(obj); return; } } if (!pdf_is_stream(xref, num, gen)) { fprintf(out, "%d %d obj\n", num, gen); fz_fprint_obj(out, obj, doexpand == 0); fprintf(out, "endobj\n\n"); } else { int dontexpand = 0; if (doexpand != 0 && doexpand != expand_all) { fz_obj *o; if ((o = fz_dict_gets(obj, "Type"), !strcmp(fz_to_name(o), "XObject")) && (o = fz_dict_gets(obj, "Subtype"), !strcmp(fz_to_name(o), "Image"))) dontexpand = !(doexpand & expand_images); if (o = fz_dict_gets(obj, "Type"), !strcmp(fz_to_name(o), "Font")) dontexpand = !(doexpand & expand_fonts); if (o = fz_dict_gets(obj, "Type"), !strcmp(fz_to_name(o), "FontDescriptor")) dontexpand = !(doexpand & expand_fonts); if ((o = fz_dict_gets(obj, "Length1")) != NULL) dontexpand = !(doexpand & expand_fonts); if ((o = fz_dict_gets(obj, "Length2")) != NULL) dontexpand = !(doexpand & expand_fonts); if ((o = fz_dict_gets(obj, "Length3")) != NULL) dontexpand = !(doexpand & expand_fonts); if (o = fz_dict_gets(obj, "Subtype"), !strcmp(fz_to_name(o), "Type1C")) dontexpand = !(doexpand & expand_fonts); if (o = fz_dict_gets(obj, "Subtype"), !strcmp(fz_to_name(o), "CIDFontType0C")) dontexpand = !(doexpand & expand_fonts); } if (doexpand && !dontexpand && !pdf_is_jpx_image(ctx, obj)) expandstream(obj, num, gen); else copystream(obj, num, gen); } fz_drop_obj(obj); }