本文整理汇总了C++中pdf_new_name函数的典型用法代码示例。如果您正苦于以下问题:C++ pdf_new_name函数的具体用法?C++ pdf_new_name怎么用?C++ pdf_new_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pdf_new_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_cspace_sRGB
/* Approximated sRGB */
static pdf_obj *
create_cspace_sRGB (png_structp png_ptr, png_infop info_ptr)
{
pdf_obj *colorspace;
pdf_obj *cal_param;
png_byte color_type;
color_type = png_get_color_type(png_ptr, info_ptr);
/* Parameters taken from PNG spec. section 4.2.2.3. */
cal_param = make_param_Cal(color_type,
2.2,
0.3127, 0.329,
0.64, 0.33, 0.3, 0.6, 0.15, 0.06);
if (!cal_param)
return NULL;
colorspace = pdf_new_array();
switch (color_type) {
case PNG_COLOR_TYPE_RGB:
case PNG_COLOR_TYPE_RGB_ALPHA:
case PNG_COLOR_TYPE_PALETTE:
pdf_add_array(colorspace, pdf_new_name("CalRGB"));
break;
case PNG_COLOR_TYPE_GRAY:
case PNG_COLOR_TYPE_GRAY_ALPHA:
pdf_add_array(colorspace, pdf_new_name("CalGray"));
break;
}
pdf_add_array(colorspace, cal_param);
return colorspace;
}
示例2: get_rendering_intent
/*
* sRGB:
*
* If sRGB chunk is present, cHRM and gAMA chunk must be ignored.
*
*/
static pdf_obj *
get_rendering_intent (png_structp png_ptr, png_infop info_ptr)
{
pdf_obj *intent;
int srgb_intent;
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sRGB) &&
png_get_sRGB (png_ptr, info_ptr, &srgb_intent)) {
switch (srgb_intent) {
case PNG_sRGB_INTENT_SATURATION:
intent = pdf_new_name("Saturation");
break;
case PNG_sRGB_INTENT_PERCEPTUAL:
intent = pdf_new_name("Perceptual");
break;
case PNG_sRGB_INTENT_ABSOLUTE:
intent = pdf_new_name("AbsoluteColorimetric");
break;
case PNG_sRGB_INTENT_RELATIVE:
intent = pdf_new_name("RelativeColorimetric");
break;
default:
WARN("%s: Invalid value in PNG sRGB chunk: %d", PNG_DEBUG_STR, srgb_intent);
intent = NULL;
}
} else
intent = NULL;
return intent;
}
示例3: create_encoding_resource
/* Creates the PDF Encoding entry for the encoding.
* If baseenc is non-null, it is used as BaseEncoding entry.
*/
static pdf_obj *
create_encoding_resource (pdf_encoding *encoding, pdf_encoding *baseenc)
{
pdf_obj *differences;
ASSERT(encoding);
ASSERT(!encoding->resource);
differences = make_encoding_differences(encoding->glyphs,
baseenc ? baseenc->glyphs : NULL,
encoding->is_used);
if (differences) {
pdf_obj *resource = pdf_new_dict();
if (baseenc)
pdf_add_dict(resource, pdf_new_name("BaseEncoding"),
pdf_link_obj(baseenc->resource));
pdf_add_dict(resource, pdf_new_name("Differences"), differences);
return resource;
} else {
/* Fix a bug with the MinionPro package using MnSymbol fonts
* in its virtual fonts:
*
* Some font may have font_id even if no character is used.
* For example, suppose that a virtual file A.vf uses two
* other fonts, B and C. Even if only characters of B are used
* in a DVI document, C will have font_id too.
* In this case, both baseenc and differences can be NULL.
*
* Actually these fonts will be ignored in pdffont.c.
*/
return baseenc ? pdf_link_obj(baseenc->resource) : NULL;
}
}
示例4: create_soft_mask
static pdf_obj *
create_soft_mask (png_structp png_ptr, png_infop info_ptr,
png_bytep image_data_ptr, png_uint_32 width, png_uint_32 height)
{
pdf_obj *smask, *dict;
png_bytep smask_data_ptr;
png_bytep trans;
int num_trans;
png_uint_32 i;
if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ||
!png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, NULL)) {
WARN("%s: PNG does not have valid tRNS chunk but tRNS is requested.", PNG_DEBUG_STR);
return NULL;
}
smask = pdf_new_stream(STREAM_COMPRESS);
dict = pdf_stream_dict(smask);
smask_data_ptr = (png_bytep) NEW(width*height, png_byte);
pdf_add_dict(dict, pdf_new_name("Type"), pdf_new_name("XObject"));
pdf_add_dict(dict, pdf_new_name("Subtype"), pdf_new_name("Image"));
pdf_add_dict(dict, pdf_new_name("Width"), pdf_new_number(width));
pdf_add_dict(dict, pdf_new_name("Height"), pdf_new_number(height));
pdf_add_dict(dict, pdf_new_name("ColorSpace"), pdf_new_name("DeviceGray"));
pdf_add_dict(dict, pdf_new_name("BitsPerComponent"), pdf_new_number(8));
for (i = 0; i < width*height; i++) {
png_byte idx = image_data_ptr[i];
smask_data_ptr[i] = (idx < num_trans) ? trans[idx] : 0xff;
}
pdf_add_stream(smask, (char *)smask_data_ptr, width*height);
RELEASE(smask_data_ptr);
return smask;
}
示例5: pdf_flush_font
static void
pdf_flush_font (pdf_font *font)
{
char *fontname, *uniqueTag;
if (!font) {
return;
}
if (font->resource && font->reference) {
if (font->subtype != PDF_FONT_FONTTYPE_TYPE3) {
if (pdf_font_get_flag(font, PDF_FONT_FLAG_NOEMBED)) {
pdf_add_dict(font->resource,
pdf_new_name("BaseFont"), pdf_new_name(font->fontname));
if (font->descriptor) {
pdf_add_dict(font->descriptor,
pdf_new_name("FontName"), pdf_new_name(font->fontname));
}
} else {
if (!font->fontname) {
ERROR("Undefined in fontname... (%s)", font->ident);
}
fontname = NEW(7+strlen(font->fontname)+1, char);
uniqueTag = pdf_font_get_uniqueTag(font);
sprintf(fontname, "%6s+%s", uniqueTag, font->fontname);
pdf_add_dict(font->resource,
pdf_new_name("BaseFont"), pdf_new_name(fontname));
if (font->descriptor) {
pdf_add_dict(font->descriptor,
pdf_new_name("FontName"), pdf_new_name(fontname));
}
RELEASE(fontname);
}
if (font->descriptor) {
pdf_add_dict(font->resource,
pdf_new_name("FontDescriptor"), pdf_ref_obj(font->descriptor));
}
}
}
if (font->resource)
pdf_release_obj(font->resource);
if (font->descriptor)
pdf_release_obj(font->descriptor);
if (font->reference)
pdf_release_obj(font->reference);
font->reference = NULL;
font->resource = NULL;
font->descriptor = NULL;
return;
}
示例6: pdfout_data_scalar_to_pdf_name
pdf_obj *
pdfout_data_scalar_to_pdf_name (fz_context *ctx, pdf_document *doc,
pdfout_data *scalar)
{
const char *s = scalar_get_string (ctx, scalar);
return pdf_new_name (ctx, doc, s);
}
示例7: pdf_set_annot_icon_name
void
pdf_set_annot_icon_name(fz_context *ctx, pdf_annot *annot, const char *name)
{
pdf_document *doc = annot->page->doc;
check_allowed_subtypes(ctx, annot, PDF_NAME_Name, icon_name_subtypes);
pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Name, pdf_new_name(ctx, doc, name));
}
示例8: pdf_parse_stm_obj
pdf_obj *
pdf_parse_stm_obj(pdf_document *doc, fz_stream *file, pdf_lexbuf *buf)
{
pdf_token tok;
fz_context *ctx = file->ctx;
tok = pdf_lex(file, buf);
switch (tok)
{
case PDF_TOK_OPEN_ARRAY:
return pdf_parse_array(doc, file, buf);
case PDF_TOK_OPEN_DICT:
return pdf_parse_dict(doc, file, buf);
case PDF_TOK_NAME: return pdf_new_name(doc, buf->scratch); break;
case PDF_TOK_REAL: return pdf_new_real(doc, buf->f); break;
case PDF_TOK_STRING: return pdf_new_string(doc, buf->scratch, buf->len); break;
case PDF_TOK_TRUE: return pdf_new_bool(doc, 1); break;
case PDF_TOK_FALSE: return pdf_new_bool(doc, 0); break;
case PDF_TOK_NULL: return pdf_new_null(doc); break;
case PDF_TOK_INT: return pdf_new_int(doc, buf->i); break;
default: fz_throw(ctx, FZ_ERROR_GENERIC, "unknown token in object stream");
}
return NULL; /* Stupid MSVC */
}
示例9: pdf_new_page_label
void pdf_new_page_label (pdf_file_handle pdf_file,
int page_index,
int base,
int count,
char style,
char *prefix)
{
struct pdf_obj *label_dict;
char style_str [2] = { style, '\0' };
if (! pdf_file->page_label_tree)
{
pdf_file->page_label_tree = pdf_new_name_tree (pdf_file, 1);
}
label_dict = pdf_new_obj (PT_DICTIONARY);
if (style)
pdf_set_dict_entry (label_dict, "S", pdf_new_name (style_str));
if (prefix)
pdf_set_dict_entry (label_dict, "P", pdf_new_string (prefix));
if (base > 1)
pdf_set_dict_entry (label_dict, "St", pdf_new_integer (base));
pdf_add_number_tree_element (pdf_file->page_label_tree,
page_index,
label_dict);
}
示例10: pdf_to_utf8_name
pdf_obj *
pdf_to_utf8_name(pdf_document *doc, pdf_obj *src)
{
char *buf = pdf_to_utf8(doc, src);
pdf_obj *dst = pdf_new_name(doc, buf);
fz_free(doc->ctx, buf);
return dst;
}
示例11: pdf_to_utf8_name
pdf_obj *
pdf_to_utf8_name(fz_context *ctx, pdf_document *doc, pdf_obj *src)
{
char *buf = pdf_to_utf8(ctx, doc, src);
pdf_obj *dst = pdf_new_name(ctx, doc, buf);
fz_free(ctx, buf);
return dst;
}
示例12: Type0Font_set_ToUnicode
void
Type0Font_set_ToUnicode (Type0Font *font, pdf_obj *cmap_ref)
{
ASSERT(font);
pdf_add_dict(font->fontdict,
pdf_new_name("ToUnicode"), cmap_ref);
}
示例13: create_cspace_Indexed
/*
* Set up Indexed ColorSpace for color-type PALETTE:
*
* PNG allows only RGB color for base color space. If gAMA and/or cHRM
* chunk is available, we can use CalRGB color space instead of DeviceRGB
* for base color space.
*
*/
static pdf_obj *
create_cspace_Indexed (png_structp png_ptr, png_infop info_ptr)
{
pdf_obj *colorspace;
pdf_obj *base, *lookup;
png_byte *data_ptr;
png_colorp plte;
int num_plte, i;
if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE) ||
!png_get_PLTE(png_ptr, info_ptr, &plte, &num_plte)) {
WARN("%s: PNG does not have valid PLTE chunk.", PNG_DEBUG_STR);
return NULL;
}
/* Order is important. */
colorspace = pdf_new_array ();
pdf_add_array(colorspace, pdf_new_name("Indexed"));
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_iCCP))
base = create_cspace_ICCBased(png_ptr, info_ptr);
else {
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sRGB))
base = create_cspace_sRGB(png_ptr, info_ptr);
else
base = create_cspace_CalRGB(png_ptr, info_ptr);
}
if (!base)
base = pdf_new_name("DeviceRGB");
pdf_add_array(colorspace, base);
pdf_add_array(colorspace, pdf_new_number(num_plte-1));
data_ptr = NEW(num_plte*3, png_byte);
for (i = 0; i < num_plte; i++) {
data_ptr[3*i] = plte[i].red;
data_ptr[3*i+1] = plte[i].green;
data_ptr[3*i+2] = plte[i].blue;
}
lookup = pdf_new_string(data_ptr, num_plte*3);
RELEASE(data_ptr);
pdf_add_array(colorspace, lookup);
return colorspace;
}
示例14: pdf_create_page
pdf_page *
pdf_create_page(pdf_document *doc, fz_rect mediabox, int res, int rotate)
{
pdf_page *page = NULL;
pdf_obj *pageobj;
float userunit = 1;
fz_context *ctx = doc->ctx;
fz_matrix ctm, tmp;
fz_rect realbox;
page = fz_malloc_struct(ctx, pdf_page);
fz_try(ctx)
{
page->resources = NULL;
page->contents = NULL;
page->transparency = 0;
page->links = NULL;
page->annots = NULL;
page->me = pageobj = pdf_new_dict(doc, 4);
pdf_dict_puts_drop(pageobj, "Type", pdf_new_name(doc, "Page"));
page->mediabox.x0 = fz_min(mediabox.x0, mediabox.x1) * userunit;
page->mediabox.y0 = fz_min(mediabox.y0, mediabox.y1) * userunit;
page->mediabox.x1 = fz_max(mediabox.x0, mediabox.x1) * userunit;
page->mediabox.y1 = fz_max(mediabox.y0, mediabox.y1) * userunit;
pdf_dict_puts_drop(pageobj, "MediaBox", pdf_new_rect(doc, &page->mediabox));
/* Snap page->rotate to 0, 90, 180 or 270 */
if (page->rotate < 0)
page->rotate = 360 - ((-page->rotate) % 360);
if (page->rotate >= 360)
page->rotate = page->rotate % 360;
page->rotate = 90*((page->rotate + 45)/90);
if (page->rotate > 360)
page->rotate = 0;
pdf_dict_puts_drop(pageobj, "Rotate", pdf_new_int(doc, page->rotate));
fz_pre_rotate(fz_scale(&ctm, 1, -1), -page->rotate);
realbox = page->mediabox;
fz_transform_rect(&realbox, &ctm);
fz_pre_scale(fz_translate(&tmp, -realbox.x0, -realbox.y0), userunit, userunit);
fz_concat(&ctm, &ctm, &tmp);
page->ctm = ctm;
/* Do not create a Contents, as an empty Contents dict is not
* valid. See Bug 694712 */
}
fz_catch(ctx)
{
pdf_drop_obj(page->me);
fz_free(ctx, page);
fz_rethrow_message(ctx, "Failed to create page");
}
return page;
}
示例15: create_cspace_ICCBased
static pdf_obj *
create_cspace_ICCBased (png_structp png_ptr, png_infop info_ptr)
{
pdf_obj *colorspace;
int csp_id, colortype;
png_byte color_type;
png_charp name;
int compression_type; /* Manual page for libpng does not
* clarify whether profile data is inflated by libpng.
*/
#if PNG_LIBPNG_VER_MINOR < 5
png_charp profile;
#else
png_bytep profile;
#endif
png_uint_32 proflen;
if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_iCCP) ||
!png_get_iCCP(png_ptr, info_ptr, &name, &compression_type, &profile, &proflen))
return NULL;
color_type = png_get_color_type(png_ptr, info_ptr);
if (color_type & PNG_COLOR_MASK_COLOR) {
colortype = PDF_COLORSPACE_TYPE_RGB;
#if 0
alternate = create_cspace_CalRGB(png_ptr, info_ptr);
#endif
} else {
colortype = PDF_COLORSPACE_TYPE_GRAY;
#if 0
alternate = create_cspace_CalGray(png_ptr, info_ptr);
#endif
}
#if 0
if (alternate)
pdf_add_dict(dict, pdf_new_name("Alternate"), alternate);
#endif
if (iccp_check_colorspace(colortype, profile, proflen) < 0)
colorspace = NULL;
else {
csp_id = iccp_load_profile(name, profile, proflen);
if (csp_id < 0) {
colorspace = NULL;
} else {
colorspace = pdf_get_colorspace_reference(csp_id);
}
}
/* Rendering intent ... */
return colorspace;
}