If this method returns a webview we will add it as a subview to self.view, if it returns nil then nothing will happen.īecause we are adding this PDF to our project we can use Bundle.main to get the file's URL. ![]() We call the createWebView method with the our view's bounds. We will use this when we initialise our PDFView.,Nothing complicated here. This method will take a frame as an argument. Distributed as file in the releases or in the package js folder. See demo source code and build script Use webpack. There are three ways to use PDFKit in the browser: Use Browserify. To do this we will create a new method called displayWebView, which will look like this:,The first method we will create is the createPdfView. For more, see the demo folder and the PDFKit programming guide. But, this will only happen if a PDF exists, if one doesn't then this method will return nil.,Now that we have created a webview to display the PDF, we need to show the webview. This new method will create a new WKWebView and then it will load the URL and return the webview that was created. ![]() Ok, now that we have WebKit imported, we can create our new method. Vc.documentData = pdfCreator.createFlyer() When I pass it the filename like above, however, it fails silently and actually creates the PDF file, it just leaves it empty. ![]() I altered the source code to force these into a JPEG (which I knew they were) and got a "SOI not found in JPEG" error. Is there something I'm missing in my code?,I solved with a callback on finish of the stream,I also tried switching this to use a base64 encoded string and then a Buffer but both failed with the error "Unknown image format". This worked for me! Thanks! I think I must have been exiting the process before the files were actually finished writing.,I also tried just adding the text of the image filename to each page but that left the file empty as well. If your job is only calling one simple page, you can also do something like directly: > import os What is your pdfkit and wkhtmltopdf version?,This works fine with me:,wkhtmltopdf so2.pdf,
0 Comments
Leave a Reply. |