VISIO - How to set grid lines such that each character appears in 1 square and each square contains only 1 character using fixed font - visio

What I am trying to do is to enable the user to fill a report design form using fixed font. Only older people have seen such forms for coding and report design :)
Question:
Using VISIO, how to set grid lines such that each character appears in 1 square and each square contains only 1 character using a fixed font such as Courier New? I am open to completely different approaches if any, even if it involves coding in VBA or C#, I know some.
I tried different values for "Minimum Spacing" but I can't get the desired result.
EDIT
I also attempted to place a grid image in the background and put the textbox in front, still monospaced font characters overlap with lines...
Edit I also tried this VBA Code:
Sub Test()
Dim I As Integer
Dim D As Double
Dim X1 As Double
Dim Y1 As Double
D = 0.13
X1 = 1.373
Y1 = 10.04
For I = 1 To 20
Application.ActiveWindow.Page.DrawLine X1, Y1, X1, Y1 + 1
X1 = X1 + D
Next
End Sub
Which produced the following "bad" result - All this suggests the the implementation of Courier New is not really fixed in width!

The Visio grid doesn't work in that way. You need to use a proper grid shape. There is one at More Shapes -> Business -> Charts and Graphs -> Charting Shapes. Set the columns and rows to what you need and then resize.
Example here - using font Liberation Mono.

Related

Rename multi-frame dicom images

I have a dicom file that contains 110 images and their names are random. I am trying to rename them according to their SliceLocations (n) and rewrite them with the dcm extension, i.e., n(1).dcm, n(2).dcm, …
Any suggestions would be appreciated.
I tried
image_list=dir('*.dcm');
for i=1:110
img=dicomread(image_list);
imgHdr = dicominfo(image_list(i).name);
for j = size(img,4);
dicomwrite(img(:,:,:,j),['n(' int2str(j) ').dcm'],imgHdr,'CreateMode','Copy');
end
end
Slice location (0020,1041) is an optional attribute for image plane module. There is no guarantee that tag will have any value. Your best option is to use the Image Position (Patient) (0020, 0032) attribute. This will have x, y, and z coordinates of the upper left hand corner (center of the first voxel transmitted) of the image. See DICOM standard PS 3.3 - 2011 (PDF), Annex C.7.6.2.1, for further explanation.
NOTE: This answer applies to "frames," not "slices." The two are apparently different things for DICOM files.
One convenient option, if you don't need exactly the naming scheme in your question, is to use the 'MultiframeSingleFile' option in the dicomwrite function:
X = dicomread('MultiFrameFile.dcm');
dicomwrite(X,'n.dcm','MultiframeSingleFile',false);
This will produce files named 'n_01.dcm', 'n_02.dcm', ...
Otherwise you can use a simple for loop in conjunction with int2str:
X = dicomread('MultiFrameFile.dcm');
for i = size(X,4);
dicomwrite(X(:,:,:,i),['n(' int2str(i) ').dcm']);
end

itextsharp - extracts text backwards

Can't for the life of me figure out why when I extract text using iTextSharp, some of the text comes in backwards.
using (iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(#"C:\Temp\pdftest\sample.pdf"))
{
string sText = iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(reader, 1, new iTextSharp.text.pdf.parser.LocationTextExtractionStrategy());
}
*Reason I using a LocationTextExtractionStragegy is because I will be using coordinates to pull the text from this position. I've just included a crop of the full PDF for my example. If I use a SimpleTextExtractionStrategy, the "B uy 5 egt 5" and " eerf" don't show up.
Output (from sample code):
B uy 5 egt 5
eerf
4x6 PRINTS Download free
CVS Mobile App.
Promo code O H m OBILe PICS
sed items available in all stores We reserve the right to
There's definitely something weird going on the with "eerf". In the pdf, the cursor goes horizontal when you try to select it (Big red FREE).
[
If I use acrobat professional, Advanced -> PDF Optimizer, select Transparency, then save the file, the text is extracted correctly and the "Red Free" is selectable.
So two questions, how can I emulate the PDF Optimizer in iTextSharp?
Or, how can iTextSharp read this text correctly?
As you can see this is my first post so don't beat me up too bad.
Additional Test:
I even extended the LocationTextExtractionStrategy and RegionTextRenderFilter so I could return the coordinates of each Textchunk. The weird thing about the "Big Red" Free, is the F's start and end points was the exact same. Same case with the R, and two E's. I would have expected that the end point was equal to the start point + the width of text.

x and y coordinate of text using itextsharp

When i extract text using itextsharp, i will get x and y coordinate of text. By using these 2 coordinates if i convert text from pdf to html based on x y position the text position chnages . to get x ,y coordinates i used
Vector curBaseline = renderInfo.GetBaseline().GetStartPoint();
float x=curBaseline[Vector.I1];
float y= curBaseline[Vector.I2];
for example : when i extract text using above method say x=42 and y=659;
" < span style=left:{0}px;bottom:{1}px;position:relative;\">",curBaseline[Vector.I1],curBaseline[Vector.I2]); the position changes . can you help me how to set position of text default as pdf.?????
Posted as answer...
If i recall correctly, PDF uses a coordinate system which starts in the left corner at the BOTTOM of the page, not at the Top. So every coordiante is wrong, when you use it directly in html. You will have to convert the values.
Your pdf document should have something like document.actualheight, simply subtract your value from that....

How to retrieve screen size/resolution in MS Access VBA to re-size a form

I have two popup forms (parent/child) that I want to be able to automatically re-size depending on the size of the screen.
How can I retrieve the size of the screen in order to achieve this.
For Access 2010 64 bit, you will need to add PtrSafe before Function.
Declare Function GetSystemMetrics32 Lib "User32" _
Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
Sub ScreenRes()
Dim w As Long, h As Long
w = GetSystemMetrics32(0) ' width in points
h = GetSystemMetrics32(1) ' height in points
End Sub
More info: http://support.microsoft.com/kb/210603
For VBA, a simpler (and therefore possibly more portable) solution might be:
Application.UsableHeight
Application.UsableWidth
As found at Adjust userforms to fit in screen. I am using this successfully with Word 2007 VBA. In my case, Application.UsableWidth gives the actual screen width, Application.UsableHeight gives the actual screen height, minus the height of Windows' taskbar.

MATLAB: latex interpreter font spacing

The font spacing in TeX-typeset equations in MATLAB defaults to being highly compressed. Is there a way to increase the amount of spacing, so that, for example, the numerator and denominator of a fraction do not make contact with the line separating the two?
plot(1:10,rand(1,10));
set(gca,'FontSize',18);
legend('$\frac{xy}{\exp\left(\frac{x}{y}\right)}$');
set(legend(),'interpreter','latex');
I think the easiest way is to use some LaTeX trickery.
Long story short, in LaTeX $ ... $ is used for inline math, but for display math, you should either use \[ ... \] or the legacy way of doing the same $$ ... $$. For LaTeX documents, don't use the latter, but for MATLAB it should be enough.
The difference between inline math and display math, is like the difference between using backticks (``) and indentation in StackOverflow. The first will show your code in-between text, the latter in-between paragraphs. With math, only display mode math will have decent lay-out for larger formulas.
So the following code should fix your problem:
plot(1:10,rand(1,10));
set(gca,'FontSize',18);
legend('$$\frac{xy}{\exp\left(\frac{x}{y}\right)}$$');
set(legend(),'interpreter','latex');
If you want even more, you might want to consult the Not So Short Introduction To LaTeX2e which gets you started with a lot of the tricks of the LaTeX trade.
edit:
What I tend to use as a trick to improve spacing in formulae is using phantoms (\phantom, \vphantom, \hphantom), but \vspace or \vskip might be a little cleaner to use.
Looking through the list of properties for the legend, there doesn't seem to be any way of specifying a line spacing that is consistent with automatic positioning. You can fudge the line spacing by enlarging the box, however, by changing the final entry (height) in the OuterPosition property. It seems the placement of the box is based on its bottom-left corner, so if your legend box is in a North position then you will also need to reduce the second entry (y-position) by an equal amount.
In this example I increase the height of a North-positioned legend box by 25% (which I have found that gives nice results), which increases the line spacing.
h = legend(s1,s2,s3, 'location', 'northeast');
set(h, 'fontsize', 16, 'interpreter', 'latex')
outerposition = get(h, 'OuterPosition');
delta_h = 0.25*outerposition(4);
outerposition(2) = outerposition(2) - delta_h;
outerposition(4) = outerposition(4) + delta_h;
set(h, 'OuterPosition', outerposition)
You have to be wary about resizing the figure after running this code fragment, since changing the OuterPosition property clears the automatic placement of the box with respect to the plot axes. If you resize the figure the legend box will go walkabouts.