Help, I need to create a PDF with iTextSharp that has
1) A green background for the entire document
2) Text (headings, tables, paragraphs) appear on a white background.
3) Special sections appear with a pink (or other color)
4) Headings on a Blue Background with White Text.
I can build a simple document, but the background colors are really throwing me off.
I add content using paragraphs, but I'm not sure how to set the background color of the paragraph, or group them together.
You create the document using objects such as Paragraphs, PdfPTables, and so on. You draw the rectangles using PdfContentByte methods. You obtain a PdfContentByte instance from a PdfWriter like this:
writer.getDirectContentUnder(); // Java
or
writer.DirectContentUnder; // C#
By using getDirectContentUnder() instead of getDirectContent(), the rectangles are drawn under the Paragraphs, PdfPTables, and so on.
Your main problem is keeping track of the coordinates: you need to know the coordinate of the lower-left corner and of the upper-right corner.
Drawing the background for a full page is a no-brainer. I've answered this question yesterday: How to draw border for whole pdf pages using iText library 5.5.2
Granted, in that answer I defined a border color for the rectangle because the OP only needed a red border on each page. You need to define the fill color of the rectangle instead of the border.
By examining the answer to yesterday's question, you'll discover the concept of page events. You'll also discover other page event methods, such as onParagraph() and onParagraphEnd(). These methods receive the Y coordinate of the start of each paragraph and the end of each paragraph. You can use these coordinates to draw rectangles in the page event.
To solve your problem, you would add a BaseColor member variable, a variable that keeps track of the initial Y value, and so on. It will require some programming, but with all the mechanisms explained in my answer, you should be able to meet your requirement.
Here's how I got it done:
Set the background color in the document
Created 1 column full page width table and set the white background
for each cell.
Add all my content to a cell
Add a new cell for each section
Draw a green border between cells, the same color as the background.
Placing content in the cells solves the problem of keeping track of the coordinates. Since the content could contain multiple paragraphs, sub-tables etc. I'm not sure if the onParagraphEnd would always fire.
Putting the content in the cells also allows control over color.
Related
Hi I am trying to create custom buttons on unity (trapeziums). I successfully created the visible area on Photoshop and imported it as Sprite 2D UI as per the following image:
The issue arises, when I'm trying to select one of the buttons in game, their border overlap each other, since the transparent area is still being considered as part of the clickable button area. How can I remove this?
EDIT:
Practically when I import I want the squared boxes to not be counted with the image. I need the edges of the orange area to be cut flush with that and not the entire area(i.e. including the transparent boxes).
You may achieve this by using Alpha Hit Test Minimum Threshold. Take a look at this nice video tutorial.
There is one extra step that is not shown in the video but mentioned in the comments: you have to change "Mesh Type" to "Full Rect" and not "Tight" as it is.
Hope that helps.
The clickable area is based on the Rect Transform component of the GameObject. Adjust the width and height to the clickable area you want. You may have to crop your image in photoshop accordingly. If you select 'Gizmos' in the editor you can toggle viewing the click region.
I am trying to make a template for my company's profile. I want to make rectangle curved from one side. As shown in the figure below. The blue box is a rectangle and the curved line is a curve in word. How can I ignore/delete the highlighted area in MSWord?
You can try using an image instead of the built in shapes. Insert the image, set the height to the full height of the page and set the text-wrapping so it is behind the text. Here's a sample image to try.
Instead of a curved line, use a filled oval shape in front of the rectangle. You might need to use the numeric fields in the Format tab to get the size you need. Also, if you put these elements in the header, they won't get in your way when editing your docs.
By using the following image i want to write code.
here is the image i want to do this one programmatically.
User can select roof or wall or fencing or windows. After selecting the particular part and color(another model) then the present color(another model) should replace with selected color.
In this image(example) user selected color(yellow) for wall and brown color for roof, after selection of color and part, old color should replace with new one.
How can we achieve this
any suggestions or help
Check my answer of how you can change the specific colors of UIImage.
Two notes:
the question is about gray to white color change, you can use this technique to change any color to any other,
the code is taken from somewhere of the developers reference, so that colors in the snippet are kinda random.
Sometimes pdf might have a transparent background. And In my application I have given a option to choose background. So, in case of pdf with transparent background and background color black all things becomes black black so, any way to check or any key inside dictionary of pdf page that can help me? Any help will appreciated.
The easiest solution for you would be to remove black color from available background colors.
Generally, all pdf pages have transparent background and the white background color is set by the viewer application. It is possible to set a background color for each page. You can read all about it in Page Group under Transparency section of the PDF Reference.
It is also possible to show a background color for a page by setting 'BoxColorInfo' dictionary in the page dictionary with appropriate values.
But I am not sure what you can achieve by knowing what color a page background is, since black background is going to be a problem for PDFs with transparent pages anyways.
EDIT: Following is the paragraph from PDFReference i was trying to point you to:
Ordinarily, the page is imposed directly on an output medium, such as
paper or a display screen. The page group is treated as an isolated
group, whose results are then composited with a backdrop color
appropriate for the medium. The backdrop is nominally white, although
varying according to the actual properties of the medium. However,
some applications may choose to provide a different backdrop, such as
a checkerboard or grid to aid in visualizing the effects of
transparency in the artwork.
It says that most PDFs would have a transparent and it is your application which shows the background color. Hope this helps.
I have a line of text which I want to display behind a CALayer, and when behind, then the text color should appear in a different color in the overlapping area.
The color of the text is black, and the text color should appear as white on the red layer when they overlap (they may both move around, so this needs to be continuously updated).
How may this be accomplished?
This can’t be done with any blend mode. You’ll need to render the text into the foreground layer in white by hand.
One trick you could try is to keep the white text always visible, but clipped by the layer that moves around using a second layer that also moves, set as the text’s mask.