I have a seemingly simple question, but I can't find the answer. I have a pre-existing pdf form. Filling in the form manually, one of its text fields shows its value in boldface type. When using HexaPdf to fill this field, the text should also appear in boldface, but it appears in regular type.
I fill the field with
doc.acro_form.field_by_name('text1').field_value = #record.value
To get this to be shown in boldface, I have tried the following, to no avail:
doc.acro_form.field_by_name('text1').set_default_appearance_string(font: 'Helvetica-Bold', font_size: 0)
This gets the error message "The requested font 'Helvetica-Bold' in variant 'none' couldn't be found".
Then I tried:
doc.acro_form.field_by_name('text1').set_default_appearance_string(font: 'Helvetica', variant: :bold, font_size: 0)
This gets: "unknown keyword: variant".
The configured fonts for the document are:
{"Times"=>[:none, :bold, :italic, :bold_italic], "Helvetica"=>[:none, :bold, :italic, :bold_italic], "Courier"=>[:none, :bold, :italic, :bold_italic], "Symbol"=>[:none], "ZapfDingbats"=>[:none]}
So Helvetica with variant :bold should be available.
Could someone please let me know the correct syntax? Thanks in advance!
I got this answer from #gettalong on github:
"It is indeed an issue as there is no way to do this currently with that method - I will fix it for the next release. You can use the following work-around until then:"
name = doc.acro_form.default_resources.add_font(doc.fonts.add('Helvetica', variant: :bold).pdf_object)
doc.acro_form.field_by_name('text1')[:DA] = "0 g /#{name} 0 Tf"
Thank you very much!
With the HexaPDF 0.18.0 release this is now directly possible by using the font_options argument for #set_default_appearance_string. No more work-arounds needed!
Related
I'm using react-ace to write a custom JS Editor. I want to throw a custom error in the gutter when the user tries to import a module other than ones from a list I specify. How do I go about doing this? I've tried extending a custom mode but this seems to only customize syntax highlighting, I've peaked around ESLint but am not sure if that's the right path. Please help I'm quite lost.
To get the data from the editor, use getValue() and then scan the string for the modules you don't want to see and then use the same row and column number and display the error using setAnnotations
editor.getSession().setAnnotations([{
row: 1,
column: 0,
text: "Error Message",
type: "error" //This would give a red x on the gutter
}]);
A few days ago I asked a question about Drupal 8 YAML Form Module: Populate Select Element. I found a solution that it works fine for me.
But now I've got a new doubt. I would like to change the value of a Hidden element and depending of this value, to show some elements in the form or not. I'm trying to implement the hook hook_yamlform_element_info_alter(array &$elements) and I do $elements['hidden_element_name']['#value'] = 'New value of the hidden element' but it doesn't work.
Any ideas? Thanks in advance!
Here is the solution: How do I change the value of a Hidden element?
Basically, I've implemented hook_form_FORM_ID_alter() and I do:
$form['elements']['hidden_element_name']['#value'] = 'New value of the hidden element';
I hope it helps someone!
I'm using the JSQMessages framework which is super awesome but I'm trying to enable hyperlinks in both the sent and received text messages - essentially i want to apply a find and replace system where certain words are replaced with pre determined hyperlinks, for example the word "stackoverflow" would turn into a hyperlink to stackoverflow when the user presses the send message button. The message receiver would then receive the hyperlink.
I have the find and replace system working fine however I'm struggling with the hyperlinks. As far as I can tell there doesn't seem to be any way to add hyperlinks to the messages as the "text" message element used to pass execute the message is an NSString and therefore cannot have a url attributed to it. However I hope I'm wrong, are hyperlinks, i.e. a word that links/executes a url when it's tapped, in text messages possible? If so what would be the recommended approach?
Thanks,
Matt
And for Swift 2.0 :
let attributes: [String:AnyObject] = [NSForegroundColorAttributeName:UIColor.redColor(), NSUnderlineStyleAttributeName: 1]
cell.textView!.linkTextAttributes = attributes
Please use following code in collectionView cellForItemAtIndexPath
Activate the data indicator as well..
cell.textView.dataDetectorTypes=UIDataDetectorTypeAll;
cell.textView.linkTextAttributes = #{ NSForegroundColorAttributeName : [UIColor jsq_messageBubbleBlueColor],
NSUnderlineStyleAttributeName : #(NSUnderlineStyleNone | NSUnderlineStyleNone) };
from basil cheatsheet:
b.objectStyle(”myStyle”); // return or create style with given name
But when I try it (on a text frame):
b.selection().appliedObjectStyle = b.objectStyle("CAPTION");
Nothing happens.
While this works:
b.selection().appliedObjectStyle = app.documents[0].objectStyles.item("CAPTION");
So what is a good use of the 'b.objectStyle("CAPTION");' method apart from creating a object style?
You discovered a bug in basil.js 1.08. This will be fixed in the next version.
Please use b.doc().objectStyles.item("CAPTION"); until then. That also goes for
b.characterStyle(); and b.paragraphStyle(); unfortunately. Thanks.
I have this input of type "Submit" that Watir cannot see. I can identify it by ID, but it doesn't turn up in browser.text_fields, or by any other idenfication method. The ID is dynamically generated so I cannot use it for testing. Any ideas on how to make this readable? I'm willing to change the WATiR source code if necessary.
<INPUT id=t8CPm value=Submit type=submit>
I have obviously tried text_field(:value, 'Submit') and text_field(:type, 'Submit'), and I get an "Unable to locate element" error.
Did you try treating it as a button element? Inputs of type submit are generally considered to be a button because the browser generally renders them that way.
try
browser.button(:value, 'Submit').flash
and see if it works for you
I changed INPUT_TYPES to ["text", "password", "textarea", "submit"] in the TextField class of input_elements.rb and there it was.
I should also probably edit the collections to read the type too.
Edit: I am an idiot and I didn't need to do this, but I'm leaving it here in case anyone else needs to identify a real dynamic-id custom-type text field, not a fake dynamic-id custom-type text field otherwise known in my particular case as a "button".