Convert HTML to Pdf in Mule 4 - anypoint-studio

Input payload has html content, which is to be converted to PDF using Mule 4. That PDF will be sent as an attachment to other end point. Any suggestions?
Thanks

Mule 4 doesn't have any built-in feature to transform to PDF. You should find a suitable Java library to generate the PDF and use the Java Module to invoke it, or some wrapper custom Java class.

Related

Print a pdf downloaded through a webservice in Flutter / Dart

I'm working with Flutter.
I have a pdf document that I download from a webservice.
The http body response of this pdf sent by http package is typed as Uint8List.
Then, I would like to print it with printing which is working with pdf package.
So I need an instance of a PdfDocument from this class.
Is there a way that I can convert this Uint8List to pdf ? I tried some other dart packages, but they didn't answer my needs because I need to print pdf, not just view them.
I also looked with flutter_downloader in order to simply get pdf file without bothering myself with Uint8List, but it seems the package is not working at the moment: https://github.com/fluttercommunity/flutter_downloader/issues/132
Thank you very much for answering.
Use:
var data = await getThePdfData(); // obtain the Uint8List
Printing.sharePdf(bytes: data);

How to use PDFMarkedContentExtractor class from pdfbox library?

I use pdfbox library to extract text from arbitrary PDF file. And I want to know how can I extract some particular text from pdf using this library.
As I understand, I should use marked content feature for this task.
There is the PDFMarkedContentExtractor class. Using its getMarkedContent method I can get PDMarkedContent object, and then, by using method getContents, I can get a real content that I need.
Am I right?
Well, but how can I specify what the document PDFMarkedContentExtractor should use as a source?
To my understanding, PDFMarkedContentExtract is used specifically for tagged contents within the PDF. Based upon your comments and your description, I believe you just want to extract the text in general. If that's the case, I believe you need to use PDFTextStripper instead.

Render HTML or GSP as a PDF and save it on server

I have an html template which I need to render as a .PDF and then save that pdf file on server. I'm using "rendering" plugin of grails. I'm able to render file as PDF but I don't understand how to save it on server location and not on user's system. Can anybody please help me ?
The pdfRenderingService provided by the plugin allows you to call render and get back an OutputStream. Using that output stream you can write that to a file on your server. The documentation explains the basics of using the service.
Your code may look something like this:
new File("report.pdf").withOutputStream { outputStream ->
outputStream << pdfRenderingService.render(template: '/report/report', model: [serial: 12345])
}
Well, actually I changed my plugin. Got Wkhtmltopdf plugin of grails more helpful. you can find it here --
https://github.com/quorak/grails-wkhtmltopdf
Also instructions regarding using this plugin you can find on the same link or here --
[https://github.com/quorak/grails-wkhtmltopdf]
Using this you can get "bytes" which you can write to file system.

How can I generate and download a pdf file in WebDynpro for ABAP?

I've got a task to create a webdynpro that given some inputs, can generate a pdf file with questions and the user should be able to download it somewhere. My question is, how can i generate a PDF in WDs and how do i prompt the download?
I do not know how to do it with Adobe Forms but I surely have seen that done using SmartForms.
When you execute the function module assigned to a smartform there is an EXPORTING parameter for it job_output_info.
With this parameter you execute then the function module CONVERT_OTF with following parameters.
EXPORTING
format = 'PDF'
IMPORTING
bin_file = e_file_as_xstring
TABLES
otf = job_output_info-otfdata[]
lines = lt_pdf_file_lines
Then if you are using WebDynpro for ABAP use the following method to let the user download the file.
wdr_task=>client_window->client->attach_file_to_response(
i_filename = 'Filename.pdf'
i_content = e_file_as_xstring
i_mime_type = 'pdf/application'
)
Not sure how it might work with Adobe Forms, but if you are able to generate the OTF content you should be able to do it as well. On the other hand maybe you are just able to get the PDF as xstring, then the OTF part will not be needed at all.
Maybe this article will help you to know how convert the Adobe Form to xstring: Getting a PDF in an xstring format in the ABAP environment

How to create pdf file from Qt application?

In my Qt application I am conducting some network tests. I have to create a report according to the test output. So I need to create the report in pdf format.
Can anybody please let me know how I can put my test results in a pdf file? My result contains graphs using the Qwt library.
this code outputs pdf from html:
QTextDocument doc;
doc.setHtml("<h1>hello, I'm an head</h1>");
QPrinter printer;
printer.setOutputFileName("c:\\temp\\file.pdf");
printer.setOutputFormat(QPrinter::PdfFormat);
doc.print(&printer);
printer.newPage();
I guess you can generate an html wrapper for your img and quickly print your image. Otherwise you might copy the image directly on the printer, since it is a paint device in a similar fashion
QPrinter printer;
QPainter painter(&printer);
printer.setOutputFileName("c:\\temp\\file.pdf");
printer.setOutputFormat(QPrinter::PdfFormat);
painter.drawImage(QRect(0,0,100,100), <QImage loaded from your file>);
printer.newPage();