コード例 #1
0
	char *PDFTextWordInterop::getFontName()
	{
		if(_textWord != NULL)
		{
			TextWord *word = (TextWord *)_textWord;
			GString *fontName = word->getFontName();
			return fontName->getCString();
		}
		else if(_wordList != NULL)
		{
			TextWordList *wordList =(TextWordList *)_wordList;
			TextWord *word = wordList->get(_currentWord);
			if(word != NULL)
			{
				GString *fontName = word->getFontName();
				return fontName->getCString();
			}
		}
		return NULL;
	}
コード例 #2
0
static void setGlobalParameter(const char* type, const char* arg1, const char* arg2 = NULL) {
	GString line;
	line.append(type);
	line.append(" ");
	line.append(arg1);
	if (arg2 != NULL) {
		line.append(" ");
		line.append(arg2);
	}
	GString name("BepdfApplication");
	globalParams->parseLine(line.getCString(), &name, 0);
}
コード例 #3
0
ファイル: page.cpp プロジェクト: serghei/kde3-kdegraphics
const QString KPDFPage::getText( const NormalizedRect & rect ) const
{
    if ( !m_text )
        return QString::null;
    int left = (int)( rect.left * m_width ),
        top = (int)( rect.top * m_height ),
        right = (int)( rect.right * m_width ),
        bottom = (int)( rect.bottom * m_height );
    GString * text = m_text->getText( left, top, right, bottom );
    QString result = QString::fromUtf8( text->getCString() );
    delete text;
    return result; 
}
コード例 #4
0
Font::Font(const GfxState *state, double size)
{
    if ( size<1 ) kdDebug(30516) << "very small font size=" << size << endl;
    _pointSize = qRound(size);

    GfxRGB rgb;
    state->getFillRGB(&rgb);
    _color = toColor(rgb);

    GfxFont *font = state->getFont();
    GString *gname = (font ? font->getName() : 0);
    QString name = (gname ? gname->getCString() : 0);
//    kdDebug(30516) << "font: " << name << endl;
    name = name.section('+', 1, 1).lower();
    if ( name.isEmpty() ) name = "##dummy"; // dummy name
    init(name);
}
コード例 #5
0
ファイル: XPDFRenderer.cpp プロジェクト: 199901/Sankore-3.1
QString XPDFRenderer::title() const
{
    if (isValid())
    {
        Object pdfInfo;
        mDocument->getDocInfo(&pdfInfo);
        if (pdfInfo.isDict())
        {
            Object title;
            Dict *infoDict = pdfInfo.getDict();
            if (infoDict->lookup((char*)"Title", &title)->isString())
            {
                GString *gstring = title.getString();
                return QString(gstring->getCString());
            }
        }
    }

    return QString();
}
コード例 #6
0
KPDFLink * KPDFOutputDev::generateLink( LinkAction * a )
// note: this function is called when processing a page, when the MUTEX is already LOCKED
{
    KPDFLink * link = NULL;
    if ( a ) switch ( a->getKind() )
    {
        case actionGoTo:
            {
            LinkGoTo * g = (LinkGoTo *) a;
            // ceate link: no ext file, namedDest, object pointer
            link = new KPDFLinkGoto( QString::null, decodeViewport( g->getNamedDest(), g->getDest() ) );
            }
            break;

        case actionGoToR:
            {
            LinkGoToR * g = (LinkGoToR *) a;
            // copy link file
            const char * fileName = g->getFileName()->getCString();
            // ceate link: fileName, namedDest, object pointer
            link = new KPDFLinkGoto( (QString)fileName, decodeViewport( g->getNamedDest(), g->getDest() ) );
            }
            break;

        case actionLaunch:
            {
            LinkLaunch * e = (LinkLaunch *)a;
            GString * p = e->getParams();
            link = new KPDFLinkExecute( e->getFileName()->getCString(), p ? p->getCString() : 0 );
            }
            break;

        case actionNamed:
            {
            const char * name = ((LinkNamed *)a)->getName()->getCString();
            if ( !strcmp( name, "NextPage" ) )
                link = new KPDFLinkAction( KPDFLinkAction::PageNext );
            else if ( !strcmp( name, "PrevPage" ) )
                link = new KPDFLinkAction( KPDFLinkAction::PagePrev );
            else if ( !strcmp( name, "FirstPage" ) )
                link = new KPDFLinkAction( KPDFLinkAction::PageFirst );
            else if ( !strcmp( name, "LastPage" ) )
                link = new KPDFLinkAction( KPDFLinkAction::PageLast );
            else if ( !strcmp( name, "GoBack" ) )
                link = new KPDFLinkAction( KPDFLinkAction::HistoryBack );
            else if ( !strcmp( name, "GoForward" ) )
                link = new KPDFLinkAction( KPDFLinkAction::HistoryForward );
            else if ( !strcmp( name, "Quit" ) )
                link = new KPDFLinkAction( KPDFLinkAction::Quit );
            else if ( !strcmp( name, "GoToPage" ) )
                link = new KPDFLinkAction( KPDFLinkAction::GoToPage );
            else if ( !strcmp( name, "Find" ) )
                link = new KPDFLinkAction( KPDFLinkAction::Find );
            else if ( !strcmp( name, "Close" ) )
                link = new KPDFLinkAction( KPDFLinkAction::Close );
            else
                kdDebug() << "Unknown named action: '" << name << "'" << endl;
            }
            break;

        case actionURI:
            link = new KPDFLinkBrowse( ((LinkURI *)a)->getURI()->getCString() );
            break;

        case actionMovie:
/*          { TODO this (Movie link)
            m_type = Movie;
            LinkMovie * m = (LinkMovie *) a;
            // copy Movie parameters (2 IDs and a const char *)
            Ref * r = m->getAnnotRef();
            m_refNum = r->num;
            m_refGen = r->gen;
            copyString( m_uri, m->getTitle()->getCString() );
            }
*/          break;

        case actionUnknown:
            kdDebug() << "Unknown link." << endl;
            break;
    }

    // link may be zero at that point
    return link;
}
コード例 #7
0
void
BepdfApplication::Initialize()
{
	if (!mInitialized) {
		mInitialized = true;

		// built in fonts
		BPath fontDirectory(mAppPath);
		fontDirectory.Append("fonts");

		// built in encodings
		BPath encodingDirectory(mAppPath);
		encodingDirectory.Append("encodings");

		InitXpdf(NULL, fontDirectory.Path(), encodingDirectory.Path());

		// system fonts
		BPath systemFontsPath;
		if (find_directory(B_BEOS_FONTS_DIRECTORY, &systemFontsPath) == B_OK) {
			BDirectory directory(systemFontsPath.Path());
			BEntry entry;
			while (directory.GetNextEntry(&entry) == B_OK) {
				if (!entry.IsDirectory())
					continue;
				BPath fontDirectory;
				if (entry.GetPath(&fontDirectory) != B_OK)
					continue;
				setGlobalParameter("fontDir", fontDirectory.Path());
			}
		}

		// CID fonts
		BMessage msg;
		mSettings->GetDisplayCIDFonts(msg);
		DisplayCIDFonts displayNames(msg);

		// record new names
		bool foundNewName = false;
		GList* list = getCIDToUnicodeNames(globalParams);
		for (int i = 0; i < list->getLength(); i ++) {
			GString* name = (GString*)list->get(i);
			if (displayNames.Contains(name->getCString())) {
				continue;
			}
			// record name
			displayNames.Set(name->getCString());
			foundNewName = true;
		}

		// store in settings
		if (foundNewName) {
			msg.MakeEmpty();
			displayNames.Archive(msg);
			mSettings->SetDisplayCIDFonts(msg);
		}

		// set CID fonts
		for (int i = 0; i < list->getLength(); i ++) {
		    GString* name = (GString*)list->get(i);
			BString file;
			DisplayCIDFonts::Type type;

			displayNames.Get(name->getCString(), file, type);
			if (type == DisplayCIDFonts::kUnknownType ||
				file.Length() == 0) {
				continue;
			}

			if (type == DisplayCIDFonts::kTrueType) {
				setGlobalParameter("displayCIDFontTT", name->getCString(), file.String());
			} else {
				setGlobalParameter("displayCIDFontT1", name->getCString(), file.String());
			}
		}

		deleteGList(list, GString);
	}
}
コード例 #8
0
ファイル: AnnotWriter.cpp プロジェクト: Akujiism/BePDF
void AnnotWriter::WriteObject(Object* obj) {
	ASSERT(mFile != NULL);
	int i;
	Object o;
	GString* s = NULL;

	switch (obj->getType()) {
		 // simple objects
		case objBool:
			fprintf(mFile, "%s", obj->getBool() ? "true" : "false");
			break;
		case objInt:
			fprintf(mFile, "%d", obj->getInt());
			break;
		case objReal:
			fprintf(mFile, "%g", obj->getReal());
			break;
		case objString:
			if (AnnotUtils::InUCS2(obj->getString())) {
				s = AnnotUtils::EscapeString(obj->getString());
				Write("(");
				Write(s);
				Write(")");
			} else {
				s = AnnotUtils::EscapeString(obj->getString());
				fprintf(mFile, "(%s)", s->getCString());
			}
			break;
		case objName:
			s = AnnotUtils::EscapeName(obj->getName());
			fprintf(mFile, "/%s", s->getCString());
			break;
		case objNull:
			Write("null");
			break;

		// complex objects
		case objArray:
			Write("[");
			for (i = 0; i < obj->arrayGetLength(); i ++) {
				obj->arrayGetNF(i, &o);
				if (i > 0) InsertWhiteSpace(&o);
				WriteObject(&o);
			}
			Write("]");
			break;
		case objDict:
			Write("<<");
			for (i = 0; i < obj->dictGetLength(); i ++) {
				if (i > 0) WriteCr();
				fprintf(mFile, "/%s", obj->dictGetKey(i));
				obj->dictGetValNF(i, &o);
				InsertWhiteSpace(&o);
				WriteObject(&o);
			}
			Write(">>");
			break;
		case objStream:
			fflush(mFile);
			fprintf(stderr, "Error: <!!!stream!!!>\n");
			ASSERT(false);
			break;
		case objRef:
			Write(obj->getRef()); Write(" R");
			break;
		default:
			fflush(mFile);
			fprintf(stderr, "Error: WriteObj unknown type %d\n", obj->getType());
			obj->print(stderr);
			fprintf(stderr, "\n");
			ASSERT(false);
	}
	delete s;
}