Hi
I know how to use the bitmap and graphics objects to create bitmaps and
write text on them with the drawString method. I now need to create some BMPs
of word or RTF docs. What would be the best approach here as I need to
maintain most if not all of the formatting. The docs will be about 3
paragraphs each.
Should I save the docs to rtf, then parse the rtf into the draw string
method? There has to be an easier way.
Thank you 3 4590
Ok make a new windows Form, then add a RichTextBox to it. Then render
your RTF on the richtextbox and screen dump the Form (you never have to
show it)
Here is the code to dump a Form:
public static void CaptureScreen(F orm form, string saveLocation)
{
Graphics g1 = form.CreateGrap hics();
Image image = new Bitmap(form.Cli entRectangle.Wi dth,
form.ClientRect angle.Height, g1);
Graphics g2 = Graphics.FromIm age(image);
IntPtr dc1 = g1.GetHdc();
IntPtr dc2 = g2.GetHdc();
BitBlt(dc2, 0, 0, form.ClientRect angle.Width,
form.ClientRect angle.Height, dc1, 0, 0, 13369376);
g1.ReleaseHdc(d c1);
g2.ReleaseHdc(d c2);
image.Save(save Location, System.Drawing. Imaging.ImageFo rmat.Jpeg);
image.Dispose() ;
}
[System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
private static extern bool BitBlt(
IntPtr hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
System.Int32 dwRop // raster operation code
);
--
Wal http://www.vooose.com
*** Sent via Developersdex http://www.developersdex.com ***
Thank you Vooose
"vooose" wrote: Ok make a new windows Form, then add a RichTextBox to it. Then render your RTF on the richtextbox and screen dump the Form (you never have to show it)
Here is the code to dump a Form:
public static void CaptureScreen(F orm form, string saveLocation) { Graphics g1 = form.CreateGrap hics(); Image image = new Bitmap(form.Cli entRectangle.Wi dth, form.ClientRect angle.Height, g1); Graphics g2 = Graphics.FromIm age(image); IntPtr dc1 = g1.GetHdc(); IntPtr dc2 = g2.GetHdc(); BitBlt(dc2, 0, 0, form.ClientRect angle.Width, form.ClientRect angle.Height, dc1, 0, 0, 13369376); g1.ReleaseHdc(d c1); g2.ReleaseHdc(d c2); image.Save(save Location, System.Drawing. Imaging.ImageFo rmat.Jpeg); image.Dispose() ; }
[System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")] private static extern bool BitBlt( IntPtr hdcDest, // handle to destination DC int nXDest, // x-coord of destination upper-left corner int nYDest, // y-coord of destination upper-left corner int nWidth, // width of destination rectangle int nHeight, // height of destination rectangle IntPtr hdcSrc, // handle to source DC int nXSrc, // x-coordinate of source upper-left corner int nYSrc, // y-coordinate of source upper-left corner System.Int32 dwRop // raster operation code );
-- Wal http://www.vooose.com
*** Sent via Developersdex http://www.developersdex.com ***
Yes, I know, I'm more than a year late on seeing this. I've been looking for
something like this for a while.
Unfortunately, vooose, this only works if the RichTextBox control is visible
and on top of all other controls/windows (topmost). It's the programmatic
equivalent of hitting Alt+PrntScrn. The part where you say "you never have
to show it" isn't correct.
I'm looking for a way to quickly convert an RTF file into a PNG file (or
bitmap or whatever). I was hoping this would help, but it's not adequate.
Is there some other way to redirect or copy a RichTextBox's rendering
(regardless of the Height) to a Bitmap object, without the RichTextBox being
visible? I was hoping to make a small and fast console app that I can add to
an RTF file's open-with menu.
"vooose" wrote:
Ok make a new windows Form, then add a RichTextBox to it. Then render
your RTF on the richtextbox and screen dump the Form (you never have to
show it)
Here is the code to dump a Form:
public static void CaptureScreen(F orm form, string saveLocation)
{
Graphics g1 = form.CreateGrap hics();
Image image = new Bitmap(form.Cli entRectangle.Wi dth,
form.ClientRect angle.Height, g1);
Graphics g2 = Graphics.FromIm age(image);
IntPtr dc1 = g1.GetHdc();
IntPtr dc2 = g2.GetHdc();
BitBlt(dc2, 0, 0, form.ClientRect angle.Width,
form.ClientRect angle.Height, dc1, 0, 0, 13369376);
g1.ReleaseHdc(d c1);
g2.ReleaseHdc(d c2);
image.Save(save Location, System.Drawing. Imaging.ImageFo rmat.Jpeg);
image.Dispose() ;
}
[System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
private static extern bool BitBlt(
IntPtr hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
System.Int32 dwRop // raster operation code
);
--
Wal http://www.vooose.com
*** Sent via Developersdex http://www.developersdex.com *** This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Martin Lucas-Smith |
last post by:
I am trying to use PHP's COM support to open a URL from within MS Word
then save the document.
I am using PHP5.0.3/Apache2/WindowsXP. phpinfo() confirms that COM support
is enabled.
Manually, this would be:
- Start MS Word (am using Office 2003)
|
by: bborden |
last post by:
When I save a document in Word that I have transferred from VBA to
Word I notice that the "Save As" file name is for, instance, "December
4.doc". Since the date is the first field I print on the Word
document I guess it picks up this as a key.
How do I stipulate what the name of the document is to be once I want
to save it in Word?
" .SaveAs" actually saves the document and I want to view and edit the
document and manually save it.
|
by: zheng |
last post by:
ÇçÌì
I have a word document and it has a picture object, I want save the picture
object as other single picture file by C# program. I have a idea, by
clipboard, copy the picture to clipboard, and then save as a file from
clipboard, it is work well in application,but don't work in a web
application. how can I to do? and are there other ideas to save the picture
object in web application?
help me !!
|
by: CM |
last post by:
Hi,
Could anyone please help me?
I am completing my Master's Degree and need to reproduce a Webpage in
Word.
Aspects of the page are lost and some of the text goes.
I would really appreciate it.
The link to the document is
http://www.surveymonkey.com/s.asp?u=689952259313
I have spent 15 hours trying to sort this but to no avail.
|
by: AVL |
last post by:
Hi,
I've a requirement in which I need to show a word document in the web page,
allow the user to edit the document and then save the document ina
particular location, How can I acheive in asp.net 1.1? need guidance....
| |
by: ljungers |
last post by:
I need to make some changes to a Query/select/print report using word application. What I need to do is change the way Word is called yet keep the process the same. Word is used so changes can be made before actual printing. Need some way of calling Word as a mail merge with the information from an Access table that the current report uses.
I have seen mail merge templates that use something like <<field name>> in them that uses a table....
|
by: mike |
last post by:
I help manage a large web site, one that has over
600 html pages... It's a reference site for ham radio
folks and as an example, one page indexes over
1.8 gb of on-line PDF documents.
The site is structured as an upside-down tree, and
(if I remember correctly) never more than 4 levels.
The site basically grew (like the creeping black blob) ...
all the pages were created in Notepad over the last
|
by: =?Utf-8?B?QmFkaXM=?= |
last post by:
Hi,
I'm using the bellow code to mail merge a word document and it's working
fine, where I'm openning "improvement.doc" which is just word document that
contain with some text and the merge fields at the top of the document...
after performing the merge I want to save the merged document as
"merged.doc" and close it. the problem is that my code is opening a new
document (as Letter) to do the merge and I don't know to access that document...
|
by: gusa992000 |
last post by:
Hello
I am trying the following problem:
A web app in jsp and java has to open a microsoft word document directly in the browser. This part is easy and i have done it.
The user then can modify the word document.
If the user 'save' the document (using the Save button of the MS tool bar in the browser) the application has to 'save as' the document on the server, not over writing the openned file but creating a new one.
|
by: =?Utf-8?B?S2ltIFM=?= |
last post by:
I have a word document I only want to printout ( not save as file ) and I
use Word printout method in backgrund but my XP operativ i so slow that a
"dummy"
dociment also get stored.
which word Printout or quit parameter have I to set to diff. than Missing
Obj. to get word printout to work Its can't be right that I have to user
timer delay of word quit command.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |