You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! Sorry for the delay, I missed this... With version 1.10.1, you can now access fonts and images from the StructuredTextPage object. For example:
//Initialise the MuPDF context. This is needed to open or create documents.usingMuPDFContextctx=new MuPDFContext();//Open a PDF documentusingMuPDFDocumentdoc=new MuPDFDocument(ctx,"path/to/file.pdf");// Obtain a MuPDFStructuredTextPage from the first page of the document, preserving the images.usingMuPDFStructuredTextPagesTextPage= doc1.GetStructuredTextPage(0, preserveImages:true);// Enumerate the MuPDFStructuredTextPageforeach(MuPDFStructuredTextBlock block in sTextPage){// Image blockif(block is MuPDFImageStructuredTextBlock imageBlock){// Access the image.MuPDFImageimage= imageBlock.Image;// Save it to a file
image.Save(@"C:\Users\Giorgio\Downloads\test.png", RasterOutputFileTypes.PNG);// Get an RGB representationbyte[]pixelBytes= image.GetBytes(PixelFormats.RGB);}// Text blockelseif(block is MuPDFTextStructuredTextBlock textBlock){// Enumerate the lines in the text block.foreach(MuPDFStructuredTextLine line in textBlock){// Enumerate the characters in the text block.foreach(MuPDFStructuredTextCharacter character in line){// Each MuPDFStructuredTextCharacter contains a MuPDFFontMuPDFFontfont= character.Font;// Useful properties you access on the font.stringfontName= font.Name;boolbold= font.IsBold;boolitalic= font.IsItalic;boolmonospaced= font.IsMonospaced;boolserif= font.IsSerif;}}}}
as shown in the title.
deepl translator.
The text was updated successfully, but these errors were encountered: