I'm trying to display an image from a collection.
The current methods (apex_util.get_blob_file_src / dbms_lob.getlength) don't seem to work, since this is a collection and not a Table.
I'm able to create a download link of the image/file but not display it.
Any ideas on how to display images from collection in a report?
The report query looks like that (without the section to display image)
select
seq_id as "Seq id",
n001 as "Id",
'<a href="' || apex_page.get_url(p_page => 3003,
p_clear_cache => 3003,
p_items => 'P3003_SEQ',
p_values => seq_id)
||'">' || c002 || '</a>'
as "Download document"
from APEX_COLLECTIONS
where collection_name = 'COLLECTION_DOCS';
Thanks
You could transform the image to base64 with a function and use the output in the img src attribute.
Here is some code to transform the blob to a base64 encoded clob.
Afterwards you can use that clob in an HTML img tag:
<img alt="" src="data:'|| img_mime_type || ';base64, '|| base64_img || '">
You need to set the mime type based on your image format. E. g. for png use "image/png".
Related
I'm trying to write a online document editor with TinyMCE 5 as editor and Aspose.Word v20.8 as converter.
But when I convert the DOCX to HTML5 with Aspose.Word, it is not rendering as expected in TinyMCE.
The HTML looses for example headers, footers, MergeFields, IF, TableStart:TableEnd sofar I can tell now.
I need this HTML has all the data because I need to convert it back to DOCX again.
Code to generate the HTML5 is:
var doc = new Document({Stream_Of_DOCX});
var options = new HtmlSaveOptions();
options.SaveFormat = SaveFormat.Html;
options.Encoding = System.Text.Encoding.UTF8;
options.UpdateFields = true;
options.ExportRoundtripInformation = true;
options.ExportImagesAsBase64 = true;
options.ExportFontsAsBase64 = true;
options.ExportPageSetup = true;
options.ExportDocumentProperties = true;
options.ExportHeadersFootersMode = ExportHeadersFootersMode.PerSection;
options.HtmlVersion = HtmlVersion.Html5;
doc.Save($"{fileName}.html", options);
The code to convert the HTML5 back to DOCX is, were the model.Html is the TinyMCE textarea:
var doc = new Document();
var builder = new DocumentBuilder(doc);
builder.InsertHtml(model.Html);
doc.Save($"{fileName}.docx");
Can anybody help me to get this working with some code examples?
Or maybe has a better idear to accomplish the task.
The main idear is to be able to edit DOCX files online, without to have to download it and upload again with some windows service as client for example.
Aspose.Words do preserve headers and footers upon saving to HTML if ExportRoundtripInformation option is enabled. In this case Aspose.Words writes header and footer content with special css attributes, which are understood by Aspose.Words:
<div style="-aw-headerfooter-type:header-primary; clear:both">
<p style="margin-top:0pt; margin-bottom:0pt; line-height:normal">
<span>header</span>
</p>
</div>
Also, Aspose.Words preserves some fields (PAGE, NUMPAGES, NOTEREF, REF, AUTOR and TITLE). For example, PAGE field is exported like the following:
<span style="-aw-field-start:true"></span><span style="-aw-field-code:' PAGE \\* MERGEFORMAT '"></span><span style="-aw-field-separator:true"></span><span>1</span><span style="-aw-field-end:true"></span>
Such content is recognized by Aspose.Words upon reading HTML and loaded into the model as field. I logged a request WORDSNET-21037 to preserve other types of fields too.
I am not familiar with TinyMCE, but I suspect that custom attributes used by Aspose.Words for roundtrip MS Word features are removed and that is why Header and Footer are not preserved in your case.
Disclosure: I work at Aspose.Words team.
How can I display a PDF Document which is stored in a BLOB Column on an Oracle Apex Page?
In the Page Attributes you can set the Mime Type to application PDF.
Then you could do something like this (As a Header Process) to actually show the PDF:
owa_util.mime_header('application/pdf',false);
htp.p('Content-length:'||l_length);
owa_util.http_header_close;
wpg_docload.download_file(l_pdf_blob);
apex_application.stop_apex_engine;
I am trying to create an Interactive Report in an Oracle APEX application. I want to show icons along with the data in a report column.
I succeeded to display the icons, but I want to display these icons in different colors depending on the word.
I found an example of this in the "Universal Theme Sample Application" application that came with Oracle APEX and I applied the same method in my own application.
But in my application all the icons are just black, although in the example application each data is displayed with different color icons.
Can anyone help me with this?
This one is the sample application:
Sample Application Screenshot
and this one is my app:
My Application Screenshot
Thanks a lot.
You can add color to your icon by adding color css in the Style attribute of your span like this:
<span class="fa #STATUS_ICON#" style="color: green;"></span> #STATUS#
and for the link:
<div class="dm-IRR-icon"> <span class="fa #STATUS_ICON#" style="color: red;"></span> <span class="dm-IRR-iconLabel">#TASK_NAME#</span> </div>
You can also make the icon bigger or smaller by adding in the style the font-size attribute like this: style="color: green; font-size: 15px;"
Edit1: To have different color you have 2 options:
I. Add a new column (icon_color named in my example) in your sql query to bring the color and use it in the HTML Expresion.
SELECT task_name,
start_date,
status,
CASE status
WHEN 'Open' THEN 'fa-clock-o is-open'
WHEN 'Closed' THEN 'fa-check-circle is-closed'
WHEN 'On-Hold' THEN 'fa-exclamation-circle is-holding'
WHEN 'Pending' THEN 'fa-exclamation-triangle is-pending'
END status_icon,
CASE status
WHEN 'Open' THEN 'red'
WHEN 'Closed' THEN 'green'
WHEN 'On-Hold' THEN 'pink'
WHEN 'Pending' THEN 'orange'
END icon_color,
assigned_to
FROM eba_ut_chart_tasks
ORDER BY 2
HTML Expression:<span class="fa #STATUS_ICON#" style="color: #ICON_COLOR#"></span> #STATUS#
II. Add all the logic inside 1 case in your query like this:
SELECT task_name,
start_date,
'<span class="fa '||
CASE status
WHEN 'Open' THEN 'fa-clock-o is-open" style="color:red'
WHEN 'Closed' THEN 'fa-check-circle is-closed" style="color:green'
WHEN 'On-Hold' THEN 'fa-exclamation-circle is-holding" style="color:blue'
WHEN 'Pending' THEN 'fa-exclamation-triangle is-pending" style="color:pink'
END ||' "></span>'||status as status,
assigned_to
FROM eba_ut_chart_tasks
ORDER BY 2;
For this option don't forget to go on your column (Status in this case) and set the Escape special characters atribute to NO.
I have an action in my controller #applications that renders a html page of my websites application page. When I specify the path for this action with the :pdf format it will render the page as a pdf (which works correctly).
I am writing another action #applications_print_version that needs to contain the rendered view from #applications plus some other pdfs (from a list of urls). Using combine_pdf I have been able to get the list of pdfs via urls working, but I can not get the #applications view to be added to the combined pdf in the #applications_print_version working.
Here is what I have so far.
def applications_print_version
html = render_to_string(action: :applications)
pdf = WickedPdf.new.pdf_from_string(html)
new_pdf = CombinePDF.new
new_pdf << CombinePDF.parse(pdf)
#List of pdfs I got from somewhere else
#pdf_attachments.each { |att| new_pdf << CombinePDF.parse( Net::HTTP.get( URI.parse( att.url ) ) ) }
send_data new_pdf.to_pdf, :disposition => 'inline', :type => "application/pdf"
end
This solution does have all the data, but the pdf variable has no styling. I can't seem to get this to work.
Thanks to a local community support I have managed to get it to work. There were a few things I needed to fix.
The layout that I was using to render #applications was using my standard pdf layout that I used for PDFKit. I duplicated the layout and replaced
<%= stylesheet_link_tag 'application' %>
with
<%= wicked_pdf_stylesheet_link_tag 'application' %>
One I did that I could render the #applications action with the layout the WickedPDF needed.
html = render_to_string(action: :applications, layout: 'wicked_pdf')
I ran into another issue. There is a known issue with WickedPDF https://github.com/mileszs/wicked_pdf/issues/470
So I had to remove any instances of #import "bootstrap" in my stylesheets which is not ideal, but I could not resolve the above issue.
Any now the #applications_print_version works correctly!
If anyone can do better, please let me know, I would like to know :)
I found the following javascript example for uploading multiple files in one session:
Upload multiple files with a single file element
My question is that in my APEX 3.2 page, I currently have a region that looks like this:
And I want to take out the default 'File Browse' and put in the multiple file upload portion in it's place.
Is there a way to put a region within a region? If not, how can I add an HTML item within a region?
Here is the code that I have in the second screen shot (html region):
<form enctype="multipart/form-data" action="your_script_here.script" method = "post">
<input id="my_file_element" type="file" name="file_1" >
<input type="submit">
Files:
<div id="files_list"></div>
<script>
var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 3 );
multi_selector.addElement( document.getElementById( 'my_file_element' ) );
</script>
</form>
You can create a "Display as Text" item and set your HTML code as the source. Make sure that the item is not set to escape HTML, otherwise you will just see the HTML and not the controls.
The result comes out like this (I have a text item "Request Title" followed by the display item based on your HTML: