Generate PDF thru iTextSharp
Hi,
My requirement is to generate a PDF from one of my Visual Web Parts. When I take a reference of the iTextSharp.dll and when I click on the "Generate PDF" button I am getting the below issue.
Could not load file or assembly itextsharp,
Version=4.1.6.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca or one of its dependencies. The
system cannot find the file specified
I have also tried with version 5.1.2 and I am getting the same issue except for the version type.
Please suggest as I am having no clue on the issue.
Thanks and Regards,
Satish
Sathiish Reddy
HI,
Move the
iTextSharp.dll to GAC and try.
Don't forget to mark it as an Answer if it resolves your issue and Vote Me as helpful if it useful.
Mahesh
Similar Messages
-
Error while Generating PDF file from Datagridview .
Hi every one,
I'm trying to generate pdf file from datagridview,while executing my code getting nullvalue exception..
Here is my code:
private void btnexportPDF_Click(object sender, EventArgs e)
//Creating iTextSharp Table from the DataTable data
PdfPTable pdfTable = new PdfPTable(dataGridView1.ColumnCount);
pdfTable.DefaultCell.Padding = 3;
pdfTable.WidthPercentage = 30;
pdfTable.HorizontalAlignment = Element.ALIGN_LEFT;
pdfTable.DefaultCell.BorderWidth = 1;
//Adding Header row
foreach (DataGridViewColumn column in dataGridView1.Columns)
PdfPCell cell = new PdfPCell(new Phrase(column.HeaderText));
cell.BackgroundColor = new iTextSharp.text.BaseColor(240, 240, 240);
pdfTable.AddCell(cell);
//Adding DataRow
foreach (DataGridViewRow row in dataGridView1.Rows)
foreach (DataGridViewCell cell in row.Cells)
pdfTable.AddCell(cell.Value.ToString());//nullvalue exception
//Exporting to PDF
string folderPath = "C:\\PDFs\\";
if (!Directory.Exists(folderPath))
Directory.CreateDirectory(folderPath);
using (FileStream stream = new FileStream(folderPath + "DataGridViewExport.pdf", FileMode.Create))
Document pdfDoc = new Document(PageSize.A2, 10f, 10f, 10f, 0f);
PdfWriter.GetInstance(pdfDoc, stream);
pdfDoc.Open();
pdfDoc.Add(pdfTable);
pdfDoc.Close();
stream.Close();
Thanks & Regards RAJENDRAN MHi Rajendran,
The second question is about the usage of iTextSharp library, which is not a MS product, please post in their forum for help:
http://support.itextpdf.com/forum
Thanks for your understanding.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
We have done toleration testing on firefox version 5 thru 6 and haven't got an issue with our website generating pdf files for our users. One of our users upgraded to firefox version 7.0.1 and they tried to generate a pdf report, now a screen pops up with Corrupted Content Error The page you are trying to view cannot be shown because an error in the data transmission was detected. I recreated this issue on my pc yesterday by installing firefox 7.0.1. Any hints as to what I need to look at would help. Cannot provide the url because it is a secure website for law enforcement. Thanks.
You can turn off compatibility checking, but more and more of the Google Toolbar will not work. Google is no longer supporting the Google Toolbar so you should use the alternatives.
Hi Mark,
See http://kb.mozillazine.org/Using_Google_Toolbar_features_without_toolbars
If you have an aspect that is not covered, indicate what that is; otherwise, expect you to be fully functional within 1-2 weeks.
<br><small>Please mark "Solved" one answer that will best help others with a similar problem -- hope this was it.</small> -
Generate PDF file in SharePoint 2013
Hi,
I have a requirement to create .pdf file while one item is submitted to list/library in SharePoint 2013.
It means when employee inputs his/her data and after submit one pdf file will generated with the summary/relevant data.
Can any one help me to figure out this scenario.
Is it possible with SharePoint out of box feature?
Please help if any solution.
Thank Youyou can not achieve this out of box, custom development with integration of 3rd party controls is required to generate pdf files. There are paid components available but i will suggest you to use iTextSharp which is a free open source library to generate
pdf files.
You can refer below link to generate pdf on basis of your requirement.
SharePoint: Generate PDF from HTML content using itextsharp
Adnan Amin MCT, SharePoint Architect | If you find this post useful kindly please mark it as an answer. -
Crystal Report generate PDF with J2EE problem
Dear All
I am having a great problem on generating PDF file by Crystal Report in J2EE.
I have my J2EE application runs Crystal Report to generate PDF files.
However for a report, i hit the following error (red color) when the PDF is generating.
But is no problem for the other reports.
Here is the code that i used to generate the PDF
My OS and Java version as follows
Window 2003 server.
Java 1.4.2_04
Please Kindly Help
Thanks very much
public static void export(HttpServletRequest request, HttpServletResponse response, String reportPath, ArrayList paramList, ReportExportFormat outFormat) throws Exception{
System.gc();
HttpSession session = request.getSession(false);
Object reportSource = getReportSource(request, reportPath);
ReportExportControl exportControl = new ReportExportControl();
if(paramList != null && paramList.size()>0){
exportControl.setParameterFields(getParamFields(paramList));
ExportOptions exportOptions = new ExportOptions();
exportOptions.setExportFormatType(outFormat);
PDFExportFormatOptions pdfexpopts = new PDFExportFormatOptions();
exportOptions.setFormatOptions(pdfexpopts);
exportControl.setReportSource(reportSource);
exportControl.setExportOptions(exportOptions);
exportControl.processHttpRequest(request, response, session.getServletContext(), null);
exportControl.dispose();
public static IReportSource getReportSource(HttpServletRequest request, String reportPath) throws Exception{
ReportClientDocument oReportClientDocument = new ReportClientDocument();
HttpSession session = request.getSession(false);
oReportClientDocument.open(reportPath, 0);
return oReportClientDocument.getReportSource();
00:57:08,671 ERROR reportdefinition Thread-28 - Report printer was not valid, switching to default printer.
00:57:08,687 ERROR objectformatter Thread-28 - com.crystaldecisions.reports.dataengine.k: |Y
00:57:09,343 ERROR b Thread-28 - Disk Exporter: no output file was created by an exporter
00:57:09,343 ERROR b Thread-28 - PdfExporter: caught Exception in PDFFormatter.finalizeFormatJob (from destination?); java.lang.IllegalArgumentExceptionHi,
I have tried this code but stil the same.
However i tried setup another tomcat and application in the other machine and the only job for the application is exporting the report that has problem, then the error is gone.
So i guess that is the memory size problem.
Thanks for this
One more question about the memory size between Tomcat and Crystal report.
I have set in catalina.bat as
set JAVA_OPTS = "-Xms2048M -Xmx1024M"
and CRConfig as
<JVMMaxHeap>1024000000</JVMMaxHeap>
<JVMMinHeap>512000000</JVMMinHeap>
1. Is that the correct setting.?
2. The memory in the JAVA_OPT and is the MAX and MIN memory that java would use,
then is the Max memory in CRConf is 1024M out of the java heap size or the application use another 1024 memory -
"Error while generating pdf" error come when clicking on "Print Version "
Hello ,
When we execute Query in the Portal there is a 'Print version' button.
When you select it, it opens up print dialog and click OK
It is supposed to send 'pdf' stream to Web browser client on end user but it is not able to generate the pdf .
getting ' Error while generating pdf '
I am working on BI 7.0 .
The same is running fine in the Q Environment .But in Production we are getting this error .
Thanks ,
RahulHi,
I think this is an ADS error. This is a reason why pdf's are not working. We had the same issue.
You can check your installation:
Usage of SAP NetWeaver BI Diagnostics & Support Desk Tool
SAP Note Number: [937697|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_bw_bex/~form/handler%7b5f4150503d3030323030363832353030303030303031393732265f4556454e543d444953504c4159265f4e4e554d3d393337363937%7d]
Exceptions: Prerequisites for messages in the area BI Java
SAP Note Number: [1224043 |https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_bw_bex/~form/handler%7b5f4150503d3030323030363832353030303030303031393732265f4556454e543d444953504c4159265f4e4e554d3d31323234303433%7d]
Solution in our case was to update the SAPADS package to 7.00 17.1
Regards
Andreas -
Error while generating PDF ( BEx Web Analyzer )
Hi,
Is there any limit to the number of pages we can print using ADS? We always get
" Error while generating PDF" Error when we try to print reports with more than 500 lines.
Thanks
NivedaGreat. It worked.
Points assigned.
Niveda -
Error while generating PDF in portal but not in WAD
Hi,
When I execute the command to export to pdf, I have a screen to fill settings of my pdf, then I valid my choice and I have this message : "Error while generating PDF" in my portal.
However, when I want to execute on Web Application Designer and click on my command "export to pdf", I have a same screen and I can open or save my document.
Is someone have an idea : why it is possible to generate my pdf on WAD but not in my portal ??
Any information is much appreciated !
Thanks in advance
V.K.Hi Pradnya,
Thanks for your answer. However it is for an old version of SAP NetWeaver..
I work with SAP BI 7.0 version.
Regards,
V.K. -
Error while generating PDF BI 7 Report Designer
Hi,
I am getting this error Error while generating PDF when i tried print version on report designer,
I tried to find information on this error but there was no information regarding this , so posted here.
Please let me know if you have any suggestions.
Thanks,
KumarWe have restated the java server and now the issue solved.
Kumar -
Hello Guru's,
I have done the ADS configuration setup and checked all configuration settings.It seems everything is working fine but when i select the option "Print Verison" ( I have executed a query using the query designer) i am getting above error.
FYI: Its a BI 700 system and we are at Suport pack10 level (both ABAP+Java). By the way i should let you know that it is a copy of Production.
Here is the log:
Error while generating PDF
com.sap.ip.bi.webapplications.pageexport.PageExportRenderingRootNode PageExport1
Error while generating PDF
com.sap.ip.bi.webapplications.pageexport.PageExportRenderingRootNode PageExport#
Any thoughts as to what the messages above might be pointing me to?I should appreciate your help.
Thanks,
Ravi.Hello Dezso,
I have executed the test report FP_TEST_00 and i got a form containing several lines on two pages.I have checked all the configuration checks and got the correct results as mentioned in the ADS document. But when i try to print a query using the query analyzer,i am getting that PDF error. I have no issues with my other BI 700 system.
Ravi. -
Error while generating PDF - in Bex Web
Hi Experts,
I am currently having the issue that I receive the error "Error while generating PDF" when using the "Print Version" functionality. This problem only occurrs for the Bex Web Query. I know that the ADS service is configured correctly- The webservice test is successful and other applications (Guided Procedures, MSS) also use it successfully.
Please see below the excerpt from the default trace:
A message was generated:
ERROR
Error while generating PDF
com.sap.ip.bi.webapplications.pageexport.PageExportRenderingRootNode PageExportRenderingRootNode_0001
Message: 28
Stack trace: java.lang.ArrayIndexOutOfBoundsException: 28
at com.sap.ip.bi.export.xfa.impl.SizeCalculator.getColumnSizes(SizeCalculator.java:178)
at com.sap.ip.bi.export.impl.ExportController.setSizes(ExportController.java:220)
at com.sap.ip.bi.export.impl.ExportController.calculateAndSetSizes(ExportController.java:611)
at com.sap.ip.bi.export.impl.ExportController.doExportPrep(ExportController.java:408)
at com.sap.ip.bi.export.impl.ExportController.convert(ExportController.java:336)
at com.sap.ip.bi.export.controller.ExportResult.createExport(ExportResult.java:58)
at com.sap.ip.bi.webapplications.pageexport.PageExportRenderingRootNode.createPDF(PageExportRenderingRootNode.java:453)
at com.sap.ip.bi.webapplications.pageexport.PageExportRenderingRootNode.doExport(PageExportRenderingRootNode.java:105)
at com.sap.ip.bi.webapplications.pageexport.PageExportRenderingRootNode.processRendering(PageExportRenderingRootNode.java:252)
at com.sap.ip.bi.webapplications.runtime.impl.Page.buildRenderingTree(Page.java:3809)
at com.sap.ip.bi.webapplications.runtime.impl.Page.processRenderingRootNode(Page.java:3867)
at com.sap.ip.bi.webapplications.runtime.impl.Page.processRendering(Page.java:3510)
at com.sap.ip.bi.webapplications.runtime.impl.Page.doProcessRequest(Page.java:3470)
at com.sap.ip.bi.webapplications.runtime.impl.Page.processRequest(Page.java:2489)
at com.sap.ip.bi.webapplications.runtime.controller.impl.Controller.doProcessRequest(Controller.java:892)
at com.sap.ip.bi.webapplications.runtime.controller.impl.Controller.processRequest(Controller.java:813)
at com.sap.ip.bi.webapplications.runtime.jsp.portal.services.BIRuntimeService.handleRequest(BIRuntimeService.java:456)
at com.sap.ip.bi.webapplications.runtime.jsp.portal.components.LauncherComponent.doContent(LauncherComponent.java:21)
at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:645)
at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:240)
at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:522)
at java.security.AccessController.doPrivileged(Native Method)
at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:405)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.servlet.InvokerServlet.service(InvokerServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
If you have any idea or clue it would be greatly appreciated.
Thanks in advance for every support,
JanHi Jan,
Most possible causes for encountering this issue are:
Possible cause:
- The ADS is installed on a plattform, that is currently not supported by SAP for ADS. Please check the avaliablity at: Product Availability Matrix
- Mixing of different Netweaver releases (NW04 and NW04s) -> This is unfortunatelly not possibble the J2EE engine release has to match with the ABAP stack release in order connect them properly.
- The ADS SP level does not match the J2EE engine SP level. -> Please update the software components to have the same support package level.
Hope this helps!!
Regards,
Arafat -
Hi,
I am using CRM ONLINE 2013.
How to automate below process?
1. On Approval Of Quotation, Run Report.
2. Generate PDF.
3. Send an Email With PDF as attachment.
As i have gone through many forums for this topic, but creating a plugin code for generating Report PDF is not possible in CRM ONLINE.
So, What is the alternate way to do this..?
Thanks.This is my entire code mentioned below:-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript">
if (typeof (SDK) == "undefined")
{ SDK = { __namespace: true }; }
SDK.JScriptRESTDataOperations = {
_context: function () {
if (typeof GetGlobalContext != "undefined")
{ return GetGlobalContext(); }
else {
if (typeof Xrm != "undefined") {
return Xrm.Page.context;
else { return new Error("Context is not available."); }
_getServerUrl: function () {
var serverUrl = this._context().getServerUrl()
if (serverUrl.match(/\/$/)) {
serverUrl = serverUrl.substring(0, serverUrl.length - 1);
return serverUrl;
_ODataPath: function () {
return this._getServerUrl() + "/XRMServices/2011/OrganizationData.svc/";
_errorHandler: function (req) {
return new Error("Error : " +
req.status + ": " +
req.statusText + ": " +
JSON.parse(req.responseText).error.message.value);
_dateReviver: function (key, value) {
var a;
if (typeof value === 'string') {
a = /Date\(([-+]?\d+)\)/.exec(value);
if (a) {
return new Date(parseInt(value.replace("/Date(", "").replace(")/", ""), 10));
return value;
Create: function (object, type, successCallback, errorCallback) {
var req = new XMLHttpRequest();
req.open("POST", this._ODataPath() + type + "Set", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 201) {
successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d);
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
req.send(JSON.stringify(object));
Retrieve: function (id, type, successCallback, errorCallback) {
var req = new XMLHttpRequest();
req.open("GET", this._ODataPath() + type + "Set(guid'" + id + "')", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 200) {
successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d);
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
req.send();
Update: function (id, object, type, successCallback, errorCallback) {
var req = new XMLHttpRequest();
req.open("POST", this._ODataPath() + type + "Set(guid'" + id + "')", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("X-HTTP-Method", "MERGE");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 204 || this.status == 1223) {
successCallback();
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
req.send(JSON.stringify(object));
Delete: function (id, type, successCallback, errorCallback) {
var req = new XMLHttpRequest();
req.open("POST", this._ODataPath() + type + "Set(guid'" + id + "')", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("X-HTTP-Method", "DELETE");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 204 || this.status == 1223) {
successCallback();
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
req.send();
RetrieveMultiple: function (type, filter, successCallback, errorCallback) {
if (filter != null) {
filter = "?" + filter;
else { filter = ""; }
var req = new XMLHttpRequest();
req.open("GET", this._ODataPath() + type + "Set" + filter, true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 200) {
successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d.results);
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
req.send();
__namespace: true
</script>
<script type="text/javascript">
//Create Email and link it with Order as Regarding field
var Xrm;
var email = new Object();
var ownerID = "";
var CustomerId = "";
if (window.opener) { Xrm = window.opener.Xrm; }
else if (window.parent) { Xrm = window.parent.Xrm; }
//Get ownerid who send email of quotation to customer
function GetOwnerID() {
var owner = Xrm.Page.getAttribute("ownerid").getValue();
ownerID = owner[0].id;
var ownerName = owner[0].name;
var entityType = owner[0].entityType;
GetToEmailGUID();
//Get customerid who receive email of quotation from owner
function GetToEmailGUID() {
var Customer = Xrm.Page.getAttribute('customerid').getValue();
CustomerId = Customer[0].id;
var CustomerName = Customer[0].name;
var entityType = Customer[0].entityType;
//if CustomerId is type of "Account" then get Primary Contact id of that account
if (entityType == "account") {
var contact = Xrm.Page.getAttribute("customerid").getValue();
if (contact === null) return;
var serverUrl = Xrm.Page.context.getClientUrl();
var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/AccountSet(guid'" + contact[0].id + "')?$select=PrimaryContactId";
var req = new XMLHttpRequest();
req.open("GET", oDataSelect, false);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
req.onreadystatechange = function () {
if (req.readyState === 4) {
if (req.status === 200) {
var retrieved = JSON.parse(req.responseText).d;
CustomerId = retrieved.PrimaryContactId.Id;
else {
alert(this.statusText);
req.send();
function CreateEmail() {
GetOwnerID();
email.Subject = "Email with Report Attachment";
//Set The current order as the Regarding object
email.RegardingObjectId = {
Id: Xrm.Page.data.entity.getId(), //Get the current entity Id , here OrderId
LogicalName: Xrm.Page.data.entity.getEntityName()//Get the current entity name, here it will be “salesOrder”
//Create Email Activity
SDK.JScriptRESTDataOperations.Create(email, "Email", EmailCallBack, function (error) { alert(error.message); });
// Email Call Back function
function EmailCallBack(result) {
email = result; // Set the email to result to use it later in email attachment for retrieving activity Id
var activityPartyFrom = new Object();
// Set the From party of the ActivityParty to relate an entity with Email From field
activityPartyFrom.PartyId = {
Id: CustomerId, //"79EBDD26-FDBE-E311-8986-D89D6765B238", // id of entity you want to associate this activity with.
LogicalName: "contact"
// Set the "activity" of the ActivityParty
activityPartyFrom.ActivityId = {
Id: result.ActivityId,
LogicalName: "email"
// Now set the participation type that describes the role of the party on the activity).
activityPartyFrom.ParticipationTypeMask = { Value: 2 }; // 2 means ToRecipients
// Create the from ActivityParty for the email
SDK.JScriptRESTDataOperations.Create(activityPartyFrom, "ActivityParty", ActivityPartyFromCallBack, function (error) { alert(error.message); });
var activityPartyTo = new Object();
// Set the From party of the ActivityParty to relate an entity with Email From field
activityPartyTo.PartyId = {
Id: ownerID, //"79EBDD26-FDBE-E311-8986-D89D6765B238", // id of entity you want to associate this activity with.
LogicalName: "systemuser"
// Set the "activity" of the ActivityParty
activityPartyTo.ActivityId = {
Id: result.ActivityId,
LogicalName: "email"
// Now set the participation type that describes the role of the party on the activity).
activityPartyTo.ParticipationTypeMask = { Value: 1 }; // 1 means Sender
// Create the from ActivityParty
SDK.JScriptRESTDataOperations.Create(activityPartyTo, "ActivityParty", ActivityPartyToCallBack, function (error) { alert(error.message); });
//ActivityParty From Callback
function ActivityPartyFromCallBack(result) {
//ActivityParty To Callback
function ActivityPartyToCallBack(result) {
GetReportId('ABM_Infotech_SalesQuote');
//Create attachment for the created email
function CreateEmailAttachment() {
//get reporting session and use the params to convert a report in PDF
var params = getReportingSession();
//Email attachment parameters
var activitymimeattachment = Object();
activitymimeattachment.ObjectId = Object();
activitymimeattachment.ObjectId.LogicalName = "email";
activitymimeattachment.ObjectId.Id = email.ActivityId;
activitymimeattachment.ObjectTypeCode = "email",
activitymimeattachment.Subject = "File Attachment";
activitymimeattachment.Body = encodePdf(params);
activitymimeattachment.FileName = "Report1.pdf";
activitymimeattachment.MimeType = "application/pdf";
//Attachment call
SDK.JScriptRESTDataOperations.Create(activitymimeattachment, "ActivityMimeAttachment", ActivityMimeAttachmentCallBack, function (error) { alert(error.message); });
//ActivityMimeAttachment CallBack function
function ActivityMimeAttachmentCallBack(result) {
var features = "location=no,menubar=no,status=no,toolbar=no,resizable=yes";
var width = "800px";
var height = "600px";
window.open(Xrm.Page.context.getServerUrl() + "main.aspx?etc=" + 4202 + "&pagetype=entityrecord&id=" + email.ActivityId, "_blank", features);
// To open window which works in outlook and IE both
//openStdWin(Xrm.Page.context.getServerUrl() + "main.aspx?etc=" + 4202 + "&pagetype=entityrecord&id=" + email.ActivityId, "_blank", width,
height, features);
//This method will get the reportId based on a report name that will be used in getReportingSession() function
function GetReportId(reportName) {
var oDataSetName = "ReportSet";
var columns = "ReportId";
var filter = "Name eq '" + reportName + "'";
retrieveMultiple(oDataSetName, columns, filter, onSuccess);
function retrieveMultiple(odataSetName, select, filter, successCallback) {
var serverUrl = Xrm.Page.context.getServerUrl();
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
var odataUri = serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "?";
if (select) {
odataUri += "$select=" + select + "&";
if (filter) {
odataUri += "$filter=" + filter;
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: odataUri,
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
success: function (data) {
if (successCallback) {
if (data && data.d && data.d.results) {
successCallback(data.d.results);
else if (data && data.d) {
successCallback(data.d);
else {
successCallback(data);
error: function (XmlHttpRequest, errorThrown) {
if (XmlHttpRequest && XmlHttpRequest.responseText) {
alert("Error while retrieval ; Error – " + XmlHttpRequest.responseText);
function onSuccess(data) {
reportId = data[0].ReportId.replace('{', ").replace('}', ");
CreateEmailAttachment(); // Create Email Attachment
//Gets the report contents
function getReportingSession() {
var pth = Xrm.Page.context.getServerUrl() + "/CRMReports/rsviewer/reportviewer.aspx";
var retrieveEntityReq = new XMLHttpRequest();
var Id = Xrm.Page.data.entity.getId();
var quotationGUID = Id.replace('{', ""); //set this to selected quotation GUID
quotationGUID = quotationGUID.replace('}', "");
var reportName = "ABM_Infotech_SalesQuote"; //set this to the report you are trying to download
var reportID = "751089AA-74B8-E211-B52F-D8D3855B253B"; //set this to the guid of the report you are trying to download
var rptPathString = ""; //set this to the CRMF_Filtered parameter
var strParameterXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'><entity name='quote'><all-attributes /><filter type='and'><condition
attribute='quoteid' operator='eq' uitype='quote' value='" + quotationGUID + "' /> </filter></entity></fetch>";
retrieveEntityReq.open("POST", pth, false);
retrieveEntityReq.setRequestHeader("Accept", "*/*");
retrieveEntityReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
rptPathString = "id=%7B" + reportID + "%7D&uniquename=" + Xrm.Page.context.getOrgUniqueName() + "&iscustomreport=true&reportnameonsrs=&reportName="
+
reportName + "&isScheduledReport=false&p:ABMFilteredQuote=" + strParameterXML;
//remove the part starting from &p:salesorderid if your report has no parameters
retrieveEntityReq.send(rptPathString);
var x = retrieveEntityReq.responseText.indexOf("ReportSession=");
var ret = new Array();
ret[0] = retrieveEntityReq.responseText.substr(x + 14, retrieveEntityReq.responseText.indexOf("&", x) - x - 14); //the session id
x = retrieveEntityReq.responseText.indexOf("ControlID=");
ret[1] = retrieveEntityReq.responseText.substr(x + 10, retrieveEntityReq.responseText.indexOf("&", x) - x - 10); //the control id
return ret;
var bdy = new Array();
var bdyLen = 0;
function concat2Bdy(x) {
bdy[bdyLen] = x;
bdyLen++;
function encodePdf(params) {
bdy = new Array();
bdyLen = 0;
var retrieveEntityReq = new XMLHttpRequest();
var pth = Xrm.Page.context.getServerUrl() + "/Reserved.ReportViewerWebControl.axd?ReportSession=" + params[0] +
"&Culture=1033&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID=" + params[1] +
"&OpType=Export&FileName=Public&ContentDisposition=OnlyHtmlInline&Format=PDF";
retrieveEntityReq.open("GET", pth, false);
retrieveEntityReq.setRequestHeader("Accept", "*/*");
retrieveEntityReq.send();
BinaryToArray(retrieveEntityReq.responseBody);
return encode64(bdy);
var StringMaker = function () {
this.parts = [];
this.length = 0;
this.append = function (s) {
this.parts.push(s);
this.length += s.length;
this.prepend = function (s) {
this.parts.unshift(s);
this.length += s.length;
this.toString = function () {
return this.parts.join('');
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function encode64(input) {
var output = new StringMaker();
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
while (i < input.length) {
chr1 = input[i++];
chr2 = input[i++];
chr3 = input[i++];
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
output.append(keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4));
return output.toString();
</script>
<script type="text/vbscript">
Function BinaryToArray(Binary)
Dim i
ReDim byteArray(LenB(Binary))
For i = 1 To LenB(Binary)
byteArray(i-1) = AscB(MidB(Binary, i, 1))
concat2Bdy(AscB(MidB(Binary, i, 1)))
Next
BinaryToArray = byteArray
End Function
</script>
</head>
<body>
<input type="button" onclick="CreateEmail();" value="Attach Report" />
</body>
</html> -
Generate pdf and html(urgent)
can anybody tell how to generate pdf and html from a single report,
thanks in advFrom a single report, you can generate outputs to html, htmlcss, pdf, rtf, XML and text formats.
If you use rwclient, rwrun or rwservlet methods, specify desformat=pdf/html and the destination file name in desname command line parameters.
If you use Reports Builder, open a report, select File->Generate to file and select html/pdf. Then give the file name.
For more details, Refer to Reports Tutorial / Publishing Reports document from this site.
http://otn.oracle.com/docs/products/reports/content.html
Thanks,
The Oracle Reports team -
Writing a java program for generating .pdf file with the data of MS-Excel .
Hi all,
My object is write a java program so tht...it'll generate the .pdf file after retriving the data from MS-Excel file.
I used POI HSSF to read the data from MS-Excel and used iText to generate .pdf file:
My Program is:
* Created on Apr 13, 2005
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
package forums;
import java.io.*;
import java.awt.Color;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import com.lowagie.text.Font.*;
import com.lowagie.text.pdf.MultiColumnText;
import com.lowagie.text.Phrase.*;
import net.sf.hibernate.mapping.Array;
import org.apache.poi.hssf.*;
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.hssf.usermodel.*;
import com.lowagie.text.Phrase.*;
import java.util.Iterator;
* Generates a simple 'Hello World' PDF file.
* @author blowagie
public class pdfgenerator {
* Generates a PDF file with the text 'Hello World'
* @param args no arguments needed here
public static void main(String[] args) {
System.out.println("Hello World");
Rectangle pageSize = new Rectangle(916, 1592);
pageSize.setBackgroundColor(new java.awt.Color(0xFF, 0xFF, 0xDE));
// step 1: creation of a document-object
//Document document = new Document(pageSize);
Document document = new Document(pageSize, 132, 164, 108, 108);
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter writer =PdfWriter.getInstance(document,new FileOutputStream("c:\\weeklystatus.pdf"));
writer.setEncryption(PdfWriter.STRENGTH128BITS, "Hello", "World", PdfWriter.AllowCopy | PdfWriter.AllowPrinting);
// step 3: we open the document
document.open();
Paragraph paragraph = new Paragraph("",new Font(Font.TIMES_ROMAN, 13, Font.BOLDITALIC, new Color(0, 0, 255)));
POIFSFileSystem pofilesystem=new POIFSFileSystem(new FileInputStream("D:\\ESM\\plans\\weekly report(31-01..04-02).xls"));
HSSFWorkbook hbook=new HSSFWorkbook(pofilesystem);
HSSFSheet hsheet=hbook.getSheetAt(0);//.createSheet();
Iterator rows = hsheet.rowIterator();
while( rows.hasNext() ) {
Phrase phrase=new Phrase();
HSSFRow row = (HSSFRow) rows.next();
//System.out.println( "Row #" + row.getRowNum());
// Iterate over each cell in the row and print out the cell's content
Iterator cells = row.cellIterator();
while( cells.hasNext() ) {
HSSFCell cell = (HSSFCell) cells.next();
//System.out.println( "Cell #" + cell.getCellNum() );
switch ( cell.getCellType() ) {
case HSSFCell.CELL_TYPE_STRING:
String stringcell=cell.getStringCellValue ()+" ";
writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
phrase.add(stringcell);
// document.add(new Phrase(string));
System.out.print( cell.getStringCellValue () );
break;
case HSSFCell.CELL_TYPE_FORMULA:
String stringdate=cell.getCellFormula()+" ";
writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
phrase.add(stringdate);
System.out.print( cell.getCellFormula() );
break;
case HSSFCell.CELL_TYPE_NUMERIC:
String string=String.valueOf(cell.getNumericCellValue())+" ";
writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
phrase.add(string);
System.out.print( cell.getNumericCellValue() );
break;
default:
//System.out.println( "unsuported sell type" );
break;
document.add(new Paragraph(phrase));
document.add(new Paragraph("\n \n \n"));
// step 4: we add a paragraph to the document
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
// step 5: we close the document
document.close();
My Input from MS-Excel file is:
Planning and Tracking Template for Interns
Name of the Intern N.Kesavulu Reddy
Project Name Enterprise Sales and Marketing
Description Estimated Effort in Hrs Planned/Replanned Actual Actual Effort in Hrs Complexity Priority LOC written new & modified % work completion Status Rework Remarks
S.No Start Date End Date Start Date End Date
1 setup the configuration 31/01/2005 1/2/2005 31/01/2005 1/2/2005
2 Deploying an application through Tapestry, Spring, Hibernate 2/2/2005 2/2/2005 2/2/2005 2/2/2005
3 Gone through Componentization and Cxprice application 3/2/2005 3/2/2005 3/2/2005 3/2/2005
4 Attend the sessions(tapestry,spring, hibernate), QBA 4/2/2005 4/2/2005 4/2/2005 4/2/2005
The o/p I'm gettint in .pdf file is:
Planning and Tracking Template for Interns
N.Kesavulu Reddy Name of the Intern
Enterprise Sales and Marketing Project Name
Remarks Rework Status % work completion LOC written new & modified Priority
Complexity Actual Effort in Hrs Actual Planned/Replanned Estimated Effort in Hrs Description
End Date Start Date End Date Start Date S.No
38354.0 31/01/2005 38354.0 31/01/2005 setup the configuration 1.0
38385.0 38385.0 38385.0 38385.0 Deploying an application through Tapestry, Spring, Hibernate
2.0
38413.0 38413.0 38413.0 38413.0 Gone through Componentization and Cxprice application
3.0
38444.0 38444.0 38444.0 38444.0 Attend the sessions(tapestry,spring, hibernate), QBA 4.0
The issues i'm facing are:
When it is reading a row from MS-Excel it is writing to the .pdf file from last cell to first cell.( 2 cell in 1 place, 1 cell in 2 place like if the row has two cells with data as : Name of the Intern: Kesavulu Reddy then it is writing to the .pdf file as Kesavulu Reddy Name of Intern)
and the second issue is:
It is not recognizing the date format..it is recognizing the date in first row only......
Plz Tell me wht is the solution for this...
Regards
[email protected]Don't double post your question:
http://forum.java.sun.com/thread.jspa?threadID=617605&messageID=3450899#3450899
/Kaj -
While generating reports in Oracle BI Publisher in pdf format, the generated pdf reports have hindi इ matra displaced by one character. For example, रिपोर्ट is printed as रपेिोरट. Word file generated of the same report have correct hindi इ matra position and also pdf generated from this word file also contains the same.
Maybe you are looking for
-
Multiple libraries/smart playlists for different disks, or sort by location
Hey. My iTunes music is physically stored on my computer's local hard disk, on an external hard disk, and on a remote server from which I stream online. When my computer is disconnected from my external hard disk or from the internet, I don't want to
-
Re: Shared Channel Strip settings, Plug-in settings...
Hi all, Has anyone gotten into shared Channel Strip settings and Plug-in settings? I read that there are multiple ways of doing this (bonjour). Just wondering if there are any good places on the net that anyone knows of. I know it's always best to ma
-
<%@ page import = "java.io.*, java.util.*,java.net.URL,java.awt.*,java.lang.*,java.sql.*" %> <HTML> <head></head> <body> <% ResultSet rs; Statement stmt; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); Co
-
Hi, I'm working on a Captivate project that I haven't created myself and I'm trying to extract the images used for some buttons. Is there some way to do that? I can't see the images in the library, so where are they? The reason for all this is becaus
-
Want to change the design of a report in query print layout
i want to change the design of a report.