Antithesus
asked on
VB6 (Not .NET), RTF - Write Rotated Text Picturebox to RTF String
I am creating a "Print Preview" facility (we won't get into WHY I am creating it).
This facility provides a programmer with the ability to create a report; programmatically specify X and Y coordinates on a page, and then insert Text, Shapes, external pictures, or internal pictureboxes.
In addition, rotated text can be inserted.
This all works great
The facility also has the ability to EXPORT the resultant report to PDF and/or RTF.
It does this by writing the necessary control "strings" around the content, and writing all this out to an appropriately named file (xxx.PDF or xxx.RTF).
I have completed the PDF portion. It works just fine.
I have almost completed the RTF portion.
Here is my problem.
To rotate text in a RTF, it appears the only way is to build the rotated text into a picturebox,
with the desired font, size, forecolor, then crop this picturebox to only contain the rotated text.
I have done this successfully too.
When I extract the contents of the picturebox into a hex string, and insert that into the RTF,
that all works fine.
BUT.... the background of the picturebox is NOT transparent, so any other objects in the RTF which are near this picturebox (especially other rotated text) gets overlayed by the overlapping portions of this picturebox.
So I then make the background of this picturebox transparent.
This works fine. At least it does on a form.
But when I do my hexextract of this now transparent background picturebox, and insert that into my rtf file... again.... the background is NOT transparent. So overlay still occurs.
I have a sample of some rtf control strings and hexstring which actually does display rotated text with a transparent background.
So I am needing to figure out how to make that code string from my picturebox.
Here is the sample of rtf control strings and hexdata which DOES have rotated text in it.
And it DOES display as such, with no overlap showing (obviously the background is transparent).
(Or something else is going on, which I am not aware of... and would be greatfull for some direction in that regard)
{\shp{\*\shpinst\shpleft0\ shptop0\sh pright3200 0\shpbotto m32000
\shpfhdr0\shpbxpage\shpbyp age\shpwr3 \shpwrk0\s hpfblwtxt0 \shpz0\shp lid1014
{\sp{\sn shapeType}{\sv 75}}
{\sp{\sn fFlipH}{\sv 0}}
{\sp{\sn fFlipV}{\sv 0}}
{\sp{\sn pib}{\sv
{\pict\wmetafile8
0100090000038200000002001C 0000000000 0400000003 0108000500 00000B0200 0000000500 00000C0200 7D007D1C00 0000FB023D FF00000807 0807900100 0000000010 0000417269 616C00A775 610F0A9170 9F740730CA 120010DAA4 75C060A775 440F668C04 0000002D01 0000050000 0009028580 7A001A0000 0021052700 2E20507269 6E74207072 6576696577 2069732074 6865206265 73742C2061 6E676C6520 313830B000 5019501905 0000000902 010000001C 000000FB02 1000070000 000000BC02 0000000001 0202225379 7374656D00 00440F668C 00000A0022 008A010000 0000FFFFFF FFBCCA1200 040000002D 0101000400 0000F00100 0003000000 0000
}}}
}
}
How do I get a similar hexstring within my program, from a picturebox which has the rotated text in it, and a transparent background?
Thanks
This facility provides a programmer with the ability to create a report; programmatically specify X and Y coordinates on a page, and then insert Text, Shapes, external pictures, or internal pictureboxes.
In addition, rotated text can be inserted.
This all works great
The facility also has the ability to EXPORT the resultant report to PDF and/or RTF.
It does this by writing the necessary control "strings" around the content, and writing all this out to an appropriately named file (xxx.PDF or xxx.RTF).
I have completed the PDF portion. It works just fine.
I have almost completed the RTF portion.
Here is my problem.
To rotate text in a RTF, it appears the only way is to build the rotated text into a picturebox,
with the desired font, size, forecolor, then crop this picturebox to only contain the rotated text.
I have done this successfully too.
When I extract the contents of the picturebox into a hex string, and insert that into the RTF,
that all works fine.
BUT.... the background of the picturebox is NOT transparent, so any other objects in the RTF which are near this picturebox (especially other rotated text) gets overlayed by the overlapping portions of this picturebox.
So I then make the background of this picturebox transparent.
This works fine. At least it does on a form.
But when I do my hexextract of this now transparent background picturebox, and insert that into my rtf file... again.... the background is NOT transparent. So overlay still occurs.
I have a sample of some rtf control strings and hexstring which actually does display rotated text with a transparent background.
So I am needing to figure out how to make that code string from my picturebox.
Here is the sample of rtf control strings and hexdata which DOES have rotated text in it.
And it DOES display as such, with no overlap showing (obviously the background is transparent).
(Or something else is going on, which I am not aware of... and would be greatfull for some direction in that regard)
{\shp{\*\shpinst\shpleft0\
\shpfhdr0\shpbxpage\shpbyp
{\sp{\sn shapeType}{\sv 75}}
{\sp{\sn fFlipH}{\sv 0}}
{\sp{\sn fFlipV}{\sv 0}}
{\sp{\sn pib}{\sv
{\pict\wmetafile8
0100090000038200000002001C
}}}
}
}
How do I get a similar hexstring within my program, from a picturebox which has the rotated text in it, and a transparent background?
Thanks
Sorry to be dumb but have you tried setting the landscape RTF tag?
wow, I'm impressed with how far you've gotten so far.
I doubt that this will help, but when you mentioned rotated fonts, I thought of this old example from Karl Peterson. He does a lot of API stuff and has a font class you can download. Sounds like you have no trouble rotating your fonts, but maybe his class will have something related to transparent backgrounds that you could use. Longshot at best.
My guess as to how the example you have above that shows a transparent background works, is that the image represented by the values in the wmetafile8 tag was originally a GIF created with a transparent background, or perhaps a Windows Meta File. Likely, you are saving your rotated text as a bitmap, and those don't support a transparent background.
I doubt that this will help, but when you mentioned rotated fonts, I thought of this old example from Karl Peterson. He does a lot of API stuff and has a font class you can download. Sounds like you have no trouble rotating your fonts, but maybe his class will have something related to transparent backgrounds that you could use. Longshot at best.
My guess as to how the example you have above that shows a transparent background works, is that the image represented by the values in the wmetafile8 tag was originally a GIF created with a transparent background, or perhaps a Windows Meta File. Likely, you are saving your rotated text as a bitmap, and those don't support a transparent background.
ASKER
mdougan,
thanks for the link. I'll look into that.
More on what I have tried....
I have saved the contents of the picturebox to the clipboard as a metafile.
Then I have extracted them into another picturebox, as a metefile.
Then I have extracted the hexvalues of that picturebox, and inserted that into my rtf file...
nope... still no transparent background.
I have tried the same a s gif... same result.
I have tried actually saving the contents to a physical file, then reading that file (in hex)...
same result.
When I look at that hexstring in my example, I am quite sure it is NOT a hex representation of a picturebox contents. I think it has significant information regarding the font, color, and angle of rotation,
and then the actual text to be shown.
The string contains (from above)
0100090000038200000002001C 0000000000 0400000003 0108000500 00000B0200 0000000500
00000C02007D007D1C000000FB 023DFF0000 0807080790 0100000000 0010000041 7269616C00 A775
610F0A91709F740730CA120010 DAA475C060 A775440F66 8C04000000 2D01000005 0000000902 8580
7A001A000000210527002E2050 72696E7420 7072657669 6577206973 2074686520 626573742C 2061
6E676C6520313830B000501950 1905000000 0902010000 001C000000 FB02100007 0000000000 BC02
00000000010202225379737465 6D0000440F 668C00000A 0022008A01 00000000FF FFFFFFBCCA 1200
040000002D01010004000000F0 0100000300 00000000
Well, this part of that string actually translates into
7A001A000000210527002E20[c olor=red]5 072696E742 0707265766 9657720697 3207468652 0626573742 C
20[/color]616E676C65203138 30B0005019 5019050
"Print preview is the best, angle 180"
I have looked at the RTF specifications for weeks, but I cannot find anything that describes what a Metafile record looks like.
I expect the hex values preceding the "text" have to do with fonts, colors, angles, etc., etc.
And obviously the hex values after the "text" mean something too.
But I just can't figure it out.
I am hoping someone here can help me.
inthedark,
I am not sure how setting any landscape rtf tag will help me.
Could you elaborate ?
thanks for the link. I'll look into that.
More on what I have tried....
I have saved the contents of the picturebox to the clipboard as a metafile.
Then I have extracted them into another picturebox, as a metefile.
Then I have extracted the hexvalues of that picturebox, and inserted that into my rtf file...
nope... still no transparent background.
I have tried the same a s gif... same result.
I have tried actually saving the contents to a physical file, then reading that file (in hex)...
same result.
When I look at that hexstring in my example, I am quite sure it is NOT a hex representation of a picturebox contents. I think it has significant information regarding the font, color, and angle of rotation,
and then the actual text to be shown.
The string contains (from above)
0100090000038200000002001C
00000C02007D007D1C000000FB
610F0A91709F740730CA120010
7A001A000000210527002E2050
6E676C6520313830B000501950
00000000010202225379737465
040000002D01010004000000F0
Well, this part of that string actually translates into
7A001A000000210527002E20[c
20[/color]616E676C65203138
"Print preview is the best, angle 180"
I have looked at the RTF specifications for weeks, but I cannot find anything that describes what a Metafile record looks like.
I expect the hex values preceding the "text" have to do with fonts, colors, angles, etc., etc.
And obviously the hex values after the "text" mean something too.
But I just can't figure it out.
I am hoping someone here can help me.
inthedark,
I am not sure how setting any landscape rtf tag will help me.
Could you elaborate ?
ASKER
hmmmm... obviously bbcodes are not recognized... I tried to hilite a portion of the string in red.. oh well
let's hilite it in bold
7A001A000000210527002E205072696E742070726576696577 2069732074 6865206265 73742C20616E676C6520313830B00050195019050
let's hilite it in bold
7A001A000000210527002E205072696E742070726576696577
ASKER
mdougan,
that link/article refers to an article from 1999.
It essentially describes everything I am doing in my routines to arrive at rotated text.
But thanks anyway
that link/article refers to an article from 1999.
It essentially describes everything I am doing in my routines to arrive at rotated text.
But thanks anyway
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Feel free to ask to delete this question and refund the points to you. Glad you have a new direction to follow! You're doing some pretty advanced programming there, kudos to you.