paragraph containing image gets broken when it overflows to following page - asp.net

I am trying to generate a PDF with iTextSharp for a library catalog. The format i am after is roughly like this :
a line for the title, followed by a line for the book information such as year, Isbn,pages .... followed by the abstract of the book wrapping around its cover image, something like what's done here
My problem is with the text and the image. I am using a paragraph as the parent container for another paragraph hosting the abstract and an image object.
Paragraph container = new Paragraph();
//cover is an object of type iTxtSharp.text.Image
cover.ScaleToFit(100f, 150f);
cover.IndentationLeft = 9f;
cover.SpacingAfter = 9f;
cover.Alignment = iTextSharp.text.Image.TEXTWRAP | iTextSharp.text.Image.ALIGN_RIGHT;
Paragraph blurb = new Paragraph(#pub.Abstract,propertyFont);
blurb.Alignment=Element.ALIGN_JUSTIFIED;
container.Add(cover);
container.Add(blurb);
using the above i get the desired behavior, however when my paragraph overflows to the following page, or when there is no abstract, the images start drifting to the center.
If i set blurb.KeepTogether to true, the image disappears.
I also tried to use a table with two columns, one for the abstract and another for the page and again the image disappeared.
How can i achieve this desired layout?

Related

Layout Paragraphs: Get Data from "Section" Paragraph in a Nested Paragraph

I'm using the Layout Paragraphs module. I have a "section" paragraph. Inside that section paragraph, I have a grid of 4-5 paragraphs. I would like to know if there's a way for those child paragraphs to access data from the parent "section" paragraph.
Technically, the paragraphs inside the "section" are not children. The parent entity for each paragraph is just the node page, from what I can tell. It's not like the section paragraph references the other paragraphs in the traditional Drupal entity reference way.
Use case: Ideally I want to have a couple of boolean fields on the section, and then have each paragraph within that section be able to access that data.
Not sure if it's possible. Anyone know?
Update
I worked this out. Please let me know if there's a more elegant way.
// Check if paragraph has parent.
$paragraphSettings = $paragraph->getAllBehaviorSettings();
if (!empty($uuid = $paragraphSettings['layout_paragraphs']['parent_uuid'])) {
$entity = \Drupal::service('entity.repository')->loadEntityByUuid('paragraph', $uuid);
// If parent exists, get boolean fields.
$vars['showBlurb'] = $entity->get('field_show_blurb')->getString();
$vars['showCta'] = $entity->get('field_show_call_to_action')->getString();
$vars['showIcon'] = $entity->get('field_show_icon')->getString();
$vars['showImage'] = $entity->get('field_show_image')->getString();
}

PowerApps: Zoom Image in HTML Text Control

Is there a way to Zoom In an image when it's clicked or hovered in powerapps?
Here is the code in the HTML Text Control:
Concatenate(
"<b><font color=black>", currentWorkItemId, "</font></b> ", LookUp(extendedWorkItemList, Id = currentWorkItemId, Title),
"<br></br><br></br><br></br>",
"<b>Test Case</b>",
"<hr>",
LookUp(workItemDetails, WorkItemId = Value(currentWorkItemId), TestCase)
)
Here is the generated HTML Text:
<b><font color=black>36066</font></b>Test<br></br><br></br><br></br><b>Test Case</b><hr><span style="display:inline !important;">Test Case<br><br><span style="display:inline !important;">This a just a Test :)<span> </span></span>TestUrl<br style="box-sizing:border-box;"><span style="display:inline !important;"><br></span><br></span><img src="https://media.geeksforgeeks.org/wp-content/uploads/20200403151026/adblur_gfg.png" alt='Geeks Image'><br><br>
And here is how it looks like:
link
Thanks in advance for your help!
This is how I do did it by clicking on the original image.
Please read through this whole response before trying.
7.3 steps
Step 1
Original image is 'Html text' control called 'Image' with HtmlText set to the following (including the quotes around in the string remove the space after the first <). :
"< img src="&ThisItem.Image&" width="&Self.Width&">"
(yours might be your whole html output since it in not just a single image but rather a whole html string)
ThisItem.Image refers to the selected SPO List Item in the form refencing a column called 'Image'. That is a 'Hyperlink or Picture' column set to Hyperlink. You may not need this, since you are already getting the URL from a another type of column.
Step 2
Set a variable on the OnScreen or App OnStart function to
Set(varImageLargeVisible, false)
Step 3
Set the original image OnSelect to
UpdateContext({varImageLargeVisible:true})
Make sure image DisplayMode is set to Edit
Step 4
Create a new HTML Text control. Set it to the size you want. If you want to block behind it off make the background color white or something to block out what is behind the control.
Step 5
Add an Icon, the X or something obvious so the user knows how to close the large image.
Set OnSelect to
UpdateContext({varImageLargeVisible:false})
Step 6
Change the Visible function for both the new Html Text control AND the icon to
If(varImageLargeVisible = true, true)
Step 7
Set the HtmlText to:
Substitute(Image.HtmlText, "width=443","width="&App.Width&"")
"width=443" is the width of the original control found on the right info panel.
7a-
Replace "Image" in 'Image.HtmlText' with the referenced image. (This references the original control called 'Image')
7b-
Replace the "443" in "width=443" with the width of your original control
7c-
Replace the "&App.Width&" in "width="&App.Width&" with the new size you want the image to be. If it will be a static size you can put in a number here instead of the dynamic size. "& &" breaks up the html within PowerApps so if you put in a static number, removed that as well.
Notes
I think you will need to define a width in your html output so the replace has something to replace.
<img src="https://media.geeksforgeeks.org/wp-content/uploads/20200403151026/adblur_gfg.png" alt='Geeks Image' width="0000"> (replace the 0000 with the size your image currently is.)
Hope that makes sense.

Issues with using CKEDITOR built-in templates

I am trying to use the default templates available with CKEDITOR.So I choose the one where an image and text can be placed side by side i.e. the image is occupying a certain part of the editor and the text the remaining part(but on the same horizontal level.I hope you get my point).But when I paste an image into the image area(provided in the template) , the text automatically shifts itself towards the bottom of the image(i.e. now image and text are not on the same level anymore). This happens no matter whether the size of the area provided for the image is bigger or smaller than the image.
Can any one say why this is happening and how to solve it.
You can change the Image Alignment To get the text in the same horizontal level
Image Properties -> Image Info -> Alignment -> Left | Right

Flex htmlText with full width image cuts characters off

My mx:Text's htmlText is the following:
mainText.htmlText = "<img src=\"breadmaker.png\" width=\"339\" height=\"275\" vspace=\"0\" hspace=\"0\" \/>" + "Lorem Ipsum is simply dummy tex......(more here)"
However, the result looks like the following:
Screenshot
As you can tell, it cuts off the first few characters in the text after the image tag (Lorem Ipsum is sim), but it is only because the image is full width. If I change the img tag to width=\"200\", it shows the text floating to the right.
However, as you can tell with a full width image (because the Text component's width is 339), it seems the text is still floating to the right, but it's hidden off to the right side of the image.
Any help?
HtmlText property is not very reliable when displaying HTML content. Adobe even has a note about img tag not being fully supported.
But if you're trying to get your text under you image, try to put them both in different paragraphs (p tag).
Alternatively you can check out Alex Harui's blog post from 3 years ago. He had at that point an HTML implementation that I found better for my purposes than the htmlText property.
What I ended up doing was determining if it was a full width image, and adding an actual <mx:Image> to the vbox. When I request the htmlText from the element, I simply run something like this:
if( fullWidthImage )
return "<p>"+imageString+"</p>"+body;
else
return body;
That way, the element itself returns the image wrapped in the body for a non full width image, but I make sure it is not included in a full width image until I need it there.

Generate a flex image from a hidden component

I'm trying to put an image, generated from some text, in a RichEditableText. Since it's a styled text, I thought about putting it another RichEditableText, style it, then print it to a Bitmap to use as source for InlineGraphicsElement.
I use the following code to do that
var txt:RichEditableText = new RichEditableText();
txt.text = name;
// Appliy given styles to the text flow of input rich editable text
createApplyNamedStyle(name, styles).call(null, txt.textFlow);
var bitmapData:BitmapData = new BitmapData(txt.width, txt.height);
bitmapData.draw(txt);
var bitmap:Bitmap = new Bitmap(bitmapData);
Unfortunatly, when called, it displays an error stack
ArgumentError: Error #2015: BitmapData non valide.
at flash.display::BitmapData()
at RichTextEditor/getTagImage()[E:\FlexWorkspace\Test\src\RichTextEditor.mxml:74]
at RichTextEditor/insertTag()[E:\FlexWorkspace\Test\src\RichTextEditor.mxml:154]
I suspect it is due to the fact that my RichEditableText, not being in visible component, is not laid out.
How can I ensure it is properly laid out ?
And am i doing the right thing to transform my text into an image ?
You're right; since the text is not on the display list, it is never validated and hence has 0 height and width.
A typical workaround is to add the item to the display list and then remove it immediatley. A little more discussion in this SO question.
You should trace txt.width and txt.height. They must be at least greater or equal to one. It does not matter if a DisplayObject is visible or not.

Resources