I'm using Syncfusion's HTML to PDF which is working great!
Little hiccup though, all their documentation shows if you want to change the font of the page numbers at the bottom you have two choices:
standard font:
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f)
custom font:
PdfFont font = new PdfTrueTypeFont(Server.MapPath("/App_Data/ARIALUNI.ttf"), 24)
But I need to allow a font from google fonts. I have the font loaded in my html but the page numbers are painted after so I'm not sure how to 1. embed it & 2. set it.
Appreciate any help.
Many thanks
For anyone that comes across this rare ask, it's not supported. You need to load and store the TrueType font and then set it to the file location as above.
My image: enter image description here
I am starting with RibbonControl in Devexpress. My problem is
Change Font Size in sub-item, if the font size is bigger than 10, it ran out of the area.
I need it to read my character in Unicode font.
There is any way to make the font area auto size with the font size?
I need to change the DrawString paragraph into different file formats like (Bold, Underline, color, etc).
Eg: Hi, This is RAM,
gfx.DrawString("Hi, This is RAM", fontRegular, XBrushes.DarkSlateGray, 0, 30);
You can use DrawString with regular, bold, italic, and bold italic fonts.
There are no paragraphs with PDFsharp. Just make the appropriate calls to DrawString with the right fonts and the correct positions. With your example, you need three calls to DrawString. Use MeasureString to find how much space a string needs so you can draw the next string at the correct position.
MigraDoc uses PDFsharp to create PDF files. MigraDoc has paragraphs and using AddFormattedText you can mix several fonts and font styles in one paragraph. So maybe consider using MigraDoc.
Information about MigraDoc on the PDFsharp web site:
http://pdfsharp.net/Overview.ashx
I have a template.docx, doc1.docx, doc2.docx. I am trying to merge doc1.docx and doc2.docx into template.docx using altChunk. The 3 documents have different font size and font styles. I want the resulting document base on the style in template.docx. Any ideas how to achieve that?
For example:
all the heading1 font size is 24, font color is blue
List paragraph font size is 12, font family is Times New Roman
Given a PDF file with color and black & white pages, is there any way with C# to find out among the given pages which are color and which are black & white?
My recommendation is to render each page to an image and then check each pixel for RGB values not equal to each other. If R=G=B for each pixel then it's a grayscale image.
You could then perform actions (such as extracting a page to another document or printing the page) on the pages based on whether they are color pages or black and white pages, etc.
This can be achieved by using my companies PDF developer library, Quick PDF, or potentially by one of the open source PDF libraries that Kenneth suggested.
Short of parsing all the postscript content, probably not. There's no flag on a PDF page that says it is or is not b&w or color. So you'd have to check the color of every element placed on the page to figure out if it was color or not. I'm not sure what libraries exist for reading PDFs on C# but you would need one that will read all the elements.
Similarly, any images you have on the page would need to be checked for color and that is not simple. Color image formats can hold b&w images.
Check out:
PDF-Analyser
I use his tools for text extraction and pdf analysis. Very inexpensive, royalty free, and work well. I think GetPDFColourStyle as part of the PDFLayoutPlus library should do the trick.
Convert each page into bitmap image and then look through each pixel in the image you would be able to catch colours and then differentiate color pages.
refer this Post for more details.
Note: If your are detecting this colors for printing sake, then you have to detect CMYK colors not RGB, CMYK is the printer standard color mode, and RGB is a display color mode.
There is a solution.
You can parse each page content bytes and look for color operators like 'rg, RG, k, K, sc, SC, scn, SCN' and read out all the color values and color spaces defined in each page.
Take a look at this example: http://habjan.blogspot.com/2013/09/proof-of-concept-converting-pdf-files.html
It implements / parses all color operators and I think it will be a good start point and reference to help you code what you need.