Giter Site home page Giter Site logo

Comments (2)

MattFedo avatar MattFedo commented on August 18, 2024

Try something like this:

NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"IMAGENAME.jpg"], 1);
NSString *stringBase64 = [imageData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];

NSString *html = @""; html = [html stringByAppendingString:[NSString stringWithFormat:@"<div align=\"left\"><img src=\"data:image/jpg;base64,%@\" align=\"absmiddle\" style=\"width:100%% \" /> </div>", stringBase64]];

PDFCreator = [NDHTMLtoPDF createPDFWithHTML:html pathForPDF:[@"~/Documents/manualDemo.pdf" stringByExpandingTildeInPath] delegate:self pageSize:kPaperSizeA4 margins:UIEdgeInsetsMake(10, 5, 10, 5)];

from ios-htmltopdf.

pankaj002 avatar pankaj002 commented on August 18, 2024

i tried that also but still not working for me

if let img = UIImage(data: imgData), let newImgData = img.jpegData(compressionQuality: 0.2) { arrImages.append(newImgData) } let base64String = arrImages[0].base64EncodedString(options: .lineLength64Characters) <img style=\"margin-top:10px\" src='data:image/png;base64,\(String(describing: base64String) )>

it's not working in 3/10 times, means when run PDF generate then 3 times approx nor working, don't know why it happen

from ios-htmltopdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.