Click here to Skip to main content
15,892,072 members
Articles / Desktop Programming / Windows Forms

View PDF files in C# using the Xpdf and muPDF library, Print PostScript.

Rate me:
Please Sign up or sign in to vote.
4.78/5 (39 votes)
26 Nov 2010GPL34 min read 1.6M   311   245  
Wrapper C# class written in C++\CLI and a sample implementation in C# to render PDF files.
#include "OutlineItemA.h"

OutlineItemA::OutlineItemA() : m_Item(NULL)
{
	
}

OutlineItemA::~OutlineItemA()
{
	// To terminate the application when all objects created with
	// 	with OLE automation, the destructor calls AfxOleUnlockApp.
	m_Item = NULL;
	
}


// OutlineItemA message handlers
wchar_t * OutlineItemA::GetTitle(void)
{
	
	//UnicodeMap *uMap = globalParams->getTextEncoding(); //getUnicodeMap(&GString("GBK"));
	wchar_t *ret=0;
	int j,n;
	//char buf[8];
	//GString *title=new GString();
	char *s;
	if(m_Item /*&& uMap!=NULL*/){
		ret =new wchar_t[m_Item->getTitleLength()+1];
		//12/July/2009 - Allow windows to map unicode characters, 
		for (j = 0; j < m_Item->getTitleLength(); j++) {
		  //n = uMap->mapUnicode(m_Item->getTitle()[j], buf, sizeof(buf));
		  //title->append(buf, n);
		  ret[j]=(wchar_t)m_Item->getTitle()[j];
		}
		ret[j]='\0';
		//s = title->getCString();		
	}else{
		return L"\0";
	}
	//USES_CONVERSION;
	//ret =A2W(s);
	return ret;
}

long OutlineItemA::GetKind(void)
{
	
	if (m_Item && m_Item->getAction()){
		return m_Item->getAction()->getKind();
	}
	return -1;
}

long OutlineItemA::GetKidsCount(void)
{
	if(m_Item!=0 ){
		m_Item->open();
		if(m_Item->hasKids()){
			return m_Item->getKids()->getLength();
		}
	}
	return 0;
}

long OutlineItemA::SetOutlineItemXPDF(long lPtr)
{
	
	m_Item =(OutlineItem *)lPtr;
	return 0;
}

long OutlineItemA::GetKidPtr(long iKid)
{
	
	
	if(m_Item && m_Item->getKids() && m_Item->getKids()->getLength()>0)
	{
		if(iKid>0 && iKid<= m_Item->getKids()->getLength()){
			return (long) m_Item->getKids()->get(iKid-1);
		}
	}
	return 0;
}

long OutlineItemA::GetLinkAction(void)
{
	

	if(m_Item)
		return (long)m_Item->getAction();
	return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Engineer HidraQuim SA de CV
Mexico Mexico
I'm a Chemical Engineering that loves the programming.
2003 - Graduated from Technical Programmer UNIVA México.
2009 - Graduated from Chemical Engineering Universidad de Guadalajara, Mexico.
Programmer by Hobby since 6 years ago.

Comments and Discussions