I want to make an application for auto finding font.
Therefore, I try to get a font and font size from PDF text with Acrobat SDK.
I examined samples and documents, but I could not find it.
CAcroPDDoc pdDoc = new AcroPDDocClass();
pdDoc.Open(filename);
Object jsObj = pdDoc.GetJSObject();
Type T = jsObj.GetType();
// no idea for getting font and font size...
My tools : Visual Studio, C#, Acrobat DC, Acrobat DC SDK
For example PDF text, font and font size on Acrobat DC
Best regards
Acrobat JavaScript and, therefore, the JSO doesn't have access to the properties of text in the page content. The best you're going to be able to do is infer the size from the bounding box height but that won't be accurate since the bbox includes the leading. You can't get the font name at all.
You can get that information if you create a plugin but that would require C++ which you don't have listed as an option in your question.
Related
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.
I am very tired of providing fonts for my application. It would be a lot easier to have some ready-to-use fonts collection that I can use.
See this
//I need to add text to image, no matter what font is
var fo = SystemFonts.Find("Mono");
var font = new Font(fo, 10f, FontStyle.Regular);
x.DrawText("123", font,color,point);
I need to be sure that computer running this piece of code have font Mono installed. But it is not always the case, so I had to keep font file in my project folder and so on...
This is just annoying.
What I want to do
//this must be a font that included into library itself.
var font = FontCollection.Any;
x.DrawText("123", font,color,point);
With this I can be sure that I will be able to print text on image no matter what system is.
I want to show some custom shapes through font icons in my UWP project. I have created my own .ttf file for custom shapes. But I don't know how to apply it programmatically.
TextBlock text = new TextBlock();
string font = "Assets/mycustomfont.webfont.ttf#MyCustomFont";
text.FontFamily= new Windows.UI.Xaml.Media.FontFamily(font);
this.grid1.Children.Add(text);
Anyone please help me on this.
The approach you are using is practically correct, but make sure to check the following:
The .ttf file must be included in the project and have Build Action set to Content in the Properties window
Start the path to the font with / to make sure it begins in root.
Ensure the # suffix actually matches the font metadata. A font viewer app like dp4 Font Viewer can help you with that. Use the Font Family name as the suffix.
I have written an article on my blog about using custom fonts in UWP so check it out to see if you haven't missed some of the steps there.
I have downloaded custom font through code and want to apply it on my text view for that I want to know the exact name of font.
Note:
I want to know the font internal name not the font file name.let a font is abc.tff and when open the font the Name at top is "Arial", so i need the name Arial.
I have found method for pure windows 8/7 desktop applications not for UWP.
There is no way that I've found to extract the metadata from a font in order to find the name.
What you could do is create an observable collection that lists the data yourself... not ideal, but realistic.
Add(new Font("ABeeZee", "/Fonts/ABeeZee-regular.ttf#ABeeZee", "Sans Serif")
Then when you call the font, you can grab the data from your collection.
I'm trying to replace a section of a PDF with different text. From research on all major PDF libraries for .NET, it seems this is complicated and not a trivial task. I think it may be easier to convert the PDF to an image, replace the text (always in the same place), then convert it back to a PDF (or leave it as an image if converting back isn't possible). Is it possible to extract an image from a PDF page with .NET?
If your text is in a known location, you can simply cover it with a rectangle filled with the background color, and then draw your text over top.
Note that the text will still be there, it simply won't be visible. Someone selecting text will still pick up the old stuff. If that's acceptable, it's quite trivial.
If the PDF was created from image, you can import it into Photoshop to edit it as an graphic. Or you can use screenshot program like "Snagit" to capture pdf page as image and use snagit's editor to erase old text and replace new one.
But this method may bring you problem is that the new added text may not the same font as text around it. Personally, I use pdf editor to replace text in pdf since the added text will be automatically fit with the original font and size.