예제 #1
0
/* ===========================================================================
	Desc
	
	@param	None	desc
	@return	int	0: no error, -1: error
	==========================================================================*/
int PDF_Object_Pages::renderObj() {

	//cout << "PDF_Object_Pages::renderObj() called...\n";
	
	string renderString = "";
	
	renderString += getIndexString() + " " + getRevisionString();
	renderString += " obj <</Type /Pages /Kids [";

	// Get obj id's for child Pages
	for (unsigned i = 0; i < kids.size(); i++) {
		renderString += kids[i]->getIndexString() + " ";
		renderString += kids[i]->getRevisionString() + " R ";
	}
	
	// Number of child Pages
	renderString += "] /Count ";
	renderString += std::to_string(kids.size());
	
	// Set size of Pages
	renderString += " /MediaBox [";
	renderString += std::to_string( getMediaBoxX() );
	renderString += " ";
	renderString += std::to_string( getMediaBoxY() );
	renderString += " ";
	renderString += std::to_string( getMediaBoxWidth() );
	renderString += " ";
	renderString += std::to_string( getMediaBoxHeight() );
	renderString += "]";
	renderString += ">>\nendobj\n";
	
	return setRenderContent( renderString );
}
예제 #2
0
int addIndex(char *name, TypeIndex *species) {
	int sizeTmp, index;
	if(strlen(name) == 0)
		return -1;
	sizeTmp = species->size;
	index = getIndexString(name, species->dict, &(species->size));
	if(species->size > sizeTmp) {
		if(sizeTmp >= species->buffer) {
			species->buffer += INC_BUFFER_UTILS;
			species->name = (char**) monrealloc(species->name, species->buffer*sizeof(char*));
		}
		species->name[index] = (char*) monmalloc((strlen(name)+1)*sizeof(char));
		strcpy(species->name[index], name);
	}
	return index;
}
예제 #3
0
/* ===========================================================================
	Desc
	
	@param	none	desc
	@return	int	0: no error, -1: error
	==========================================================================*/
int PDF_Object_Catalog::renderObj() {

	//cout << "PDF_Object_Catalog::renderObj() called...\n";

	string renderString = "";
	renderString += getIndexString() + " " + getRevisionString();
	renderString += " obj <</Type /Catalog /Pages ";

	for (unsigned i = 0; i < pages.size(); i++) {
		renderString += pages[i]->getIndexString() + " ";
		renderString += pages[i]->getRevisionString() + " R ";
	}
	renderString += ">>\nendobj\n";
	
	return setRenderContent( renderString );
}
예제 #4
0
/* ===========================================================================
	// Render PDF obj to string content
	
	@param	none	desc
	@return	none	desc
	==========================================================================*/
int PDF_Object_Page::renderObj() {

	/*
   //scale.setConversion(pt);
   // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE 4/12
   cout << "==============================================\n";
   cout << "==============================================\n";
   cout << "==============================================\n";
   cout << "PDF_Object_Page::renderObj() called...\n";
  // cout << "SCALE current: |"<< scale.getUnitsAsString() << "|, ";
   //cout << "conversion units: |" << scale.getConversionUnitsAsString() << "|\n";
   //scale.setUnits(pt);
   //scale.setConversion(mm);
   
   cout << "SCALE current: |"<< scale.getUnitsAsString() << "|, ";
   cout << "conversion units: |" << scale.getConversionUnitsAsString() << "|, ";
   printf("scale factor: |%f|\n", scale.getConversionFactor() );
   //cout << "scale factor: |" << scale.getConversionFactor() << "|\n";
   cout << "==============================================\n";
   cout << "==============================================\n";
   cout << "==============================================\n";

	//cout << "PDF_Object_Page::renderObj() called...\n";
	*/

	string renderString = "";
	renderString += getIndexString() + " " + getRevisionString();
	
	// GET PAGES ADRESS FOR PARENT FIELD
	renderString += " obj <</Type /Page /Parent 2 0 R /Contents ";
	
	for (unsigned i = 0; i < contents.size(); i++) {
		renderString += contents[i]->getIndexString() + " ";
		renderString += contents[i]->getRevisionString() + " R ";
	}
	
	// Render UserUnit
	renderString += "/UserUnit ";
	//renderString += "2.83465";
	renderString += convertToString( scale.getConversionFactor() );
	renderString += " ";
	
	renderString += ">>\nendobj\n";
	
	return setRenderContent( renderString );
}
예제 #5
0
static void fillIndexPage( void **pages, unsigned curpage, unsigned base,
                    int datalevel )
{
    HelpIndexEntry      *entry;
    HelpPageHeader      *header;
    unsigned            i;
    char                *src;

    header = pages[curpage];
    entry = (HelpIndexEntry *) ( (char *)header + sizeof( HelpPageHeader ) );
    for( i = 0; i < header-> num_entries; i++ ) {
        entry->nextpage = base;
        src = getIndexString( pages, base, datalevel );
        strncpy( entry->start, src, INDEX_LEN );
        entry->start[ INDEX_LEN -1 ] = '\0';
        base++;
        entry++;
    }
}
예제 #6
0
void MyWidget::fromClipboardToLineEdit() // слот
{
	if (mpClipboard ->text().size() < 35)
	{
		uiForm ->lineEditInput ->setText(mpClipboard ->text());
		qint32 n = getIndexString(mCurrentListFileName, uiForm ->lineEditInput ->text(), "OneWord");
		if (n == -1)
			uiForm ->lineEditInput ->setFocus();
		else
		{
			qDebug() << "Index = " << n;
			quint32 m = uniqueFileName(mCurrentListFileName, uiForm ->lineEditInput ->text());
			if (m == 1)
				uiForm ->listWidgetFiles ->setCurrentRow(n);
			else
				uiForm ->listWidgetFiles ->setCurrentRow(mCurrentIndex);
		}
	}
}
예제 #7
0
/* ===========================================================================
	DESC
	
	@param	none	desc
	@return	none	desc
	==========================================================================*/
int PDF_Object_Stream::renderObj() {

	//cout << "----------------------------------------------------------------\n";
	//cout << "\tPDF_Object_Stream::renderObj() called...\n";

	string renderString = "";
	string renderStream = "";
	unsigned streamLength = 0;
	pdf_obj::coords currentPoint;
	
	//cout << "\t\tProcessing " << getPathCount() << " paths...\n";
	
	// Process each Path in paths
	for (unsigned p = 0; p < getPathCount(); p++) {
		
		// Set graphics state 
		// Set Stroke width /pattern
		// Set line width (w): "4 w " 
		
		//cout << "\t\tPath " << p << ": ";
		//cout << "stroke width: " << paths[p]->getStrokeWidth() << ", filled: ";
		//if (paths[p]->getFilled() ) cout << "YES, "; else cout << "NO, "; 
		//cout << "closed: ";
		//if (paths[p]->getClosePath() ) cout << "YES\n"; else cout << "NO\n"; 
		
		//cout << "stroke: |";
		//cout << paths[p]->getStrokeWidth();
		
		// Stroke Set
		if (paths[p]->getStrokeWidth() > 0.0) {
		
			//cout << ", cs: " << paths[p]->stroke.getColorSpace();
		
			// Stroke Specified
			renderStream += convertToString( paths[p]->getStrokeWidth() ); 
			renderStream += " w "; 
			
			// Line dash (d) array [units on, units off] units space at start: "[ 4 6 ] 0 d ";
			if ( paths[p]->getDashedStroke() ) {
				renderStream += "[ ";
				renderStream += convertToString( paths[p]->getStrokeDash() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->getStrokeGap() );
				renderStream += " ] ";
				renderStream += convertToString( paths[p]->getStrokeOffset() );
				renderStream += " d ";
			}
			
			// Set stroke color (RGB values, 0.0-1.0) (RG): "0.9 0.5 0.0 RG "; 	
			switch( paths[p]->stroke.getColorSpace() ) {
		
				case 1: // Grayscale
					//cout << ", grey: " << paths[p]->stroke.getValuePDF('A');
					renderStream += convertToString( paths[p]->stroke.getValuePDF('A') );
					renderStream += " G ";
				break;
			
				case 3: // RGB
					renderStream += convertToString( paths[p]->stroke.getValuePDF('R') );
					renderStream += " "; 
					renderStream += convertToString( paths[p]->stroke.getValuePDF('G') );
					renderStream += " ";
					renderStream += convertToString( paths[p]->stroke.getValuePDF('B') );
					renderStream += " RG ";
				break;
			
				case 4: // CMYK
					renderStream += convertToString( paths[p]->stroke.getValuePDF('C') );
					renderStream += " "; 
					renderStream += convertToString( paths[p]->stroke.getValuePDF('M') );
					renderStream += " ";
					renderStream += convertToString( paths[p]->stroke.getValuePDF('Y') );
					renderStream += " ";
					renderStream += convertToString( paths[p]->stroke.getValuePDF('K') );
					renderStream += " K "; 
				break;
			
				default:
					// Paper Color
					renderStream += "1.0 1.0 1.0 G ";
				break;
			}	

		} else {
		
			// No Stroke
			renderStream += "0 w "; 
		}
		
		//cout << "|, ";
		
		// Process Fill (if needed
		//cout << "fill: |cs: ";
		//cout << paths[p]->fill.getColorSpace();
	
		// Set fill color (RGB values, 0.0-1.0) (rg): "0.9 0.5 0.0 rg "; 
		switch( paths[p]->fill.getColorSpace() ) {
		
			case 1: // Grayscale
				//cout << ", grey: " << paths[p]->fill.getValue('A');
				renderStream += convertToString( paths[p]->fill.getValuePDF('A') );
				renderStream += " g ";
			break;
			
			case 3: // RGB
				renderStream += convertToString( paths[p]->fill.getValuePDF('R') );
				renderStream += " "; 
				renderStream += convertToString( paths[p]->fill.getValuePDF('G') );
				renderStream += " ";
				renderStream += convertToString( paths[p]->fill.getValuePDF('B') );
				renderStream += " rg ";
			break;
			
			case 4: // CMYK
				renderStream += convertToString( paths[p]->fill.getValuePDF('C') );
				renderStream += " "; 
				renderStream += convertToString( paths[p]->fill.getValuePDF('M') );
				renderStream += " ";
				renderStream += convertToString( paths[p]->fill.getValuePDF('Y') );
				renderStream += " ";
				renderStream += convertToString( paths[p]->fill.getValuePDF('K') );
				renderStream += " k "; 
			break;
			
			default:
				// Transparent
				//renderStream += "1.0 g ";
			break;
		}	
		
		//cout << "|\n";

		// Store Current Graphics State (q): "q "
		renderStream += "q\n";
		
		// Get Starting point for Path
		currentPoint.x = paths[p]->path[0]->getStartX();
		currentPoint.y = paths[p]->path[0]->getStartY();

		// Process each element in Path
		for (unsigned e = 0; e < paths[p]->getPathSize(); e++) {

			// Get "pen" location
			// Check if start
			// Begun new path (x,y) (m): "150 250 m"; // 
			if (e == 0) {
				renderStream += convertToString( currentPoint.x ); 
				renderStream += " ";
				renderStream += convertToString( currentPoint.y ); 
				renderStream += " m "; // BEGIN NEW PATH
				
			} else if (paths[p]->path[e]->getStartX() != currentPoint.x || 
				 		  paths[p]->path[e]->getStartY() != currentPoint.y) {
			
				// the next point is not lined up with current point
				// End Path and start a new one
				renderStream += "s \n"; // End previous path
			
				// Get new start point
				renderStream += convertToString( currentPoint.x ); 
				renderStream += " ";
				renderStream += convertToString( currentPoint.y ); 
				renderStream += " m "; // BEGIN NEW PATH
			} 		
	
			// Get end point of pen
			if (paths[p]->path[e]->getType() == 1) {

				// Bezier with curve handles at start (c1x, c1y, c2x, c2y, destx, desty) (c):
				// 	"300 400 400 400 400 300 c "; 
				renderStream += convertToString( paths[p]->path[e]->getStartHandleX() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->path[e]->getStartHandleY() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->path[e]->getEndHandleX() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->path[e]->getEndHandleY() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->path[e]->getEndX() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->path[e]->getEndY() );
				renderStream += " c ";
			
			} else if (paths[p]->path[e]->getType() == 2) {

				// Draw line from current point to new point (x,y) (l): "150 350 l";
				renderStream += convertToString( paths[p]->path[e]->getEndX() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->path[e]->getEndY() );
				renderStream += " l ";
			
			} 
		
			// "MOVE" pen to current location
			currentPoint.x = paths[p]->path[e]->getEndX();
			currentPoint.y = paths[p]->path[e]->getEndY();
			
		} // end processing of elements in path
		
		// Close path? Stroke? Fill?
		// S	-	Stroke the path
		// s	-	Close and stroke the path same effect as the sequence h S .
		// f	-	Fill the path, using the nonzero winding number rule
		// f*	-	Fill the path, using the even-odd rule t
		// B	-	Fill and then stroke the path, using the nonzero winding number rule
		// B*	-	Fill and then stroke the path, using the even-odd rule t
		// b	-	Close, fill, and then stroke the path, using the nonzero winding number rule t
		// b*	-	Close, fill, and then stroke the path, using the even-odd rule
		//	n	-	End the path object without filling or stroking it. 	
		if ( paths[p]->getClosePath() ) renderStream += "h ";
		if ( paths[p]->getStrokeWidth() > 0 ) renderStream += "S ";
		if ( paths[p]->getFilled() ) renderStream += "f ";
		
		// Rectangle x,y w,h rectangle (re), filled (f): "100 400 300 300 re f "
		// Stroke Path (S): "S ";	
		
		// Reset Dash to solid line: "[ ] 0 d " if needed
		if ( paths[p]->getDashedStroke() ) renderStream += "[ ] 0 d ";
		
		// Clear Current Graphics state (Q): "Q "
		renderStream += "Q\n";
	}
	
	//renderStream += "h S ";
	
	streamLength = renderStream.length();
	renderString += getIndexString() + " " + getRevisionString();
	renderString += " obj\n";
	renderString += "<</Length ";
	renderString += convertToString( streamLength ); // Get Stream length
	renderString += ">>\n";
	renderString += "stream\n";
	renderString += renderStream;
	renderString += "endstream\n";
	renderString += "endobj\n";
	
	//cout << "\tPDF_Object_Stream::renderObj() called...DONE.\n";
	//cout << "----------------------------------------------------------------\n";
	
	return setRenderContent( renderString );
}