How do I store and view graphically formatted data? - delphi

I have an app (written in D2010) which is similar to a text retrieval app... It has a list of questions, with their corresponding answers. Most answers are strictly text, but some answers have graphics, and formatting. My dilemma has to do with the formatted answer. The user should be able to copy this answer (formatting and graphics) in order to paste it into another app. I have tried using a Word OCX. This is a little problematic. User has to have word, it gives random errors when using inside a virtual machine, etc. I am now playing with using a built in browser component, and viewing the data as a PDF. This is nice and easy, but when I copy and paste it, I loose all formatting, and the graphic shows up as a large totally black box.
I can store the data in whatever format I choose. It is stored as a BLOB in a DB file. I write it to a temp file and then I call some type of viewing routine, so I have flexibility there. My issue is really, what viewer mechanism is simple to implement, and allows copying/pasting, while maintaining text formatting (bullets, indents, etc) and graphics.
Thanks,
GS

The TRichEdit (or any of TRichEdit descendants or similar classes) will allow the users to visualize text formatting and images, and when the content is copied, the RTF representation of the data will be copied into the clipboard.
When the clipboard data is pasted into a RTF compatible text editor (like Wordpad and Word), all the formatting, bullets and images are preserved.

Related

Microsoft word clipboard HTML documentation

I could not find any documentation describing conventions in text/html data in the clipboard resulting from copying part of a word document!
Specifically I want to know what classes like MsoNormal, TableGrid313, MsoTableGrid, MsoHeading9, MsoListParagraph are there! Or does styling information of texts always lay in style attribute of a span element containing the text?
The Word round-tip HTML is undocumented as it's not an official Word file format.
It was created to enable round-tripping Word documents for viewing (and some editing) in a browser, many years ago. Even then, it was not documented as its use was for internal Microsoft software. Being HTML, anyone could read and produce it, but MS made an conscious decision to not document it (and not need to put the resources into maintaining that documentation).

can Mathematica be instructed to print-to-file smaller pdf files?

Mathematica 9.0.1.0, Linux.
Create a notebook cell with only the word "Section" and apply the format "Section" to it. Then create a variable x and evaluate it. Then print the two-cell notebook to a pdf file. (We often have to pass these forth and back via email to mobile users.) The resulting pdf file is just under 1MB big. A few more modest additions, and Mma print-to-file yields a 2-3MB files from about one page of notebook. for comparison, my 800 page dense latex-generated book with R graphics consumes about 4MB.
can Mma be instructed to produce more compact pdf files? I know it can rasterize graphics, but this isn't really a graphics problem.
this comes from the folks from wolfram support:
The pdf files are large because they contain embedded fonts for faithful reproduction.
One way to reduce the file size would be to set certain options below to False.
This can be done from Mathematica menu by going to Format->Options Inspector->
Select 'Global Preferences' from Show option values-> go to
Notebook Options->Printing Options-> EmbedExternalFonts set to False.
Do the same for Notebook Options->Printing Options->EmbedStandardPostScriptFonts
set to False.
However, the PDF that is generated may not look exactly like you want it, especially if you send it to someone else. However, if you just want to keep the PDF on your machine, where the fonts exist anyway, this may be a good default option.
apparently, their developers are working on the problem, too.

General question - copy, cut, paste

How do the applications transfer the copied strings into each other? Is this a clipboard usage? If so, how can i access the clipboard in a program?
Edit: I'm interested in Windows systems, I know a bit of C#, and C++.
Yes, cut-and-paste is usually done using the system-wide clipboard.
In both Windows Forms and WPF applications, there are (different) classes called 'Clipboard', which contain the stuff you need to access the system clipboard.
Basically, the clipboard allows you to put pretty much anything on to it, along with markers that say what format the data is in. You can put the same data on in lots of different formats. That's how, for example, you can cut and paste a part of a spreadsheet in Excel into Notepad - Excel has put the data onto the clipboard in both a native Excel format and a plain text format.

What's the best approach for modifying PDF interactive form fields on iOS?

I've been doing some head banging on this one and solicit your advice.
I am building an app that as part of it's features is to present PDF forms; meaning display them, allow fields to be changed and save the modified PDF file back out. UIWebViews do not support PDF interactive forms.
Using the CGPDF apis (and benefit from other questions posted here and elsewhere), I can certainly present the PDF (without the form fields/widgets), scan and find the fields in the document, figure out where on the screen to draw something and make them interactive.
What I can't seem to figure out is how to change the CGPDFDictionary objects and write them back out to a file. One could use the CGPDF Apis to create a new PDF document from whole cloth, but how do you use it to modify an existing file?
Should I be looking elsewhere such as 3rd party PDF libs like PoDoFo or libHaru?
I'd love to hear from anyone who has successfully modified a PDF and written it back out as to your approach.
I once did this incredibly cheaply by munging through the PDF -- I mean using regular expressions -- and just dirtily changing the actual raw text of the raw PDF data file.
It can work perfectly in simple situations where you are easily able to find the value in question.
No idea what you're trying to do here but a lateral thought! Hope it helps!

Is CFE_LINK stored in RTF RichEdit 3.0?

I am using MS TextServices to implement windowless rich text editing and setting CFE_LINK to create hyperlinks. This all works but when I save the text to my internal buffer for writing to a file the CFE_LINK effect isn't saved.
I have (tried to) ensured that AutoDetectURL is OFF.
I am using EM_STREAMOUT to save from editor to buffer, as UTF-8 as RichEdit doesn't seem to work with Unicode.
I've looked at the saved RTF and looked at the MS RTF Specs and I can't see what control word would be used, so now I am worrying that it's not actually saved.
From my experience, the answer seems to be No. The richedit control creates the hyperlink formatting on the fly, but does not store it.
Six years ago or so I spent a lot of time trying to achieve what you are probably trying to do, using riched20.dll (at the time, version 3 of the richedit control). I wanted to have "proper" hyperlinks in a notebook application: the url would be marked as hidden text, while the description text would be underlined and clickable. The best I could do was to achieve this at runtime, marking arbitrary stretches of text with CFE_LINK. After saving and reloading the rtf stream, the changes would be gone. No amount of asking around did any good, either, though that was well before StackOverflow :)
My solution would be to replace richedit with a third-party control, such as TRichView, which can do what you want.

Resources