I have a scenatio to export a 25000 characters text , which is does not have any space break between character. it mean single word with 250000 length . but realtime a word length cannot be more then 25. Anyhow the text should have exported into pdf using Aspose word template. but it doesnot export 25000 length , instead export 4578 characters into pdf , remaining are discarded in pdf. but i could get the 25000 length character in my code before calling that pdf export method using aspose.
But the text are properly exported into pdf , if you give positive scenario text upto any characters length .
Let me know, is there any solution why the text are discarded , if gives contineous text without break?
Please use CompatibilityOptions.GrowAutofit property as shown below to get the desired output.
Document doc = new Document(MyDir + "SupervisionReportTemplate - Copy.docx");
DataTable table = new DataTable("SupervisorComment");
table.Columns.Add("GeneralVisitComment", typeof(string));
var newRow = table.NewRow();
newRow["GeneralVisitComment"] = File.ReadAllText(MyDir + "25000 contineous character length.txt", Encoding.Unicode);
table.Rows.Add(newRow);
doc.MailMerge.ExecuteWithRegions(table);
doc.CompatibilityOptions.GrowAutofit = true;
doc.Save(MyDir + "18.4.docx");
I work with Aspose as Developer Evangelist.
Related
I am trying to create a PDF File to export using jsPDF library. In one of the lines I am trying to write a word that contains this 'ū' letter,
doc.text('Hūla', 20, 30);
However, when doing so the exported file doesn't contain this letter but instead it becomes
'H k l a' with spaces in between and a k instead of the ū.
What can I do in order to have this printed properly?
The solution was to use a font that supports this. I had to try multiple ones in order to get it working with this letter ū (it is not a specific language)
The font was Amiri. It also supported the Arabic font.
I need to update a bilingual dictionary written in Writer by first parsing all entries into their parts e.g.
main word (font 1, bold)
foreign equivalent transliterated (font 1, italic)
foreign equivalent (font 2, bold)
part of speech (font 1, italic)
Each line of the document is the main word followed by the parts listed above, each separated by a space or punctuation.
I need to automate the process of walking through the whole file, line by line, and place a delimiter between each part, ignoring spaces and punctuation, so I can mass import it into a Calc file. In other words, "each part" is a sequence of character (ignoring spaces and punctuation) that have the same font AND font-style.
I have tried the standard Search&Replace feature, and AltSearch extension, but neither are able to complete the task. The main problem is I am not able to write a search query that says:
Find: consecutive characters with the same font AND font_style, ignore spaces and punctuation
Replace: term found above + "delimiter"
Any suggestions how I can write a script for this, or if an existing tool can solve the problem?
Thanks!
Pseudo code for desired effect:
var delimiter = "|"
Go to beginning of document
While not end of document do:
var $currLine = get line from doc
var $currChar = get next character which is not space or punctuation;
var $font = currChar.font
var $font_style - currChar.font_style (e.g. bold, italic, normal)
While not end of line do:
$currChar = next character which is not space or punctuation;
if (currChar.font != $font || currChar.font_style != $font_style) { // font or style has changed
print $delimiter
$font = currChar.font
$font_style - currChar.font_style (e.g. bold, italic, normal)
}
end While
end While
Here are tips for each of the things your pseudocode does.
First, the easiest way to move line by line is with the TextViewCursor, although it is slow. Notice the XLineCursor section. For the while loop, oVC.goDown() will return false when the end of the document is reached. (oVC is our variable for the TextViewCursor).
Get each character by calling oVC.goRight(0, False) to deselect followed by oVC.goRight(1, True) to select. Then the selected value is obtained by oVC.getString(). To ignore space and punctuation, perhaps use python's isalnum() or the re module.
To determine the font of the character, call oVC.getPropertyValue(attr). Values for attr could simply be CharAutoStyleName and CharStyleName to check for any changes in formatting.
Or grab a list of specific properties such as 'CharFontFamily', 'CharFontFamilyAsian', 'CharFontFamilyComplex', 'CharFontPitch', 'CharFontPitchAsian' etc. Character properties are described at https://wiki.openoffice.org/wiki/Documentation/DevGuide/Text/Formatting.
To insert the delimiter into the text: oVC.getText().insertString(oVC, "|", 0).
This python code from github shows how to do most of these things, although you'll need to read through it to find the relevant parts.
Alternatively, instead of using the LibreOffice API, unzip the .odt file and parse content.xml with a script.
As the title says Is there any option to print the arabic content ZPL Printer.
Thing tried is adding the font and initiate the print
^XA ^FX ^FR ^CF0,40^CI28^FO130,45^FH^FD محاكمة Font file^FS ^XZ
My printer has TT0003M_.TTF font installed but it shows "????" when i tried to print arabic using
^XA^FO50,50^AE:TT0003M_.TTFN,50,50^FDمحاكمة^FS ^XZ
Any idea how to install a font and print the arabic text using ZPL language?
^XA^CI28^CW1,E:TT0003M_.TTF^LL130^FS
^PA0,1,1,1
^FO50,50^A1N30,30^FDمحاكمة
^FS
^XZ
Updated this answer to match the other question
Also found this on the Zebra KB - https://km.zebra.com/kb/index?page=content&id=SO6820&actp=RSS
Maybe it is too late to answer your question :) but I have the same issue and I solve it so I want to share my answer.
1- You can use ZebraDesigner 3 or "BarTender Designer" to design your ZPL code.
2- Use this font ZEBRA Swiss Unicode, it support Arabic characters.
3- After finish your design click Print and check the box "Print to file" then click Print and save the file with extension ".prn".image
4- Open the file using notepad and you will see the ZPL code.
5- Here is the result
^FPH,3^FT225,224^A#N,141,141,TT0003M_^FH\^CI28^FDمحاكمة^FS^CI27
Or the full result in this image.
6- If you are using online zpl viewer like this don't worry if you can't see the Arabic characters, but if you want to print you will not see any problems
7- Don't try to make your text in the center ,usin this will cut and reverse the Arabic text
The default is Field Text > "^FT"or with x,x"^FTx,y" "^FT225,224" like in this code:
^FPH,3^FT225,224^A#N,141,141,TT0003M_^FH\^CI28^FDمحاكمة^FS^CI27
If you try to center,right or left your Arabic text it will use Field Block "^FB" "^FB383,1,75,C" it is different than "^FT" and it is not supporting Arabic text.
^FPH,3^FT225,224^A#N,141,141,TT0003M_^FB383,1,75,C^FH\^CI28^FDمحاكمة^FS^CI27
you can see Field Block properties in this book at page 169
8- I'm not sure but I tried very hard and there is no way to center the arabic text until now.
But I have a trick using ^FT width to calculate the center
Using this function ,it is c#:
//Define page_width and font_width
int page_width = 600;
int font_width = 18;
call the function it will return X position (center).
string ar = "محاكمة محاكمة محاكمة";
string FT_center = center_line(ar);
here is the function, 315 = middle width or center point
public string center_line(string arabic_text)
{
int text_width = (arabic_text.Length * font_width) / 2;
decimal d = ((page_width - (text_width / 2)));
int x = Convert.ToInt16(Math.Round(d)) ;
x = 315 + (text_width / 2);
return x.ToString();
}
use it like this:
^FPH,3^FT"+FT_center+#",224^A#N,141,141,TT0003M_^FH\^CI28^FDمحاكمة^FS^CI27
Article http://runrev.com/newsletter/june/issue135/newsletter4.php shows how to display a table in a text field. Is it as well possible to display in-line images?
You'll have to mess with the htmltext of the field in order to insert the online images, but it can be done. Put the htmltext of the field into a variable, then insert a line of html, as in
put "<img src=" & quote & "http://www.site.com/image.png" & quote & ">" after line x of tHtmlText
and then set the htmltext of the field back to tHtmlText
If the image is in your stack, you can use
put "%" into fld 1
set the imageSource of char 1 of fld 1 to 1014
Where % is an arbitrary character and 1014 is the image id of an arbitrary image. You can set the imageSource of any character in a field.
I'm currently trying to write a script which would run through a word document and output to a text file all the lines that are written in a certain font.
So if I had the document:
"This is the first line of the document.
This is the second line of the document.
This is the third line of the document."
And say normal lines are Times New Roman, bold is Arial, and italics is Sans Serif.
Then, ideally, I could parse the document for all lines in Arial and the text file output would have the line:
This is the second line of the document.
Any idea on how to do this from a script? I was thinking about first converting the doc into xml, but I do not think this is possible within a script.
You'll want to use the FIND object, and the FONT property of the FIND object.
So, something like this:
Public Sub FindTest()
Dim r As Range
Set r = ActiveDocument.Content
With r.Find
.ClearFormatting
.Style = "SomeStyleName"
Do While .Execute(Forward:=True, Format:=True) = True
'---- we found a range
Dim duperange As Range
Set duperange = r.Duplicate
Debug.Print r.Text
Loop
End With
End Sub
Note that where I've specified Style, you could specify font formatting via the FIND.FONT object, or various other formatting options. Just browse around the FIND object to see what's available.