Planet PDF Forum Archive

Planet PDF ForumWowsers! This is page is old, head to the LIVE Planet PDF Forum. It features more than 10 conferences, covering everything from beginner to in-depth developer and pre-press discussions. If you wish to continue... one & two archive covers 1999-2011 (160,000 pages).


New Forum | Previous | Next | (P-PDF) Developers


Topic: Changing color space using SDK
Conf: (P-PDF) Developers, Msg: 95183
From: nvanraalte
Date: 8/26/2003 09:05 PM

The attached sample code illustrates iterating through all the PDEText objects on a page, and for each object tring to change its color space. The problem I have is that the routine appears to go through the text objects correctly, but does not seem to change their color space. Are there any other steps I am missing in order to permanently alter the color space of a PDEText object?


ACCB1 void ACCB2 ColorText(void *data)
{
AVDoc avDoc;
AVPageView pageView;
PDDoc pdDoc;
PDPage pdPage;

PDEContent volatile pdePageContent = NULL;
PDEElement pdePageElement;
long lpPageElementIndex;
long lpTextRunIndex;

PDEContent volatile pdeContContent = NULL;
PDEElement pdeContElement;
long lpContElementIndex;

PDEColorSpace pdeColorSpace;
PDEGraphicState gState;
ASFixedMatrix textMatrix;
ASFixed fontSize;
PDEText volatile pdeText = NULL;

// Get the currently displayed page and get its crop box.
avDoc = AVAppGetActiveDoc();
pageView = AVDocGetPageView (avDoc);
pdDoc = AVDocGetPDDoc (avDoc);
pdPage = PDDocAcquirePage (pdDoc, AVPageViewGetPageNum(pageView));

pdePageContent = PDPageAcquirePDEContent (pdPage, gExtensionID);

for (lpPageElementIndex = 0; lpPageElementIndex < PDEContentGetNumElems (pdePageContent); lpPageElementIndex++){

pdePageElement = PDEContentGetElem(pdePageContent, lpPageElementIndex);

switch (PDEObjectGetType((PDEObject) pdePageElement)){
case kPDEText:{
AVAlert (ALERT_STOP, "Page Text Element", "OK", NULL, NULL, false);
}
break;
case kPDEGroup: {
AVAlert (ALERT_STOP, "Page Group Element", "OK", NULL, NULL, false);
}
break;
case kPDEPath:{
AVAlert (ALERT_STOP, "Page Path Element", "OK", NULL, NULL, false);
}
break;
case kPDEImage:{
AVAlert (ALERT_STOP, "Page Image Element", "OK", NULL, NULL, false);
}
break;
case kPDEForm:{
AVAlert (ALERT_STOP, "Page Form Element", "OK", NULL, NULL, false);
}
break;
case kPDEXObject:{
AVAlert (ALERT_STOP, "Page Object Element", "OK", NULL, NULL, false);
}
break;
case kPDEShading:{
AVAlert (ALERT_STOP, "Page Shading Element", "OK", NULL, NULL, false);
}
break;
case kPDEContainer:{
AVAlert (ALERT_STOP, "Page Container Element", "OK", NULL, NULL, false);

pdeContContent = PDEContainerGetContent((PDEContainer) pdePageElement);

for (lpContElementIndex = 0; lpContElementIndex < PDEContentGetNumElems (pdeContContent); lpContElementIndex++){

pdeContElement = PDEContentGetElem(pdeContContent, lpContElementIndex);
switch (PDEObjectGetType((PDEObject) pdeContElement)){
case kPDEText:{

AVAlert (ALERT_STOP, "Content Text Element", "OK", NULL, NULL, false);

pdeText = (PDEText) pdeContElement;

for ( lpTextRunIndex = 0; lpTextRunIndex < PDETextGetNumRuns( (PDEText) pdeText ); lpTextRunIndex++ ){

AVAlert (ALERT_STOP, "Content Text Element Run", "OK", NULL, NULL, false);

PDETextGetGState (pdeText, kPDETextRun, lpTextRunIndex, &gState, sizeof(PDEGraphicState));

pdeColorSpace = PDEColorSpaceCreateFromName (ASAtomFromString("DeviceRGB"));
gState.strokeColorSpec.space = gState.fillColorSpec.space = pdeColorSpace;
gState.strokeColorSpec.value.color[0] = gState.fillColorSpec.value.color[0] = ASFloatToFixed(0.0);
gState.strokeColorSpec.value.color[1] = gState.fillColorSpec.value.color[1] = ASFloatToFixed(0.9);
gState.strokeColorSpec.value.color[2] = gState.fillColorSpec.value.color[2] = ASFloatToFixed(0.0);
gState.miterLimit = fixedTen;
gState.flatness = fixedOne;
gState.lineWidth = fixedFifty;
PDETextRunSetGState ( pdeText, lpTextRunIndex, &gState, sizeof(gState));
}
}
break;
default:{
AVAlert (ALERT_STOP, "Content Ignore Element", "OK", NULL, NULL, false);
}
break;
}

}
}
break;
default: {
AVAlert (ALERT_STOP, "Page Ignore Element", "OK", NULL, NULL, false);
}
break;
}

}

PDERelease ((PDEObject) pdeText);
PDERelease ((PDEObject) pdeColorSpace);

if (pdePageContent)
PDPageReleasePDEContent (pdPage, gExtensionID);

PDPageRelease (pdPage);
}



PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Back to the past, 15 years ago! Open Publish 2002

Looking back to 2002, it's amazing how much of the prediction became a reality. Take a read and see what you think!

September 14, 2017
Platinum Sponsor





Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.

Features

Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.