Showing posts with label page. Show all posts
Showing posts with label page. Show all posts

Thursday, March 29, 2012

Create an index in a PDF file

Hi!!

I have a report that is exported to a PDF file... Is possible to get an index in the beginning of the file? I have the page number at the bottom of each page but i would need an index...

Thx in advance!!

Any idea? Isn′t possible to do it? At the moment, I havent found anything linked with this...|||

Hi Sergio,

Do you mean a document map? Check out this link: http://msdn2.microsoft.com/en-us/library/ms156383.aspx

|||

Hi Brad!!

not exactly... i would like to appear something similar but in a page in the beginning of the PDF document including the page number where each element is, i.e. the tables of the document... is there any option to do this? it′s very similar to the document map but with the page number...

I see two problems:

- I was thinking of using "=Globals.PageNumber" but i can′t, it says me that only can be placed in the header or the footer...

- and the other problem is setting the content of the document map in a page of the PDF... could I do this?

Perhaps, this is a bit difficult but I am always looking for challenges ... any suggestions? thx in advance!!

Sergio

|||I know of no way to accomplish exactly what you are looking for sorry to say. The document map links to items as repeated on pages. But I am not sure what you mean by "setting the content of the document map in a page of the PDF". If you mean as a page, there is no way to control this.|||

Hi Brad,

that was exactly i ment: i want to show it as a page, but if there is no way to do it... anyway, thank you for your help...

Sergio

Sunday, March 25, 2012

Create a PDF file directly to disk?

Hello all,

I use Reporting Services and an aspx page to create a PDF file. I need to save the file directly to a disk file with a name, without asking the user if he want to open or to save it. I'm using the folowing command:

Response.WriteFile("http://" & System.Environment.MachineName & "/ReportServer?%2fReportsApp%2fRptFSUnicoR&rs%3aCommand=Render&rs%3aFormat=PDF&MyID=" & IDFun,True)

Any idea how I do that?

Regards

HttpResponse.WriteFile requires either an absolute or virtual path to a sever-local filesystem location. So, referencing the URL of the report server won't work.

Also, I don't think you'll be able to bypass any browser's download prompt dialog without employing some sort of trusted control to do the HTTP request and file saving for you behind the scenes. SoftArtisans XFile is one such product that can do this.

-Chris

|||

Hi Chris,

Thank you for your answer. I'm afraid I will have to think in another solution.

As Report is generated from Reporting Services I thought I could have another parameter to force the "save" at the time I render the Report.

Best regards

sql

create a page index for a long crystal report

I have to create a page index for a long crystal report which is grouped by product group. Is there any way to create a page index using crystal report to identify the page number in which the product group is appear in the reportHi,

I think you can create Table of contents for the report in the Report header. I haven't worked on this as it requires CR 10... Im working on CR 8.x.. You can refer this article, which explains how to do it.

http://support.businessobjects.com/library/kbase/articles/c2011950.asp

Let me know if it works.

Bye,

Praveen|||Hi,

yes it can possible in CR 9 and CR 10 version,but we are using CR 8.x
is it possible in CR 8.x

thanks

sujesh

Monday, March 19, 2012

CR10 web viewer width 100%

Hello,
I'm trying to set my CrystalReportViewer to 100% of page width in ASP.NET. When I set the Width property on the control in the ASPX page itself, the viewer renders itself correctly when the page first loads, but on each postback the "%" is changed to "px" causing the viewer to be only 100 pixels wide.

I can apparently get around that by setting the width to Unit.Percentage(100) on every Page_Load event. Then the viewer appears as I expect with 100% width everytime I navigate pages, search, or export.

My problem is this workaround doesn't seem to work for the group tree. When I toggle the group tree, the two divs that get rendered are of width 14px and 86px (which add up to 100px).

Any ideas how I can get around this bug?

Thanks,
JamesI have a lousy solution but it seems to work (this is C# code but same should apply to VB):
public class MyCrystalReportViewer : CrystalDecisions.Web.CrystalReportViewer
{
protected override void Render(HtmlTextWriter output)
{
string renderedControl = string.Empty;

// Render the control to a string builder
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter htw = new HtmlTextWriter(sw);
base.Render(htw);

// Extract the string for processing
renderedControl = sb.ToString();

// Replace certain strings in the group tree div style tag
// Be sure to check for all indices along the way and just do nothing if things aren't found.
int groupTreeIndex = renderedControl.IndexOf("<div class=\"crgrptr\"");
if ( groupTreeIndex != -1 )
{
int groupTreeStyle = renderedControl.IndexOf("style=\"",groupTreeIndex);
if ( groupTreeStyle != -1 )
{
int groupTreeStyleEnd = renderedControl.IndexOf("\"",groupTreeStyle+7);
if ( groupTreeStyleEnd != -1 )
{
string groupTreeStyleTag = renderedControl.Substring(groupTreeStyle+7,groupTreeStyleEnd-groupTreeStyle-7);
renderedControl = renderedControl.Substring(0,groupTreeStyle+7)
+ "display:inline;" + groupTreeStyleTag.Replace("width:14px","width:14%").Replace("position:absolute","position:static")
+ renderedControl.Substring(groupTreeStyleEnd);
}
}
}

// Replace certain strings in the page div style tag
// Be sure to check for all indices along the way and just do nothing if things aren't found.
int pageIndex = renderedControl.IndexOf("<div class=\"crystalstyle\"");
if ( pageIndex != -1 )
{
int pageStyle = renderedControl.IndexOf("style=\"",pageIndex);
if ( pageStyle != -1 )
{
int pageStyleEnd = renderedControl.IndexOf("\"",pageStyle+7);
if ( pageStyleEnd != -1 )
{
string pageStyleTag = renderedControl.Substring(pageStyle+7,pageStyleEnd-pageStyle-7);
renderedControl = renderedControl.Substring(0,pageStyle+7)
+ "display:inline;" + pageStyleTag.Replace("width:86px","width:86%").Replace("position:absolute","position:static")
+ renderedControl.Substring(pageStyleEnd);
}
}
}

// Now output the reformatted HTML of the control
output.Write(renderedControl);
}
}

Sunday, March 11, 2012

CR10 ActiveX print orientation

Does anyone know how to set the page orientation of the print dialog on the users machine at runtime? Is it possible?
i.e. if you create a CR with landscape layout and the users default print setup is portrait the report will not print correctly.You need to define something called :

crep.PaperOrientation = 2 ; //crDefaultPaperOrientation

Where

crDefaultPaperOrientation= 0
crLandscape= 2
crPortrait = 1

Goto Crystal reports'd developer help and search for PaperOrientation or CRPaperOrientation :

Printer Settings
This application (some demo application) demonstrates how to change the report printer settings at runtime using code.

There are four new report properties that allow you to easily retrieve and set PaperSize, PaperOrientation, PaperSource, and PrinterDuplex for the report printer options. All of these are demonstrated.
There is also a new method called PrinterSetup that provides a Windows standard printer setup window to allow the user to change the printer properties directly at runtime. This is demonstrated as well.
The two methods are independent of each other. For example, changing the Windows standard printer setup will not alter the report printer settings and vice-versa. These new properties and the new method give you much more control over how the report is printed.


Thanks

:wave:

CR again

i want the detail to be display is 3 record per page for the same trans_code..

the format is like this :

trans_code : 1
page : 1
----
id_customer
----
1
2
3
----
total per page : 3

trans_code : 1
page : 2
----
id_customer
----
4
5
----
total per page : 2
total for trans_code : 1 is 5

i'm new at CR and i don't know the syntax that use in CR..
does anyone can help me plz?

thanks,
erickHi,

Open Section Criteria, Find New Page After event in detail section and
copy below code,

RecordNumber MOD 3=0

It will display only 3 records per page.

-Yags|||i already try that..thanks..it works..
but the problem is that it can't show the group footer..
i want to show how many records display in first page, and so on..and in last page i want to show all the records that has been display..

it make me counfuse coz i don't know the syntax that use in CR

CR 8.5 - (almost) blank first page

Hi,

Having a problem with crystal reports 8.5 (from within VB6). searched and searched, to no avail, so now I post... :)

i have a report with the following layout:
-Report header
-Page header
-Group header 1
-detail
-group footer 1
-page footer
-report footer

Problem is, if group 1 will not fit on the first page of the report, then the first page will print with only the report header and report footer on it - nothing else.

I've tried unchecking all the "Keep together" options on the sections but it doesn't change a thing. any advice people? i found an article talking about this problem and how V10 fixes it, but surely there is a workaround (or at least something). Frankly, I don't care if it puts half a section on a page if it will fit complete on the next - i just don't want this silly blank first page printing.Have you remembered checking off the Keep Group together option in both the Change Group Options and Format Section Menues? Doing this for all groups has worked for me this far.

- Jukka|||Great stuff - it works. Thanks heaps for actually finding this post and replying to it. I'd given up!

Sunday, February 19, 2012

Counting total number of queries executed within the page

Hi everyone,

Does exist an easy way to count the actually number of queries executed within a page?

I've searched here and in google but found anything...

Thanks in advance!

If SQL Server is your backend database, you can use SQL Profiler to run a trace on the statements executed.

|||

The db is sql server 2000, but it's on a shared server.. can I use the profiler in a shared environment too?

In case I can use it, does it aggregate someqhat the queries per ASP.NET page executed?

Thanks!

|||

>can I use the profiler in a shared environment too?
You can limit it by database.

>In case I can use it, does it aggregate someqhat the queries per ASP.NET page executed?
Given the right option it will report each query run.

Friday, February 17, 2012

Counting records

Hello,

I want to count some records in a table I have. My table is updated when someone posts information to an .asp page. Then, I use SSRS to create reports on this information in the table. I want to filter the results that the report shows based on how many records are in the table.

For instance:

Name last4 ID

John 2112 54432

John 3222 21223

John 7777 88888

John 3333 22222

John 3212 88722

Carol 2122 12111

Carol 5555 12111

Carol 3342 83635

Carol 1211 98363

Steve 2122 21331

James 2113 21123

Teresa 3223 21154

I want to filter the results shown in the report to records with > 3 occurances. So, the results for the above table would show only Carol and John.

Is there any way I can do this either in the SQL statement or in the reporting services statement?

Any help is appreciated.

Thanks

I think this ought to meet your needs

SELECT Name, last4, ID

FROM Some_Table

WHERE Name IN (

SELECT Name

FROM Some_Table

GROUP BY Name

HAVING COUNT(*) > 3

)

Just replace Some_Table with your table name.|||

Great. Thanks

I had something similar, but I had a few parts backwards. : )

So, if I wanted to add some more parameters should those go after the HAVING?

Like: HAVING COUNT (*) >3 AND Date BETWEEN @.startdate AND @.enddate

Thanks again.

|||Typically you would put the predicates that doesn't have any aggregate functions or GROUPING function in the WHERE clause. Logically the HAVING clause is seen as being evaluated after the GROUP BY clause has been evaluated so that the aggregate function results can be compared. This is different from the WHERE clause which can be evaluated at different stages (join conditions, table / index scans / seeks etc). So put the Date predicate in the WHERE clause and the COUNT(*) has to be in the HAVING clause.|||

So, if I understand correctly, it should be something like this:

SELECT Name, last4, ID

FROM Some_Table

WHERE Name IN (

SELECT Name

FROM Some_Table

GROUP BY Name

HAVING COUNT(*) > 3

) AND Date BETWEEN @.begindate AND @.enddate

Would that be the correct placement to include the date range in the WHERE clause?

Thanks again.

counting pages etc

i'm trying to make certian stuff inside a table header be shown on the
first page ONLY ,and other stuff hidden on the first page..
I'm having a lot of problems
in the end i want to put hidden.visibility to be based on some logic,
but i've found no way to differentiate the pages..
for example i try this custom code, to test something out, figure that
i should get a incremental increase everytime it is called
public shared thecount as integer = 0
Public Function docount as Integer
thecount = thecount + 1
return thecount
End Function
but inside the tables header i have
=Code.docount
and it shows 0 on every page..
anybody else pulled their hair out on this one, and has come through
the other side?I have an example of putting items in the footer on the first page only at
www.MSBICentral.com
It does not try to count pages, but can tell if this is the first
page...The File is called PageFooterOnFirstOnly.RDL
It is in the downloads section... Hope this helps..
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Karl Prosser" <klumsy@.xtra.co.nz> wrote in message
news:7156880c.0502151713.2432cd30@.posting.google.com...
> i'm trying to make certian stuff inside a table header be shown on the
> first page ONLY ,and other stuff hidden on the first page..
> I'm having a lot of problems
> in the end i want to put hidden.visibility to be based on some logic,
> but i've found no way to differentiate the pages..
> for example i try this custom code, to test something out, figure that
> i should get a incremental increase everytime it is called
> public shared thecount as integer = 0
> Public Function docount as Integer
> thecount = thecount + 1
> return thecount
> End Function
> but inside the tables header i have
> =Code.docount
> and it shows 0 on every page..
> anybody else pulled their hair out on this one, and has come through
> the other side?|||thanks for the example, but making a footer only show on the first page
was not my problem since headers and footers can look at the global
page counter, it was something in the body, in the header of a table..
i could use repeatonnewpage, however i needed some header stuff to show
sometimes and some not to. and i found that that even though a table
header can have many rows and each row has a repeat on new page
property, if you change one row, it changes them all, anyhow i managed
to do it with created another group, a dummy group and having my logic
in there..
also i found out why my example code above didn't work, it seems RS
only calculates the table header once (even though it repeats it on
subsequent pages, it doesn't recalculaste it, just reuses whatever was
last calculated)
Karl
Wayne Snyder wrote:
> I have an example of putting items in the footer on the first page
only at
> www.MSBICentral.com
> It does not try to count pages, but can tell if this is the first
> page...The File is called PageFooterOnFirstOnly.RDL
> It is in the downloads section... Hope this helps..
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Karl Prosser" <klumsy@.xtra.co.nz> wrote in message
> news:7156880c.0502151713.2432cd30@.posting.google.com...
> > i'm trying to make certian stuff inside a table header be shown on
the
> > first page ONLY ,and other stuff hidden on the first page..
> > I'm having a lot of problems
> > in the end i want to put hidden.visibility to be based on some
logic,
> > but i've found no way to differentiate the pages..
> >
> > for example i try this custom code, to test something out, figure
that
> > i should get a incremental increase everytime it is called
> >
> > public shared thecount as integer = 0
> > Public Function docount as Integer
> > thecount = thecount + 1
> > return thecount
> > End Function
> >
> > but inside the tables header i have
> > =Code.docount
> >
> > and it shows 0 on every page..
> >
> > anybody else pulled their hair out on this one, and has come
through
> > the other side?

Tuesday, February 14, 2012

counter inside select statement?

Hi, can you add a counter inside a select statement to get a unique id line of the rows?

In my forum i have a page that displays a users past posts in the forum, these are first sorted according to their topicID and then they are sorted after creation date. What i want is in the select statement is to create a counter to get a new numeric order.

This is the normal way:

SELECT id, post, comment, created FROM forum_posts WHERE (topicID = @.topicID) ... some more where/order by statements

This is what i want:

DECLARE @.tempCounter bigint
SET @.tempCounter = 0
SELECT @.tempCounter, id, post, comment, created FROM forum_posts WHERE (topicID = @.topicID)... some more where/order by statements and at the end.. (SELECT @.tempCounter = @.tempCounter + 1)

Anyone know if this can be done?

Use Row Num ( if you are using SQL SErver 2005 ) as

Select ROW_NUMBER() OVER(ORDER BY Some_Field ) AS rownum,
* from Table_Nane

|||

yes i am using MS SQL 2005, it worked for half of the problem, ill display the SP below, what the SP does is to select the posts from a single user, by ordering them first by topicID then by date created.
In order to bring back just what the client need, i incorperated a custom paging system.

DECLARE @.first_idint, @.startRowint
SET @.startRowIndex=(@.startRowIndex- 1)* @.maximumRows+ 1
IF @.startRowIndex= 0
SET @.startRowIndex= 1

SETROWCOUNT @.startRowIndex

SELECT @.first_id=ROW_NUMBER()OVER(ORDERBY forum_answer.topicidASC, forum_answer.idDESC)FROM forum_answerINNERJOIN forum_topicsON forum_topics.id= forum_answer.topicidINNERJOIN forum_boardON forum_board.id= forum_topics.boardidAND forum_board.hidden= 0INNERJOIN forumON forum.id= forum_board.forumidAND forum.hidden= 0RIGHTOUTERJOIN profile_publicinfoON profile_publicinfo.username= forum_answer.usernameWHERE(forum_answer.username= @.UserName)ORDERBY forum_answer.topicidASC, forum_answer.idDESC

SETROWCOUNT @.maximumRows

DECLARE @.tempVarint
SELECT @.tempVar=ROW_NUMBER()OVER(ORDERBY forum_answer.topicidASC, forum_answer.idDESC), forum_answer.topicid, forum_answer.id, forum_answer.username, forum_answer.answer, forum_answer.created, profile_publicinfo.signatureFROM forum_answerINNERJOIN forum_topicsON forum_topics.id= forum_answer.topicidINNERJOIN forum_boardON forum_board.id= forum_topics.boardidAND forum_board.hidden= 0INNERJOIN forumON forum.id= forum_board.forumidAND forum.hidden= 0RIGHTOUTERJOIN profile_publicinfoON profile_publicinfo.username= forum_answer.usernameWHERE(forum_answer.username= @.UserName)AND(@.first_id<= @.tempVar)ORDERBY forum_answer.topicidASC, forum_answer.idDESC

SETROWCOUNT 0

The first thing we do, is to get the id for the first post that should be returned. This works with the ROW_NUMBER method, the second select statement, takes xx number of rows with start from the position it recieves from the first select statement. So if @.first_id is 5 and maximumRows is 5, then the second select statement will only take rows 5->10 from the table.

The problem is the ROW_NUMBER inside the second select statement, sql screams if i put it at the end like (@.first_id <= ROW_NUMBER...

Msg 4108, Level 15, State 1, Procedure Forum_GetUserAnswers, Line 32
Windowed functions can only appear in the SELECT or ORDER BY clauses.

SQL also screams if i put it in the beginning (as shown above), then i get the following error:

Msg 141, Level 15, State 1, Procedure Forum_GetUserAnswers, Line 33
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.

Thats why i wanted a way to calculate the rows and get a ID according to that. Any idea of how to proceed?