This content has been marked as final.
Show 17 replies
-
1. Re: Is it possible to shift page content horizontally programmatically?
(Leonard_Rosenthol) May 7, 2008 3:29 PM (in response to andrejusc)You can do it using the PDEdit APIs from a plugin.
Leonard -
2. Re: Is it possible to shift page content horizontally programmatically?
andrejusc May 7, 2008 9:18 PM (in response to andrejusc)Hi Leonard,
Could you get me more details on that?
So far I was trying this way:
1. Obtain page content:
PDEContent pdeContent = PDPageAcquirePDEContent (pdPage, gExtensionID);
2. Get enumeration of content's elements:
ASInt32 pdeContentNumElems = PDEContentGetNumElems (pdeContent);
3. Loop through elements and see their type:
for (ASInt32 elemIdx = 0; elemIdx < pdeContentNumElems; elemIdx++) {
// get element
PDEElement pdeElement = PDEContentGetElem (pdeContent, elemIdx);
// type
ASInt32 iType = PDEObjectGetType((PDEObject) pdeElement);
...
}
4. If particular element is of type PDEText - try to retrieve Text matrix:
if (iType == kPDEText){
PDETextItem pdeTextItem = PDETextGetItem ((PDEText) pdeElement, 0);
ASFixedMatrix matrix;
PDETextItemGetTextMatrix (pdeTextItem, 0, &matrix);
matrix.h = matrix.h + 10;
PDETextItemSetTextMatrix (pdeTextItem, &matrix);
}
But when I analize retrieved matrix - all fields are 0 and after first call to PDETextItemSetTextMatrix cycle breaks by some unknown reason.
Should I try to achieve that in some other way? -
3. Re: Is it possible to shift page content horizontally programmatically?
andrejusc May 8, 2008 12:09 AM (in response to andrejusc)It's interesting that for this statement:
PDETextItemSetTextMatrix (pdeTextItem, &matrix);
I actually get "Incorrect PDEObject type" exception.
So how could I change particular text element/block position? -
4. Re: Is it possible to shift page content horizontally programmatically?
andrejusc May 8, 2008 1:40 AM (in response to andrejusc)One more observation. I've copied part of code from ObjShiftSnip from Adobe SDK 6.0 into my plugin, compiled it and run under latest Adobe 8.1.2. When I invoke that shifting by 72 points (or 1 inch) I could see that only lines and rectangles have moved, but not any text.
Is it a bug or what? -
5. Re: Is it possible to shift page content horizontally programmatically?
andrejusc May 8, 2008 2:10 AM (in response to andrejusc)Update:
Under 6.0.0 everything works correctly, under 8.1.2 same plugin shifts only graphics elements, not text. -
6. Re: Is it possible to shift page content horizontally programmatically?
(Leonard_Rosenthol) May 8, 2008 2:39 AM (in response to andrejusc)I don't have the SDK for Acrobat 6, so I can't look at that particular piece of code - but I suspect that it's not checking the object type.
Personally, if it were me doing this, I would just prepend the content stream with the actual PDF operators for this (ie. 1 0 0 1 72 0 cm) and be done with it.
Leonard -
7. Re: Is it possible to shift page content horizontally programmatically?
andrejusc May 8, 2008 2:52 AM (in response to andrejusc)That old SDK 6.0 code actually does that object type checking in this way:<br /><br />case kPDEText:<br />{<br /> ASUns32 numRuns = PDETextGetNumRuns ((PDEText)pdeElement);<br /><br /> for (ASUns32 j=0; j<numRuns; j++)<br /> {<br /> PDETextGetMatrix((PDEText)pdeElement, kPDETextRun, j, &elemMatrix);<br /> // Perform transformation to translate object position<br /> ASFixedMatrixConcat( &newMatrix, &xMatrix, &elemMatrix );<br /> // and we apply it<br /> PDETextRunSetMatrix((PDEText)pdeElement, j, &newMatrix);<br /> }<br />}<br />break;<br /><br />But as I say - it works then under 6.0.0, but not under 8.1.2<br /><br />And for my initial code retrieved Text matrix was always filled with 0s.<br /><br />So it seems a bug to me. Where should I open bug report then?<br /><br />In regards to your suggestion for stream prepending - I don't like that approach. But thanks anyway. -
8. Re: Is it possible to shift page content horizontally programmatically?
(Leonard_Rosenthol) May 8, 2008 8:37 AM (in response to andrejusc)You don't want the text matrix, you want the current (general) matrix.
Leonard -
9. Re: Is it possible to shift page content horizontally programmatically?
andrejusc May 8, 2008 11:37 AM (in response to andrejusc)I don't understand your response. Could you elaborate? -
10. Re: Is it possible to shift page content horizontally programmatically?
(Leonard_Rosenthol) May 8, 2008 6:05 PM (in response to andrejusc)There is a current transformation matrix that effects all objects in the content stream and then there is a text matrix that only operates on text. You want the former.
Leonard -
11. Re: Is it possible to shift page content horizontally programmatically?
(priyapradeep) Jul 8, 2008 12:38 AM (in response to andrejusc)How does the form matrix relate to the CTM? I need to flatten the graphic elements in a Form XObject in order to display in a CAD system. Just concatenating the form matrix with the CTM does not give me the intended result. -
12. Re: Is it possible to shift page content horizontally programmatically?
(Aandi_Inston) Jul 8, 2008 1:13 AM (in response to (priyapradeep))>How does the form matrix relate to the CTM?
At the start of executing the form CTM = form matrix . CTM
There is an implied q/Q around the execution of the form, so the CTM
returns to normal afterwards.
This is what happens with a "Do" operator. Form XObjects used as
appearance streams for annotations have an adjustment according to the
position and size of the annotation.
Aandi Inston -
13. Re: Is it possible to shift page content horizontally programmatically?
(priyapradeep) Jul 8, 2008 2:39 AM (in response to andrejusc)Thanks very much for the reply.
I am confused about what I should do to get the coordinates of the flattened objects in a form. I am using the PDE Edit API; The PDEFormGetMatrix or PDEElementGetMatrix for the form do not give me the proper result;
I tried concatenating the matrix returned by PDEFormGetMatrix and matrix for individual path elements in the form(PDEElementGetMatrix for the element in the form). This does not work either.
For all other elements in PDF PDEElementGetMatrix gives me the correct coordinates. But PDEForms need something more than this; What is it? Your feedback is greatly appreciated.
Thanks,
Priya -
14. Re: Is it possible to shift page content horizontally programmatically?
(Aandi_Inston) Jul 8, 2008 2:49 AM (in response to (priyapradeep))What order are you concatenating PDEFormGetMatrix or
PDEElementGetMatrix?
Aandi Inston -
15. Re: Is it possible to shift page content horizontally programmatically?
(priyapradeep) Jul 8, 2008 3:02 AM (in response to andrejusc)ASFixedMatrixConcat (&transMatrix, &elemMatrix, &transMatrix); where the transMatrix is PDEFormGetMatrix and elemMatrix is that of the individual element in the Form content (using PDEElementGetMatrix).
But does the order matter?
Thanks,
priya -
16. Re: Is it possible to shift page content horizontally programmatically?
(Aandi_Inston) Jul 8, 2008 3:22 AM (in response to (priyapradeep))That looks like the right order. Well, on purely PDF content
principles this looks right (I assume by "flattened object in a form"
you now mean a form XObject in the page).
But I haven't worked with this part of PDFEdit; maybe it is different
there. Anyone?
Aandi Inston -
17. Re: Is it possible to shift page content horizontally programmatically?
(Leonard_Rosenthol) Jul 8, 2008 5:57 AM (in response to andrejusc)I wouldn't even bother trying to flatten XObjects with PDEdit - it's NOT designed for it (and will probably make things worse).
FYI - flattening Form XObjects is VERY complex work, given the possibilities for multiple layers of XObjects (which have to handled bottom->top).
Leonard
