I have inherited ASP.NET project, which is generating some word documents using Gios.Word.WordDocument.
My problem is, everything works fine on my computer, with czech locale, but on english version server some diacritics are missing. I have no experiences with this library, so I don't know where to start.
Basically it works like this:
Gios.Word.WordDocument rd = new WordDocument(WordDocumentFormat.A4);
Font fontRegular = new Font("Arial", 10, FontStyle.Regular);
rd.SetFont(fontRegular);
var rt = rd.NewTable(fontRegular, Color.Black, rows, 2, 10);
WordCell title = rt.Rows[0][0];
title.SetFont(fontRegular);
title.Write("dle vzoru přílohy č. 2 Nařízení vlády č. 201/2010Sb.");
rd.SaveToFile("/* path to file */");
The bad result on the server looks like this dle vzoru prílohy c. 1 Narízení vlády c. 201/2010Sb.
I have tried to set up font this way:
Font fontBold = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point, 238); // 238 eastern europe charset byte
But no chage is happend.
Finally I have modified this library to generate RTF in unicode. Modified version source is published on:
https://github.com/FandaCZ/Gios.Word
Related
I am updating web.config file of Asp.net mvc dynamically while installation using installshiled script.
It works correctly on all machines; however it generates ??? charaters on Chinese machine at the start of web.config file like below.
???<?xml version="1.0" encoding="utf-8"?>
Please suggest how this problem can be please.
Below is the Installshield code
Using installscript I am finding connection string place holder and replacing that with connection string generated while installation.
szIniFile = INSTALLDIR^"AppDir\\Web.config";
szSearchStr = "[COONECTIONSTRING]";
FindAndReplaceInFile(szIniFile, szSearchStr,strWebConString);
function FindAndReplaceInFile(szFile, szSearchStr,szReplaceStr)
STRING szReturnLine,szString, szSecPart,szFirstPart,svString,szArchive;
NUMBER nResult,nSubPos,nSearchStrLen,nLineNumber;
begin
nSearchStrLen = StrLength(szSearchStr);
nResult=FileGrep (szFile, szSearchStr, szReturnLine, nLineNumber,
RESTART) ;
NumToStr ( svString, nResult );
while (nResult=0)
nSubPos = StrFind(szReturnLine, szSearchStr); //get position of szSearchStr
StrSub (szFirstPart, szReturnLine, 0, nSubPos);
StrSub (szSecPart, szReturnLine, nSubPos+nSearchStrLen, StrLength(szReturnLine));
szString="";
szString = szFirstPart+szReplaceStr+szSecPart;
FileInsertLine (szFile, szString, nLineNumber, REPLACE);
nLineNumber = nLineNumber + 1;
nResult=FileGrep (szFile, szSearchStr, szReturnLine, nLineNumber,CONTINUE) ;
endwhile;
end;
You had a byte order marker (BOM) at the start of the file.
I suspect that what has happened is you opened a UTF8 encoded file in as a different encoding. This misread the unnecessary BOM and corrupted it. When you saved it, the unknown character markers replaced the BOM.
To rectify this, you need to encode your config as UTF8 without a BOM. Edits should then be safe, unless you have other characters outside the ASCII range in your file.
I'd like to print dialogs in french using pyRevit scripts. As soon as I include an accent like "ê" in my code, the pyRevit script doesn't even execute.
But if I do for instance print "être" in RevitPythonShell, no problem.
Why? Why the different treatment, and can it be handeled with pyRevit?
Thanks a lot,
Arnaud.
It is all about encoding and decoding. I reccommend you to read this nice article on the subject : http://sametmax.com/lencoding-en-python-une-bonne-fois-pour-toute/
You should prefix all your scripts with : # coding: utf8
# coding: utf8
__title__ = "TextEncoding"
print("être")
PyRevit output :
Im not sure about PyRevit, but I can use French characters when making Revit Dialogs in the RevitPythonShell like this:
dialog = TaskDialog("être")
dialog.MainContent = "être"
dialog.Show()
And when using Winforms like this:
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import Form, Label
form = Form()
form.Width = 300
form.Height = 100
label = Label()
label.Text = 'Here is some French Text: "être"'
label.Width = 280
label.Height = 70
label.Parent = form
form.ShowDialog()
Could you post some code showing in what instance it fails?
I'm newbie in indesign scripting stuffs.So I apologise as I couldn't post my trials.
Objective:
I have an indd document which will have figure caption,label etc. I need to copy content(figure which is editable) from other indd file to this document where related figure label exists.
For example:
sample.indd
Some text
Fig.1.1 caption
some text
I need to copy the content of figure1.indd and paste into the sample.indd document where Fig.1.1 string exists and so on. Now I'm doing it manually. But am supposed to automate this.
So, I need some hint how to acheive it using extendscript?
I have found something like below to do this, but I don't have any clue to develop it further and also am not sure whether this approach is correct to get my result. Pls help me
myDocument=app.open(File("file.indd"),false); //opening a file to get the content without showing.
myDocument.pages.item(0).textFrames.item(0).contents="some text";
//here I could set the content but I don't knw how to get the content
// ?????? Then I have to paste the content into active document.
I found the script for my requirement.
var myDoc = File("sample.indd");//Destination File
var myFigDoc = File("fig.indd");//Figure File
app.open(File(myFigDoc));
app.activeDocument.pageItems.everyItem().select();
app.copy();
app.open(File(myDoc));
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "FIG. 1.1 ";//Figure caption text
//app.findGrepPreferences.appliedParagraphStyle = "FigureCaption";//Figure Caption Style
myFinds = app.activeDocument.findGrep();
for(var i=0;i<myFinds.length;i++){
myFinds[i].insertionPoints[0].contents="\r";
myFinds[i].insertionPoints[0].select();
app.paste();
}
app.findGrepPreferences = app.changeGrepPreferences = null;
If acceptable for you, you can place an indesign file as link (place…). So a script could try to catch the "fig…" strings and do the importation.
Have a look at scripts that use finGrep() and place() command.
How to add under line under a spacebar. It is not adding space under the empty spaces.
I tried with 2-3 example and it failed to add underline under space.
1.
para = New Paragraph(New Chunk("abc. ", underlined_font))
cell = New PdfPCell(para)
cell.Border = 0
cell.BorderWidthBottom = 0
document.Add(cell)
Dim str_required_space As New String(" "c, 20)
para = New Paragraph(New Chunk(str_required_space, underlined_font))
cell = New PdfPCell(para)
cell.Border = 0
cell.BorderWidthBottom = 0
document.Add(cell)
I can't use border of cell as the length of the input string is uncertain. So I am using underline.
Please help to add spaces under space.
My Requirement image
Thanks
[Edit]
If I follow answer 1 then result would be like below
asdasd asdsad scasdnk kjashdk kasbas ckasbd ascuasc ksajcasc
asdansjdnasjakjsnasndasdmlaskdm
________________________________________________________________
But I need Below result.
asdasd asdsad scasdnk kjashdk kasbas ckasbd ascuasc ksajcasc
________________________________________________________________
asdansjdnasjakjsnasndasdmlaskdm
________________________________________________________________
I tried with Ansii Code. Not working for me :(
Dim str_required_space As New String(ChrW(32), (119 - (str_synopsis.Length Mod 119)))
para = New Paragraph(str_required_space)
cell = New PdfPCell(para)
cell.Border = 0
doc.Add(cell)
Please read chapter 2 of my book, more specifically the section about vertical position marks, separators, and tabs (section 2.2.6).
Looking at your image (ignoring the soft porn images on that site, please avoid such links in the future), I think you need a line as shown in figure 2.9 (the line under the names of the directors). The code that results in the PDF shown in that screen shot can be found here.
This is how it's done in Java:
Paragraph p = new Paragraph("abc.");
LineSeparator line = new LineSeparator(1, 100, null, Element.ALIGN_CENTER, -2);
p.add(line);
document.add(p);
It should be a no-brainer to adapt this code to C#. If you do experience problems, then you can find the ported versions of the book samples here.
What did you do wrong in your code?
This doesn't make sense:
para = New Paragraph(New Chunk("abc. ", underlined_font))
The content of the Chunk is trimmed, which explains why the spaces disappear. An alternative would be to use non-breaking space characters (ASCII code 160) instead of regular space characters (ASCII code 32).
Update
My previous answer was based on your image and it was the correct answer to your initial question. However: you have now changed your question (instead of creating a new question).
You can meet your requirement by using a page event, more specifically, by implementing the OnGenericTag() method. This method is described in chapter 5 of my book.
In Java, the implementation would look like this:
public void onGenericTag(PdfWriter writer, Document pdfDocument,
Rectangle rect, String text) {
Rectangle page = pdfDocument.getPageSize();
float x1 = page.getRight(pdfDocument.rightMargin());
float x2 = page.getLeft(pdfDocument.leftMargin());
float y = rect.getBottom() - 3;
PdfContentByte canvas = writer.getDirectContent();
canvas.moveTo(x1, y);
canvas.lineTo(x2, y);
canvas.stroke();
}
You need to create an instance of the page event with that implementation (e.g. a class that you wrote and that you named MyPageEvent) and declare that page event to the PdfWriter using the setPageEvent() method:
writer.setPageEvent(new MyPageEvent());
You can now declare you Chunk and Paragraph like this:
Chunk chunk = new Chunk(long_text);
chunk.setGenericTag("");
Paragraph p = new Paragraph(chunk);
document.add(p);
It is important that you construct your paragraph with only one Chunk object. If you have more than one Chunk in the paragraph, parts of the line will look thicker.
Using QRCode.net assembly to generate QRCode images for URLs, I've tried most of the properties / options available and the URLs first character is always replaced with an asterisk (*). As the QRCode text is to be a URL, this means that some QRCode reader apps don't recognise my QRCode as a valid URL. For now, I pad the URL with a ' ' space so you at least get '*http://myapp.com', instead of '*ttp://myapp.com', but this always happens..
QRCode.Net on CodePlex
Has anyone seen this before, or know which setting stops it, I've tried most, here's my code:
Dim iee As New ImageEncoder()
iee.AutoConfigurate = True
iee.ECI = -1
iee.Encoding = 4
iee.Fnc1Mode = 0
iee.ErrorCorrectionLevel = 0
iee.Version = 1
iee.ProcessTilde = False
iee.MarginSize = 10
iee.ModuleSize = 6
iee.StructuredAppend = False
iee.StructuredAppendCounter = 0
iee.StructuredAppendIndex = 0
iee.TextData = " http://myApp.com/?querystringdata=here")
Dim image As Bitmap = iee.Encode2Image()
Dim tempSitePath As String
tempSitePath = HttpContext.Current.Server.MapPath(HttpContext.Current.Session("dirTempPath"))
image.Save(tempSitePath + "loc_" + locid + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
This was bugged with them.. Ended up using a different library..
I found a demo library for QRCode.net.
http://www.codeproject.com/Articles/258779/Just-launched-new-open-source-project-QrCode-Net-a
This has downloadable source-code. I opened the solution, made a few changes to get the project to build and it created codes with no asterisk (*). I believe the demo code is older than this post, but perhaps the library has also been updated with a fix.