When I edit an existing yaml file extra string "!" are getting added to value of map-node whose value is string like "'dd'-'MM'". This is happening only during editing but not I create a new YAML file with same data.
e.g:
Test:
- Key1: "'dd'-'MM'"
- Key2: ABC
...
If I edit the above file programatically the result is
Test:
- Key1: !<!> "'dd'-'MM'"
- Key2: ABC
...
I have verified my value string which I am setting, it definitely without "!" string characters.
This is a known bug in the library. Please see the bug report on the project page.
Related
As the title states, I am currently struggling to force line-breaks ("\n" respectively "\r\n") in a pdf-acro-field. I am using OpenPdf and FlyingSaucer (see dependencies for details) and managed to enable multi-line and rich-text of fields by setting the bit-flags 13 and 26 of the "Ff" property.
I was using the PDF-Reference ISO-3200_2008 as a guide (starting on page 442).https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf
Issue
I read an existing PDF and fill the acro fields programmatically. Something like this:
acroFields.setField("address", content);
The content is just a simple string with some newline characters. Nothing special.
My text is too long and will have to break at some point. When multiline is enabled, the text will break, but only if it reaches the end of the line. Basically, what I want to display is something like an address and some additional information on top. But not all lines are equal in size and for example I want to have information 1 and 2 on the same line and info 4 and 5 each on separate lines.
What I had in mind
<h2>What I want</h2>
<pre>Company XYZ
A brand here</pre>
<pre>Another Section
With some more info that goes further to the right
phone, email, website</pre>
<br>
<h2>What it looks like</h2>
<p>Company XYZ
A brand here
Another Section
With some more info that goes further to the right
phone, email, website</p>
Questions
Is there a way to implement line-breaks in PDF in general?
Is there a way to implement line-breaks programmatically?
Can I do this in OpenPdf or FlyingSaucer?
If there is no simple way - what would be a viable workaround?
Dependencies
compile group: 'com.github.librepdf', name: 'openpdf', version: '1.3.3'
compile group: 'com.googlecode.juniversalchardet', name: 'juniversalchardet', version: '1.0.3'
compile 'org.xhtmlrenderer:flying-saucer-core:9.1.18'
compile 'org.xhtmlrenderer:flying-saucer-pdf-openpdf:9.1.18'
It did not work, because the content (input coming from parsed html file) had \r\n in it, but somehow it does only work with \n so I did the following:
content.replaceAll("\\\\r\\\\n", Chunk.NEWLINE.getContent()); // 2nd param is just "\n"
This fixed my issue.
I am currently trying to parse file with contents something like this using sscanf:
param1 = value1
...
param5=value5
...
paramn = valuen
I need to extract values by param name.
For example:
sscanf((char*)rtext, "param5=%s", label)
I am trying to get "value5" into string variable "label".
This example returns 0 coincidences. I have tried various specificators with no luck. Looks like this not working because there is another symbols including new line before "param5". How to tell sscanf to skip this until "param5" will be found? Thank you.
Read file line by line until you will get the successful scan.
Been searching around for this for a couple hours, can't find anything which will do this correctly. When writing a string to a text file, a blank line is outputted at the end.
writeString = New StreamWriter(path, False)
writeString.WriteLine("Hello World")
writeString.Flush()
writeString.Close()
This will write the following to file:
Hello World
(Blank Line)
I've tried removing last character of string (both as regular string with varString.Substring(0, varString.Length - 1) and also as a list of string with varList.RemoveAt(varList.Count - 1)) but it just removes the literal last character.
I've also tried using Replace(vbCrLf, "") and many variations of it but again, they only remove literal new lines created in the string, not the new line at the end that is magically created.
Preferably, I'm seeking a method which will be able to remove that magical newline before the string is ever written to the file. I found methods which read from the file and then write back to it which would require Write > Read > Write, but in all cases the magical new line still appeared. :(
If it's important to note: The file will contain a string which may contain actual new lines (it's 'Song Artist - Song Title', though can contain other information and new lines can be added if the user wishes). That text file is then read by other applications (such as mIRC etc) of which output the contents by various means depending on application.
Eg. If an application were to read it and output it into a textbox.. the new line will additionally output to that textbox.. which is a problem! I have no control of the applications which will read the file as input considering it's the client which decides the application, so the removal of the new line needs to be done when outputted.
Help is appreciated~!
Use the Write method instead of WriteLine. The WriteLine method is the one adding a blank 0 length line to the file because it is terminating the "Hello World" string with a newline.
writeString.Write("Hello World")
I was trying to write a program where I can upload a file that has first and last names in it and create a new file with the first letter of each first name followed by the last name.
The file that I created is a textfile and the lines would be like this:
firstname1 lastname1 (for example, john smith)
firstname2 lastname2 (for example jane jones)
firstname 3 lastname3 (for example jane doe)
etc...
I want to create a file that would look like this:
jsmith
jjones
jdoe
The issue that I am getting is that when I open the file in python it gives me all of these weird unwanted characters before getting to the actual text of the file. The book I am using to learn from doesn't say anything about this which is why i am posting here.
For example when I upload the file and run the following command:
newfile=open("example.file.rtf","r")
for i in newfile:
print(i)
I get this:
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf540
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\f0\fs24 \cf0 name 1\
name 2\
name 3 \
name 4 \
The actual text that I wrote in the textfile was just this:
name 1
name 2
name 3
name 4
Why is this happening? Why wouldn't it just show the plain text? If I can't get it to do that, how can I get around this issue for when I run loops through the file.
You are writing the file in RTF ("Rich Text") format, which is not plain text. Those "weird unwanted characters" are being written there by your editor. Use a plain text editor like Notepad to create your file, or explicitly save it as plain text.
I want to read a text file in Objective-C till a specified delimiter
For eg:if this is my .txt input file ,
#abc = name1$
#xyz = name2$
i want to read abc and assign it in the string variable key,and read name1 till $ and assign it to variable value
for eg:expected output
key = abc
value= name1
key = xyz
value= name2
Kindly suggest me some solution, which functions are available in objective-C, what is its syntax.
Get the -filedescriptor from the NSFileHandle, then use fdopen to retrieve a FILE *, finally use fscanf to read formatted input.
Or, read the whole file into an NSString and -enumerateLinesUsingBlock: to act on each line individually.